summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx04
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-13 16:44:46 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-13 16:44:46 +0000
commitce0f7d95d62ce3e90368320a207635fb05acbbe0 (patch)
treecee25d8b97dbf07cedd919f59bc6836e8b566a61 /testsuites/psxtests/psx04
parentAdded code so post context switch extensions can be run on every context (diff)
downloadrtems-ce0f7d95d62ce3e90368320a207635fb05acbbe0.tar.bz2
Added more test cases for kill() and alarm(). kill() now can unblock a
thread which has the signal unblocked.
Diffstat (limited to 'testsuites/psxtests/psx04')
-rw-r--r--testsuites/psxtests/psx04/init.c91
1 files changed, 68 insertions, 23 deletions
diff --git a/testsuites/psxtests/psx04/init.c b/testsuites/psxtests/psx04/init.c
index 23e2871a60..1db88461df 100644
--- a/testsuites/psxtests/psx04/init.c
+++ b/testsuites/psxtests/psx04/init.c
@@ -36,8 +36,6 @@ void *POSIX_Init(
)
{
int status;
- struct timespec tv;
- struct timespec tr;
struct sigaction act;
sigset_t mask;
sigset_t pending_set;
@@ -53,7 +51,7 @@ void *POSIX_Init(
Init_id = pthread_self();
printf( "Init's ID is 0x%08x\n", Init_id );
- /* install a signal handler */
+ /* install a signal handler for SIGUSR1 */
status = sigemptyset( &act.sa_mask );
assert( !status );
@@ -76,6 +74,8 @@ void *POSIX_Init(
/* now block the signal, send it, see if it is pending, and unblock it */
+ empty_line();
+
status = sigemptyset( &mask );
assert( !status );
@@ -102,37 +102,82 @@ void *POSIX_Init(
status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
assert( !status );
- puts( "*** END OF POSIX TEST 4 ***" );
- exit( 0 );
+ /* now let another task get interrupted by a signal */
- /* create a thread */
+ empty_line();
+ printf( "Init: create a thread interested in SIGUSR1\n" );
status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
assert( !status );
- /*
- * Loop for 5 seconds seeing how many signals we catch
- */
+ 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 );
- tr.tv_sec = 5;
- tr.tv_nsec = 0;
+ printf( "Init: sleep so the other task can block\n" );
+ status = sleep( 1 );
+ assert( !status );
+
+ /* switch to task 1 */
+
+ printf( "Init: send SIGUSR1 to process\n" );
+ status = kill( getpid(), SIGUSR1 );
+ assert( !status );
- do {
- tv = tr;
+ status = sigpending( &pending_set );
+ assert( !status );
+ printf( "Init: Signals pending 0x%08x\n", pending_set );
+
+ printf( "Init: sleep so the other task can catch signal\n" );
+ status = sleep( 1 );
+ assert( !status );
- Signal_occurred = 0;
+ /* switch to task 1 */
- status = nanosleep ( &tv, &tr );
- assert( !status );
+ /* test alarm */
+
+ empty_line();
+
+ /* install a signal handler for SIGALRM and unblock it */
+
+ status = sigemptyset( &act.sa_mask );
+ assert( !status );
+
+ act.sa_handler = Signal_handler;
+ act.sa_flags = 0;
+
+ sigaction( SIGALRM, &act, NULL );
+
+ status = sigemptyset( &mask );
+ assert( !status );
+
+ status = sigaddset( &mask, SIGALRM );
+ assert( !status );
+
+ printf( "Init: Unblock SIGALRM\n" );
+ status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
+ assert( !status );
+
+ /* schedule the alarm */
+
+ printf( "Init: Firing alarm in 5 seconds\n" );
+ status = alarm( 5 );
+ printf( "Init: %d seconds left on previous alarm\n", status );
+ assert( !status );
- printf(
- "Init: signal was %sprocessed with %d:%d time remaining\n",
- (Signal_occurred) ? "" : "not ",
- (int) tr.tv_sec,
- (int) tr.tv_nsec
- );
+ printf( "Init: Firing alarm in 2 seconds\n" );
+ status = alarm( 2 );
+ printf( "Init: %d seconds left on previous alarm\n", status );
+ assert( status );
- } while ( tr.tv_sec || tr.tv_nsec );
+ printf( "Init: Wait 4 seconds for alarm\n" );
+ status = sleep( 4 );
+ printf( "Init: %d seconds left in sleep\n", status );
+ assert( status );
/* exit this thread */