mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 22:48:23 +00:00
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.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
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.
|
||||
|
||||
2009-09-28 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* Makefile.am, configure.ac: Add new test for calling pthread_cancel()
|
||||
|
||||
@@ -91,6 +91,10 @@ void *countTaskAsync(void *ignored)
|
||||
sc = pthread_setcanceltype(12, &old);
|
||||
fatal_posix_service_status( sc, EINVAL, "cancel type EINVAL" );
|
||||
|
||||
puts( "Init - pthread_cancel - bad ID - EINVAL" );
|
||||
sc = pthread_cancel(0x100);
|
||||
fatal_posix_service_status( sc, EINVAL, "cancel bad Id" );
|
||||
|
||||
/* Start countTask deferred */
|
||||
{
|
||||
sc = pthread_create(&task, NULL, countTaskDeferred, &taskparameter);
|
||||
|
||||
@@ -3,6 +3,7 @@ Init - pthread_setcancelstate - NULL oldstate - EINVAL
|
||||
Init - pthread_setcancelstate - bad state - EINVAL
|
||||
Init - pthread_setcanceltype - NULL oldtype - EINVAL
|
||||
Init - pthread_setcanceltype - bad type - EINVAL
|
||||
Init - pthread_cancel - bad ID - EINVAL
|
||||
countTaskDeferred: elapsed time (second): 0
|
||||
countTaskDeferred: elapsed time (second): 1
|
||||
countTaskDeferred: elapsed time (second): 2
|
||||
|
||||
@@ -12,27 +12,80 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
rtems_timer_service_routine SetType_duringISR_TSR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
)
|
||||
{
|
||||
int oldtype;
|
||||
|
||||
TSR_status = pthread_setcanceltype( 0, &oldtype );
|
||||
TSR_occurred = 1;
|
||||
}
|
||||
|
||||
void doit(
|
||||
rtems_timer_service_routine (*TSR)(rtems_id, void *),
|
||||
const char *method
|
||||
)
|
||||
{
|
||||
rtems_interval start;
|
||||
rtems_interval end;
|
||||
rtems_status_code status;
|
||||
|
||||
printf( "Init: schedule %s from a TSR\n", method );
|
||||
|
||||
TSR_occurred = 0;
|
||||
TSR_status = 0;
|
||||
|
||||
status = rtems_timer_fire_after( timer_id, 10, TSR, NULL );
|
||||
assert( !status );
|
||||
|
||||
do {
|
||||
end = rtems_clock_get_ticks_since_boot();
|
||||
} while ( !TSR_occurred && ((end - start) <= 800));
|
||||
|
||||
if ( !TSR_occurred ) {
|
||||
printf( "%s did not occur\n", method );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
if ( TSR_status != EPROTO ) {
|
||||
printf( "%s returned %s\n", method, strerror(TSR_status) );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
printf( "%s - from ISR returns EPROTO - OK\n", method );
|
||||
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
int status;
|
||||
rtems_interval start;
|
||||
rtems_interval end;
|
||||
rtems_id timer_id;
|
||||
rtems_status_code status;
|
||||
|
||||
puts( "\n\n*** POSIX TEST CANCEL 01 ***" );
|
||||
|
||||
@@ -42,29 +95,9 @@ void *POSIX_Init(
|
||||
);
|
||||
assert( !status );
|
||||
|
||||
Cancel_occurred = 0;
|
||||
Cancel_status = 0;
|
||||
|
||||
puts( "Init: schedule pthread_cancel from a TSR" );
|
||||
status = rtems_timer_fire_after( timer_id, 10, Cancel_duringISR_TSR, NULL );
|
||||
assert( !status );
|
||||
|
||||
/* cancel occurs during sleep */
|
||||
|
||||
do {
|
||||
end = rtems_clock_get_ticks_since_boot();
|
||||
} while ( !Cancel_occurred && ((end - start) <= 800));
|
||||
|
||||
if ( !Cancel_occurred ) {
|
||||
puts( "Cancel did not occur" );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
if ( Cancel_status != EPROTO ) {
|
||||
printf( "Cancel returned %s\n", strerror(Cancel_status) );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
puts( "pthread_cancel - from ISR returns EPROTO - OK" );
|
||||
|
||||
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);
|
||||
|
||||
@@ -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 ***
|
||||
|
||||
Reference in New Issue
Block a user