diff options
-rw-r--r-- | c/src/tests/psxtests/psx02/init.c | 45 | ||||
-rw-r--r-- | testsuites/psxtests/psx02/init.c | 45 |
2 files changed, 88 insertions, 2 deletions
diff --git a/c/src/tests/psxtests/psx02/init.c b/c/src/tests/psxtests/psx02/init.c index cd017e62eb..3b3b0ef4a0 100644 --- a/c/src/tests/psxtests/psx02/init.c +++ b/c/src/tests/psxtests/psx02/init.c @@ -15,12 +15,19 @@ #include <signal.h> volatile int Signal_occurred; +volatile int Signal_count; void Signal_handler( int signo ) { - printf( "Signal: %d caught by 0x%x\n", signo, pthread_self() ); + Signal_count++; + printf( + "Signal: %d caught by 0x%x (%d)\n", + signo, + pthread_self(), + Signal_count + ); Signal_occurred = 1; } @@ -32,6 +39,8 @@ void *POSIX_Init( struct timespec tv; struct timespec tr; struct sigaction act; + sigset_t mask; + sigset_t pending_set; puts( "\n\n*** POSIX TEST 2 ***" ); @@ -56,9 +65,43 @@ void *POSIX_Init( /* simple signal to self */ + Signal_count = 0; + Signal_occurred = 0; + + status = pthread_kill( Init_id, SIGUSR1 ); + assert( !status ); + + Signal_occurred = 0; + + /* now block the signal, send it, see if it is pending, and unblock it */ + + status = sigemptyset( &mask ); + assert( !status ); + + status = sigaddset( &mask, SIGUSR1 ); + assert( !status ); + + printf( "Init: Block SIGUSR1\n" ); + status = sigprocmask( SIG_BLOCK, &mask, NULL ); + assert( !status ); + + status = sigpending( &pending_set ); + assert( !status ); + printf( "Init: Signals pending 0x%08x\n", pending_set ); + + + printf( "Init: send SIGUSR1 to self\n" ); status = pthread_kill( Init_id, SIGUSR1 ); assert( !status ); + status = sigpending( &pending_set ); + assert( !status ); + printf( "Init: Signals pending 0x%08x\n", pending_set ); + + printf( "Init: Unblock SIGUSR1\n" ); + status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); + assert( !status ); + /* create a thread */ status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL ); diff --git a/testsuites/psxtests/psx02/init.c b/testsuites/psxtests/psx02/init.c index cd017e62eb..3b3b0ef4a0 100644 --- a/testsuites/psxtests/psx02/init.c +++ b/testsuites/psxtests/psx02/init.c @@ -15,12 +15,19 @@ #include <signal.h> volatile int Signal_occurred; +volatile int Signal_count; void Signal_handler( int signo ) { - printf( "Signal: %d caught by 0x%x\n", signo, pthread_self() ); + Signal_count++; + printf( + "Signal: %d caught by 0x%x (%d)\n", + signo, + pthread_self(), + Signal_count + ); Signal_occurred = 1; } @@ -32,6 +39,8 @@ void *POSIX_Init( struct timespec tv; struct timespec tr; struct sigaction act; + sigset_t mask; + sigset_t pending_set; puts( "\n\n*** POSIX TEST 2 ***" ); @@ -56,9 +65,43 @@ void *POSIX_Init( /* simple signal to self */ + Signal_count = 0; + Signal_occurred = 0; + + status = pthread_kill( Init_id, SIGUSR1 ); + assert( !status ); + + Signal_occurred = 0; + + /* now block the signal, send it, see if it is pending, and unblock it */ + + status = sigemptyset( &mask ); + assert( !status ); + + status = sigaddset( &mask, SIGUSR1 ); + assert( !status ); + + printf( "Init: Block SIGUSR1\n" ); + status = sigprocmask( SIG_BLOCK, &mask, NULL ); + assert( !status ); + + status = sigpending( &pending_set ); + assert( !status ); + printf( "Init: Signals pending 0x%08x\n", pending_set ); + + + printf( "Init: send SIGUSR1 to self\n" ); status = pthread_kill( Init_id, SIGUSR1 ); assert( !status ); + status = sigpending( &pending_set ); + assert( !status ); + printf( "Init: Signals pending 0x%08x\n", pending_set ); + + printf( "Init: Unblock SIGUSR1\n" ); + status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); + assert( !status ); + /* create a thread */ status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL ); |