Changeset 481d8f8 in rtems for testsuites/psxtests/psx04


Ignore:
Timestamp:
Aug 8, 1996, 6:44:09 PM (24 years ago)
Author:
Mark Johannes <Mark.Johannes@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
77597dd
Parents:
4357da1
Message:

Signal_info_handler: added multiple signal cases to finish out the test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/psx04/init.c

    r4357da1 r481d8f8  
    3232}
    3333
     34void Signal_info_handler(
     35  int        signo,
     36  siginfo_t *info,
     37  void      *context
     38)
     39{
     40  Signal_count++;
     41  printf(
     42    "Signal_info: %d caught by 0x%x (%d) si_signo= %d si_code= %d value= %d\n",
     43    signo,
     44    pthread_self(),
     45    Signal_count,
     46    info->si_signo,
     47    info->si_code,
     48    info->si_value.sival_int
     49  );
     50  Signal_occurred = 1;
     51}
     52
    3453void *POSIX_Init(
    3554  void *argument
     
    4059  sigset_t          mask;
    4160  sigset_t          pending_set;
     61  sigset_t          oset;
    4262
    4363  puts( "\n\n*** POSIX TEST 4 ***" );
     
    5272  printf( "Init's ID is 0x%08x\n", Init_id );
    5373
    54   /* install a signal handler for SIGUSR1 */
     74/* install a signal handler for SIGUSR1 */
    5575
    5676  status = sigemptyset( &act.sa_mask );
    5777  assert( !status );
    58 
     78  printf( "Init: sigemptyset -  set= 0x%08x\n", act.sa_mask );
     79
     80  /* test sigfillset following the above sigemptyset */
     81
     82  status = sigfillset( &act.sa_mask );
     83  assert( !status );
     84  printf( "Init: sigfillset -  set= 0x%08x\n", act.sa_mask );
     85
     86  /* test sigdelset */
     87
     88  status = sigdelset( &act.sa_mask, SIGUSR1 );
     89  assert( !status );
     90  printf( "Init: sigdelset - delete SIGUSR1 set= 0x%08x\n", act.sa_mask );
     91
     92  /* test sigismember - FALSE */
     93
     94  status = sigismember( &act.sa_mask, SIGUSR1 );
     95  assert( !status );
     96  puts( "Init: sigismember - FALSE since SIGUSR1 is not a member" );
     97
     98  /* test sigismember - TRUE */
     99
     100  status = sigismember( &act.sa_mask, SIGUSR2 );
     101  assert( status );
     102  puts( "Init: sigismember - TRUE since SIGUSR2 is a member" );
     103
     104  /* return the set to empty */
     105
     106  act.sa_handler = Signal_handler;
     107  act.sa_flags   = 0;
     108 
     109  sigaction( SIGUSR1, &act, NULL );
     110
     111  /* simple signal to process */
     112
     113  Signal_count = 0;
     114  Signal_occurred = 0;
     115
     116  printf( "Init: send SIGUSR1 to process\n" );
     117  status = kill( getpid(), SIGUSR1 );
     118  assert( !status );
     119
     120/* end of install a signal handler for SIGUSR1 */
     121
     122  Signal_occurred = 0;
     123
     124  /* now block the signal, send it, see if it is pending, and unblock it */
     125
     126  empty_line();
     127
     128  status = sigemptyset( &mask );
     129  assert( !status );
     130
     131  status = sigaddset( &mask, SIGUSR1 );
     132  assert( !status );
     133
     134  printf( "Init: Block SIGUSR1\n" );
    59135  act.sa_handler = Signal_handler;
    60136  act.sa_flags   = 0;
     
    108184
    109185  printf( "Init: create a thread interested in SIGUSR1\n" );
    110   status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
     186  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
    111187  assert( !status );
    112188
     
    180256  assert( status );
    181257
     258  /* test SIG_SETMASK case and returning oset of pthread_sigmask */
     259
     260  empty_line();
     261
     262  status = sigemptyset( &mask );
     263  assert( !status );
     264 
     265  status = sigaddset( &mask, SIGUSR1 );
     266  assert( !status );
     267
     268  status = sigaddset( &mask, SIGUSR2 );
     269  assert( !status );
     270
     271  printf( "Init: Block SIGUSR1 and SIGUSR2 only\n" );
     272  status = pthread_sigmask( SIG_SETMASK, &mask, &oset );
     273  printf( "Init: Previous blocked set was 0x%08x\n", oset );
     274  assert( !status );
     275
     276  /* test inquiry about current blocked set with pthread_sigmask */
     277 
     278  status = pthread_sigmask( NULL, NULL, &oset );
     279  printf( "Init: Current blocked set is 0x%08x\n", oset );
     280  assert( !status );
     281
     282  /* return blocked mask to no signals blocked */
     283
     284  status = sigemptyset( &mask );
     285  assert( !status );
     286 
     287  printf( "Init: Unblock all signals\n" );
     288  status = pthread_sigmask( SIG_SETMASK, &mask, &oset );
     289  printf( "Init: Previous blocked set was 0x%08x\n", oset );
     290  assert( !status );
     291
     292  /* test sigsuspend */
     293
     294  empty_line();
     295
     296  printf( "Init: create a thread to send Init SIGUSR1\n" );
     297  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
     298  assert( !status );
     299
     300  status = sigemptyset( &mask );
     301  assert( !status );
     302 
     303  printf( "Init: sigsuspend for any signal\n" );
     304  status = sigsuspend( &mask );
     305  assert( status );
     306  printf( "Init: awakended from sigsuspend status=%08d \n", status );
     307
     308  /* test a SIGINFO case, these are signals sent to a process only */
     309
     310  empty_line();
     311
     312  printf( "Init: create a thread to sent Process SIGUSR1 with SA_SIGINFO\n" );
     313  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
     314  assert( !status );
     315
     316  /* set action on SIGUSR1 to an info case */
     317  act.sa_handler   = Signal_handler;
     318  act.sa_flags     = SA_SIGINFO;
     319  act.sa_sigaction = Signal_info_handler;
     320 
     321  sigaction( SIGUSR1, &act, NULL );
     322
     323  printf( "Init: sleep so the Task_3 can sigqueue SIGUSR1\n" );
     324  status = sleep( 1 );
     325  assert( !status );
     326
     327     /* switch to task 1 */
     328
     329  puts( "Init: sigqueue occurred" );
     330
     331  /* Send SIGUSR1, Task_3 has issued a sigwaitinfo */
     332
     333  status = sigemptyset( &mask );
     334  assert( !status );
     335
     336  status = sigaddset( &mask, SIGUSR1 );
     337  assert( !status );
     338
     339  printf( "Init: Block SIGUSR1\n" );
     340  status = sigprocmask( SIG_BLOCK, &mask, NULL );
     341  assert( !status );
     342
     343  printf( "Init: send SIGUSR1 to process\n" );
     344  status = kill( getpid(), SIGUSR1 );
     345  assert( !status );
     346
     347  printf( "Init: sleep so the Task_3 can receive SIGUSR1\n" );
     348  status = sleep( 1 );
     349  assert( !status );
     350
     351  /* Send SIGUSR1, Task_3 has issued a sigwait */
     352 
     353  status = sigemptyset( &mask );
     354  assert( !status );
     355 
     356  status = sigaddset( &mask, SIGUSR1 );
     357  assert( !status );
     358 
     359  printf( "Init: Block SIGUSR1\n" );
     360  status = sigprocmask( SIG_BLOCK, &mask, NULL );
     361  assert( !status );
     362 
     363  printf( "Init: send SIGUSR1 to process\n" );
     364  status = kill( getpid(), SIGUSR1 );
     365  assert( !status );
     366 
     367  printf( "Init: sleep so the Task_3 can receive SIGUSR1\n" );
     368  status = sleep( 1 );
     369  assert( !status );
     370
     371  /* Send SIGUSR1, Task_3 has issued a sigwaitinfo */
     372 
     373  status = sigemptyset( &mask );
     374  assert( !status );
     375 
     376  status = sigaddset( &mask, SIGUSR2 );
     377  assert( !status );
     378 
     379  printf( "Init: Block SIGUSR2\n" );
     380  status = sigprocmask( SIG_BLOCK, &mask, NULL );
     381  assert( !status );
     382 
     383  printf( "Init: send SIGUSR2 to process\n" );
     384  status = kill( getpid(), SIGUSR2 );
     385  assert( !status );
     386 
     387  printf( "Init: sleep so the Task_3 can receive SIGUSR2\n" );
     388  status = sleep( 1 );
     389  assert( !status );
     390
     391  /* Suspend for signal that has already be sent */
     392
     393  printf( "Init: sigsuspend for any signal\n" );
     394  status = sigsuspend( &mask );
     395  assert( status );
     396  printf( "Init: awakended from sigsuspend status=%d \n", status );
     397
    182398  /* exit this thread */
    183399
Note: See TracChangeset for help on using the changeset viewer.