Changeset ce0f7d95 in rtems


Ignore:
Timestamp:
Jun 13, 1996, 4:44:46 PM (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
728b5a7
Parents:
1b17790
Message:

Added more test cases for kill() and alarm(). kill() now can unblock a
thread which has the signal unblocked.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psx04/init.c

    r1b17790 rce0f7d95  
    3737{
    3838  int               status;
    39   struct timespec   tv;
    40   struct timespec   tr;
    4139  struct sigaction  act;
    4240  sigset_t          mask;
     
    5452  printf( "Init's ID is 0x%08x\n", Init_id );
    5553
    56   /* install a signal handler */
     54  /* install a signal handler for SIGUSR1 */
    5755
    5856  status = sigemptyset( &act.sa_mask );
     
    7674
    7775  /* now block the signal, send it, see if it is pending, and unblock it */
     76
     77  empty_line();
    7878
    7979  status = sigemptyset( &mask );
     
    103103  assert( !status );
    104104
    105   puts( "*** END OF POSIX TEST 4 ***" );
    106   exit( 0 );
     105  /* now let another task get interrupted by a signal */
    107106
    108   /* create a thread */
     107  empty_line();
    109108
     109  printf( "Init: create a thread interested in SIGUSR1\n" );
    110110  status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
    111111  assert( !status );
    112112
    113   /*
    114    *  Loop for 5 seconds seeing how many signals we catch
    115    */
     113  printf( "Init: Block SIGUSR1\n" );
     114  status = sigprocmask( SIG_BLOCK, &mask, NULL );
     115  assert( !status );
     116 
     117  status = sigpending( &pending_set );
     118  assert( !status );
     119  printf( "Init: Signals pending 0x%08x\n", pending_set );
    116120
    117   tr.tv_sec = 5;
    118   tr.tv_nsec = 0;
     121  printf( "Init: sleep so the other task can block\n" );
     122  status = sleep( 1 );
     123  assert( !status );
     124
     125     /* switch to task 1 */
     126
     127  printf( "Init: send SIGUSR1 to process\n" );
     128  status = kill( getpid(), SIGUSR1 );
     129  assert( !status );
    119130 
    120   do {
    121     tv = tr;
     131  status = sigpending( &pending_set );
     132  assert( !status );
     133  printf( "Init: Signals pending 0x%08x\n", pending_set );
    122134
    123     Signal_occurred = 0;
     135  printf( "Init: sleep so the other task can catch signal\n" );
     136  status = sleep( 1 );
     137  assert( !status );
    124138
    125     status = nanosleep ( &tv, &tr );
    126     assert( !status );
     139     /* switch to task 1 */
    127140
    128     printf(
    129       "Init: signal was %sprocessed with %d:%d time remaining\n",
    130       (Signal_occurred) ? "" : "not ",
    131       (int) tr.tv_sec,
    132       (int) tr.tv_nsec
    133    );
     141  /* test alarm */
    134142
    135   } while ( tr.tv_sec || tr.tv_nsec );
     143  empty_line();
     144
     145  /* install a signal handler for SIGALRM and unblock it */
     146 
     147  status = sigemptyset( &act.sa_mask );
     148  assert( !status );
     149 
     150  act.sa_handler = Signal_handler;
     151  act.sa_flags   = 0;
     152 
     153  sigaction( SIGALRM, &act, NULL );
     154 
     155  status = sigemptyset( &mask );
     156  assert( !status );
     157 
     158  status = sigaddset( &mask, SIGALRM );
     159  assert( !status );
     160 
     161  printf( "Init: Unblock SIGALRM\n" );
     162  status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
     163  assert( !status );
     164
     165  /* schedule the alarm */
     166 
     167  printf( "Init: Firing alarm in 5 seconds\n" );
     168  status = alarm( 5 );
     169  printf( "Init: %d seconds left on previous alarm\n", status );
     170  assert( !status );
     171
     172  printf( "Init: Firing alarm in 2 seconds\n" );
     173  status = alarm( 2 );
     174  printf( "Init: %d seconds left on previous alarm\n", status );
     175  assert( status );
     176
     177  printf( "Init: Wait 4 seconds for alarm\n" );
     178  status = sleep( 4 );
     179  printf( "Init: %d seconds left in sleep\n", status );
     180  assert( status );
    136181
    137182  /* exit this thread */
  • testsuites/psxtests/psx04/init.c

    r1b17790 rce0f7d95  
    3737{
    3838  int               status;
    39   struct timespec   tv;
    40   struct timespec   tr;
    4139  struct sigaction  act;
    4240  sigset_t          mask;
     
    5452  printf( "Init's ID is 0x%08x\n", Init_id );
    5553
    56   /* install a signal handler */
     54  /* install a signal handler for SIGUSR1 */
    5755
    5856  status = sigemptyset( &act.sa_mask );
     
    7674
    7775  /* now block the signal, send it, see if it is pending, and unblock it */
     76
     77  empty_line();
    7878
    7979  status = sigemptyset( &mask );
     
    103103  assert( !status );
    104104
    105   puts( "*** END OF POSIX TEST 4 ***" );
    106   exit( 0 );
     105  /* now let another task get interrupted by a signal */
    107106
    108   /* create a thread */
     107  empty_line();
    109108
     109  printf( "Init: create a thread interested in SIGUSR1\n" );
    110110  status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
    111111  assert( !status );
    112112
    113   /*
    114    *  Loop for 5 seconds seeing how many signals we catch
    115    */
     113  printf( "Init: Block SIGUSR1\n" );
     114  status = sigprocmask( SIG_BLOCK, &mask, NULL );
     115  assert( !status );
     116 
     117  status = sigpending( &pending_set );
     118  assert( !status );
     119  printf( "Init: Signals pending 0x%08x\n", pending_set );
    116120
    117   tr.tv_sec = 5;
    118   tr.tv_nsec = 0;
     121  printf( "Init: sleep so the other task can block\n" );
     122  status = sleep( 1 );
     123  assert( !status );
     124
     125     /* switch to task 1 */
     126
     127  printf( "Init: send SIGUSR1 to process\n" );
     128  status = kill( getpid(), SIGUSR1 );
     129  assert( !status );
    119130 
    120   do {
    121     tv = tr;
     131  status = sigpending( &pending_set );
     132  assert( !status );
     133  printf( "Init: Signals pending 0x%08x\n", pending_set );
    122134
    123     Signal_occurred = 0;
     135  printf( "Init: sleep so the other task can catch signal\n" );
     136  status = sleep( 1 );
     137  assert( !status );
    124138
    125     status = nanosleep ( &tv, &tr );
    126     assert( !status );
     139     /* switch to task 1 */
    127140
    128     printf(
    129       "Init: signal was %sprocessed with %d:%d time remaining\n",
    130       (Signal_occurred) ? "" : "not ",
    131       (int) tr.tv_sec,
    132       (int) tr.tv_nsec
    133    );
     141  /* test alarm */
    134142
    135   } while ( tr.tv_sec || tr.tv_nsec );
     143  empty_line();
     144
     145  /* install a signal handler for SIGALRM and unblock it */
     146 
     147  status = sigemptyset( &act.sa_mask );
     148  assert( !status );
     149 
     150  act.sa_handler = Signal_handler;
     151  act.sa_flags   = 0;
     152 
     153  sigaction( SIGALRM, &act, NULL );
     154 
     155  status = sigemptyset( &mask );
     156  assert( !status );
     157 
     158  status = sigaddset( &mask, SIGALRM );
     159  assert( !status );
     160 
     161  printf( "Init: Unblock SIGALRM\n" );
     162  status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
     163  assert( !status );
     164
     165  /* schedule the alarm */
     166 
     167  printf( "Init: Firing alarm in 5 seconds\n" );
     168  status = alarm( 5 );
     169  printf( "Init: %d seconds left on previous alarm\n", status );
     170  assert( !status );
     171
     172  printf( "Init: Firing alarm in 2 seconds\n" );
     173  status = alarm( 2 );
     174  printf( "Init: %d seconds left on previous alarm\n", status );
     175  assert( status );
     176
     177  printf( "Init: Wait 4 seconds for alarm\n" );
     178  status = sleep( 4 );
     179  printf( "Init: %d seconds left in sleep\n", status );
     180  assert( status );
    136181
    137182  /* exit this thread */
Note: See TracChangeset for help on using the changeset viewer.