diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-28 23:52:46 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-09-28 23:52:46 +0000 |
commit | 0c07f6950ffe764f3c4ec37924a9921638a7079a (patch) | |
tree | cfbe9fa523c135f01d3b4ce1217ec2d1131a6ca7 /testsuites/psxtests/psxcancel01 | |
parent | 2009-09-28 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-0c07f6950ffe764f3c4ec37924a9921638a7079a.tar.bz2 |
2009-09-28 Joel Sherrill <joel.sherrill@OARcorp.com>
* psxcancel/init.c, psxcancel/psxcancel.scn, psxcancel01/init.c,
psxcancel01/psxcancel01.scn: Add missing pthread cancellation test
cases.
Diffstat (limited to 'testsuites/psxtests/psxcancel01')
-rw-r--r-- | testsuites/psxtests/psxcancel01/init.c | 89 | ||||
-rw-r--r-- | testsuites/psxtests/psxcancel01/psxcancel01.scn | 4 |
2 files changed, 65 insertions, 28 deletions
diff --git a/testsuites/psxtests/psxcancel01/init.c b/testsuites/psxtests/psxcancel01/init.c index 437fd93588..72f95b1c10 100644 --- a/testsuites/psxtests/psxcancel01/init.c +++ b/testsuites/psxtests/psxcancel01/init.c @@ -12,59 +12,92 @@ #include <pmacros.h> #include <errno.h> -volatile int Cancel_occurred; -volatile int Cancel_status; +volatile int TSR_occurred; +volatile int TSR_status; + +rtems_id timer_id; rtems_timer_service_routine Cancel_duringISR_TSR( rtems_id ignored_id, void *ignored_address ) { - Cancel_status = pthread_cancel( pthread_self() ); - Cancel_occurred = 1; + TSR_status = pthread_cancel( pthread_self() ); + TSR_occurred = 1; } +rtems_timer_service_routine SetState_duringISR_TSR( + rtems_id ignored_id, + void *ignored_address +) +{ + int oldstate; + + TSR_status = pthread_setcancelstate( 0, &oldstate ); + TSR_occurred = 1; +} -void *POSIX_Init( - void *argument +rtems_timer_service_routine SetType_duringISR_TSR( + rtems_id ignored_id, + void *ignored_address ) { - int status; - rtems_interval start; - rtems_interval end; - rtems_id timer_id; + int oldtype; - puts( "\n\n*** POSIX TEST CANCEL 01 ***" ); + TSR_status = pthread_setcanceltype( 0, &oldtype ); + TSR_occurred = 1; +} - status = rtems_timer_create( - rtems_build_name( 'T', 'M', '1', ' ' ), - &timer_id - ); - assert( !status ); +void doit( + rtems_timer_service_routine (*TSR)(rtems_id, void *), + const char *method +) +{ + rtems_interval start; + rtems_interval end; + rtems_status_code status; - Cancel_occurred = 0; - Cancel_status = 0; + printf( "Init: schedule %s from a TSR\n", method ); - puts( "Init: schedule pthread_cancel from a TSR" ); - status = rtems_timer_fire_after( timer_id, 10, Cancel_duringISR_TSR, NULL ); - assert( !status ); + TSR_occurred = 0; + TSR_status = 0; - /* cancel occurs during sleep */ + status = rtems_timer_fire_after( timer_id, 10, TSR, NULL ); + assert( !status ); do { end = rtems_clock_get_ticks_since_boot(); - } while ( !Cancel_occurred && ((end - start) <= 800)); + } while ( !TSR_occurred && ((end - start) <= 800)); - if ( !Cancel_occurred ) { - puts( "Cancel did not occur" ); + if ( !TSR_occurred ) { + printf( "%s did not occur\n", method ); rtems_test_exit(0); } - if ( Cancel_status != EPROTO ) { - printf( "Cancel returned %s\n", strerror(Cancel_status) ); + if ( TSR_status != EPROTO ) { + printf( "%s returned %s\n", method, strerror(TSR_status) ); rtems_test_exit(0); } - puts( "pthread_cancel - from ISR returns EPROTO - OK" ); + printf( "%s - from ISR returns EPROTO - OK\n", method ); + +} + +void *POSIX_Init( + void *argument +) +{ + rtems_status_code status; + + puts( "\n\n*** POSIX TEST CANCEL 01 ***" ); + + status = rtems_timer_create( + rtems_build_name( 'T', 'M', '1', ' ' ), + &timer_id + ); + assert( !status ); + doit( Cancel_duringISR_TSR, "pthread_cancel" ); + doit( SetState_duringISR_TSR, "pthread_setcancelstate" ); + doit( SetType_duringISR_TSR, "pthread_setcanceltype" ); puts( "*** END OF POSIX TEST CANCEL 01 ***" ); rtems_test_exit(0); diff --git a/testsuites/psxtests/psxcancel01/psxcancel01.scn b/testsuites/psxtests/psxcancel01/psxcancel01.scn index ad1dae753e..80e93440c1 100644 --- a/testsuites/psxtests/psxcancel01/psxcancel01.scn +++ b/testsuites/psxtests/psxcancel01/psxcancel01.scn @@ -1,4 +1,8 @@ *** POSIX TEST CANCEL 01 *** Init: schedule pthread_cancel from a TSR pthread_cancel - from ISR returns EPROTO - OK +Init: schedule pthread_setcancelstate from a TSR +pthread_setcancelstate - from ISR returns EPROTO - OK +Init: schedule pthread_setcanceltype from a TSR +pthread_setcanceltype - from ISR returns EPROTO - OK *** END OF POSIX TEST CANCEL 01 *** |