diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-11 20:46:13 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-11 20:46:13 +0000 |
commit | 699fe08a2537ffcf4a1eec2fd5438c4f206384da (patch) | |
tree | 295e42d68db12bafb75de524b8834d528660d1ab | |
parent | tested blocking a signal, sending it to self, then unblocking it. (diff) | |
download | rtems-699fe08a2537ffcf4a1eec2fd5438c4f206384da.tar.bz2 |
Added test case which blocks a signal, sees what signals are pending, sends
that same signal to the executing thread, sees what is pending, then unblocks
that signal so the handler can execute.
-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 ); |