Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:40

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 2017.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include "tmacros.h"
0034 #include <signal.h>
0035 #include <string.h>
0036 #include <stdio.h>
0037 
0038 const char rtems_test_name[] = "PSXSTRSIGNAL 1";
0039 typedef struct {
0040   char *sigstr;
0041   int   signal;
0042 } Signals_t;
0043 
0044 Signals_t Signals[] = {
0045   { "SIGHUP",   SIGHUP },
0046   { "SIGINT",   SIGINT },
0047   { "SIGQUIT",  SIGQUIT },
0048   { "SIGILL",   SIGILL },
0049   { "SIGTRAP",  SIGTRAP },
0050   { "SIGIOT",   SIGIOT },
0051   { "SIGABRT",  SIGABRT },
0052 #ifdef SIGEMT
0053   { "SIGEMT",   SIGEMT },
0054 #endif
0055   { "SIGFPE",   SIGFPE },
0056   { "SIGKILL",  SIGKILL },
0057   { "SIGBUS",   SIGBUS },
0058   { "SIGSEGV",  SIGSEGV },
0059   { "SIGSYS",   SIGSYS },
0060   { "SIGPIPE",  SIGPIPE },
0061   { "SIGALRM",  SIGALRM },
0062   { "SIGTERM",  SIGTERM },
0063   { "SIGURG",   SIGURG },
0064   { "SIGSTOP",  SIGSTOP },
0065   { "SIGTSTP",  SIGTSTP },
0066   { "SIGCONT",  SIGCONT },
0067   { "SIGCHLD",  SIGCHLD },
0068   { "SIGCLD",   SIGCLD },
0069   { "SIGTTIN",  SIGTTIN },
0070   { "SIGTTOU",  SIGTTOU },
0071   { "SIGIO",    SIGIO },
0072   { "SIGPOLL",  SIGPOLL },
0073   { "SIGWINCH", SIGWINCH },
0074   { "SIGUSR1",  SIGUSR1 },
0075   { "SIGUSR2",  SIGUSR2 },
0076   { NULL,       -1 },
0077 };
0078 
0079 void do_test(void);
0080 void do_test_rt(void);
0081 void *POSIX_Init(void *unused);
0082 
0083 void do_test(void)
0084 {
0085   int i;
0086 
0087   puts( "=== Normal Signals" );
0088   for (i=0 ; Signals[i].sigstr ; i++) {
0089     printf(
0090       "signal=%s => %s\n",
0091       Signals[i].sigstr,
0092       strsignal(Signals[i].signal)
0093     );
0094   }
0095 }
0096 
0097 void do_test_rt(void)
0098 {
0099   int sig;
0100 
0101   puts( "=== Real-Time Signals" );
0102   for (sig=SIGRTMIN ; sig <= SIGRTMAX ; sig++) {
0103     printf(
0104       "signal=SIGRTMIN+%d => %s\n",
0105       sig-SIGRTMIN,
0106       strsignal(sig)
0107     );
0108   }
0109 }
0110 
0111 void *POSIX_Init(
0112   void *unused
0113 )
0114 {
0115   TEST_BEGIN();
0116 
0117   do_test();
0118   puts("");
0119   do_test_rt();
0120 
0121   TEST_END();
0122   rtems_test_exit( 0 );
0123 
0124   return NULL; /* just so the compiler thinks we returned something */
0125 }
0126 
0127 /* configuration information */
0128 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0129 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0130 
0131 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0132 
0133 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
0134 
0135 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0136 
0137 #define CONFIGURE_INIT
0138 #include <rtems/confdefs.h>