summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxcancel01/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/psxtests/psxcancel01/init.c')
-rw-r--r--testsuites/psxtests/psxcancel01/init.c89
1 files changed, 61 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);