Changeset 0c07f69 in rtems


Ignore:
Timestamp:
Sep 28, 2009, 11:52:46 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
5fc4c4b5
Parents:
bfd225e
Message:

2009-09-28 Joel Sherrill <joel.sherrill@…>

  • psxcancel/init.c, psxcancel/psxcancel.scn, psxcancel01/init.c, psxcancel01/psxcancel01.scn: Add missing pthread cancellation test cases.
Location:
testsuites/psxtests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/ChangeLog

    rbfd225e r0c07f69  
     12009-09-28      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * psxcancel/init.c, psxcancel/psxcancel.scn, psxcancel01/init.c,
     4        psxcancel01/psxcancel01.scn: Add missing pthread cancellation test
     5        cases.
     6
    172009-09-28      Joel Sherrill <joel.sherrill@OARcorp.com>
    28
  • testsuites/psxtests/psxcancel/init.c

    rbfd225e r0c07f69  
    9292  fatal_posix_service_status( sc, EINVAL, "cancel type EINVAL" );
    9393
     94  puts( "Init - pthread_cancel - bad ID - EINVAL" );
     95  sc = pthread_cancel(0x100);
     96  fatal_posix_service_status( sc, EINVAL, "cancel bad Id" );
     97
    9498  /* Start countTask deferred */
    9599  {
  • testsuites/psxtests/psxcancel/psxcancel.scn

    rbfd225e r0c07f69  
    44Init - pthread_setcanceltype - NULL oldtype - EINVAL
    55Init - pthread_setcanceltype - bad type - EINVAL
     6Init - pthread_cancel - bad ID - EINVAL
    67countTaskDeferred: elapsed time (second):  0
    78countTaskDeferred: elapsed time (second):  1
  • testsuites/psxtests/psxcancel01/init.c

    rbfd225e r0c07f69  
    1313#include <errno.h>
    1414
    15 volatile int Cancel_occurred;
    16 volatile int Cancel_status;
     15volatile int TSR_occurred;
     16volatile int TSR_status;
     17
     18rtems_id  timer_id;
    1719
    1820rtems_timer_service_routine Cancel_duringISR_TSR(
     
    2123)
    2224{
    23   Cancel_status = pthread_cancel( pthread_self() );
    24   Cancel_occurred = 1;
     25  TSR_status = pthread_cancel( pthread_self() );
     26  TSR_occurred = 1;
    2527}
    2628
     29rtems_timer_service_routine SetState_duringISR_TSR(
     30  rtems_id  ignored_id,
     31  void     *ignored_address
     32)
     33{
     34  int oldstate;
     35
     36  TSR_status = pthread_setcancelstate( 0, &oldstate );
     37  TSR_occurred = 1;
     38}
     39
     40rtems_timer_service_routine SetType_duringISR_TSR(
     41  rtems_id  ignored_id,
     42  void     *ignored_address
     43)
     44{
     45  int oldtype;
     46
     47  TSR_status = pthread_setcanceltype( 0, &oldtype );
     48  TSR_occurred = 1;
     49}
     50
     51void doit(
     52  rtems_timer_service_routine (*TSR)(rtems_id, void *),
     53  const char                   *method
     54)
     55{
     56  rtems_interval    start;
     57  rtems_interval    end;
     58  rtems_status_code status;
     59
     60  printf( "Init: schedule %s from a TSR\n", method );
     61
     62  TSR_occurred = 0;
     63  TSR_status   = 0;
     64
     65  status = rtems_timer_fire_after( timer_id, 10, TSR, NULL );
     66  assert( !status );
     67
     68  do {
     69    end = rtems_clock_get_ticks_since_boot();
     70  } while ( !TSR_occurred && ((end - start) <= 800));
     71
     72  if ( !TSR_occurred ) {
     73    printf( "%s did not occur\n", method );
     74    rtems_test_exit(0);
     75  }
     76  if ( TSR_status != EPROTO ) {
     77    printf( "%s returned %s\n", method, strerror(TSR_status) );
     78    rtems_test_exit(0);
     79  }
     80  printf( "%s - from ISR returns EPROTO - OK\n", method );
     81
     82}
    2783
    2884void *POSIX_Init(
     
    3086)
    3187{
    32   int             status;
    33   rtems_interval  start;
    34   rtems_interval  end;
    35   rtems_id        timer_id;
     88  rtems_status_code status;
    3689
    3790  puts( "\n\n*** POSIX TEST CANCEL 01 ***" );
     
    4396  assert( !status );
    4497
    45   Cancel_occurred = 0;
    46   Cancel_status   = 0;
    47 
    48   puts( "Init: schedule pthread_cancel from a TSR" );
    49   status = rtems_timer_fire_after( timer_id, 10, Cancel_duringISR_TSR, NULL );
    50   assert( !status );
    51 
    52   /* cancel occurs during sleep */
    53 
    54   do {
    55     end = rtems_clock_get_ticks_since_boot();
    56   } while ( !Cancel_occurred && ((end - start) <= 800));
    57 
    58   if ( !Cancel_occurred ) {
    59     puts( "Cancel did not occur" );
    60     rtems_test_exit(0);
    61   }
    62   if ( Cancel_status != EPROTO ) {
    63     printf( "Cancel returned %s\n", strerror(Cancel_status) );
    64     rtems_test_exit(0);
    65   }
    66   puts( "pthread_cancel - from ISR returns EPROTO - OK" );
    67 
     98  doit( Cancel_duringISR_TSR, "pthread_cancel" );
     99  doit( SetState_duringISR_TSR, "pthread_setcancelstate" );
     100  doit( SetType_duringISR_TSR, "pthread_setcanceltype" );
    68101
    69102  puts( "*** END OF POSIX TEST CANCEL 01 ***" );
  • testsuites/psxtests/psxcancel01/psxcancel01.scn

    rbfd225e r0c07f69  
    22Init: schedule pthread_cancel from a TSR
    33pthread_cancel - from ISR returns EPROTO - OK
     4Init: schedule pthread_setcancelstate from a TSR
     5pthread_setcancelstate - from ISR returns EPROTO - OK
     6Init: schedule pthread_setcanceltype from a TSR
     7pthread_setcanceltype - from ISR returns EPROTO - OK
    48*** END OF POSIX TEST CANCEL 01 ***
Note: See TracChangeset for help on using the changeset viewer.