From 15974b65ea61303110208353e15375a5d78d9121 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 4 Jun 1996 14:32:21 +0000 Subject: added basic test cases for pthread_self and pthread_equal --- testsuites/psxtests/psx01/init.c | 5 +++++ testsuites/psxtests/psx01/system.h | 9 +++++++++ testsuites/psxtests/psx01/task.c | 28 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 14 deletions(-) (limited to 'testsuites/psxtests/psx01') diff --git a/testsuites/psxtests/psx01/init.c b/testsuites/psxtests/psx01/init.c index 98fb6d41ac..5a3d387802 100644 --- a/testsuites/psxtests/psx01/init.c +++ b/testsuites/psxtests/psx01/init.c @@ -113,6 +113,11 @@ void *POSIX_Init( printf( "sec (%d), nsec (%d) remaining\n", (int)tr.tv_sec, (int)tr.tv_nsec ); assert( !tr.tv_sec && !tr.tv_nsec ); + /* get id of this thread */ + + Init_id = pthread_self(); + printf( "Init's ID is 0x%08x\n", Init_id ); + /* create a thread */ status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL ); diff --git a/testsuites/psxtests/psx01/system.h b/testsuites/psxtests/psx01/system.h index 409bff4450..3b776a082d 100644 --- a/testsuites/psxtests/psx01/system.h +++ b/testsuites/psxtests/psx01/system.h @@ -43,4 +43,13 @@ void *Task_1_through_3( /* global variables */ +#ifdef CONFIGURE_INIT +#define TEST_EXTERN +#else +#define TEST_EXTERN extern +#endif + +TEST_EXTERN pthread_t Init_id; +TEST_EXTERN pthread_t Task_id; + /* end of include file */ diff --git a/testsuites/psxtests/psx01/task.c b/testsuites/psxtests/psx01/task.c index 02678aa31c..f26c660f70 100644 --- a/testsuites/psxtests/psx01/task.c +++ b/testsuites/psxtests/psx01/task.c @@ -26,25 +26,25 @@ void *Task_1_through_3( ) { int seconds; + int status; /* XXX temporary */ - puts( "*** END OF POSIX TEST 1 ***" ); - exit( 0 ); - - for ( ; ; ) { - /* grab the tod */ + /* get id of this thread */ - /* if we have run longer 35 seconds exit */ + Task_id = pthread_self(); + printf( "Task's ID is 0x%08x\n", Task_id ); - if ( seconds >= 35 ) { - puts( "*** END OF POSIX TEST 1 ***" ); - exit( 0 ); - } + status = pthread_equal( Task_id, Task_id ); + if ( status ) + puts( "pthread_equal match case passed" ); + assert( status ); - /* put our task number and the current time */ + status = pthread_equal( Init_id, Task_id ); + if ( !status ) + puts( "pthread_equal different case passed" ); + assert( !status ); - /* delay based on our thread number */ - - } + puts( "*** END OF POSIX TEST 1 ***" ); + exit( 0 ); } -- cgit v1.2.3