mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
added basic test cases for pthread_self and pthread_equal
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -26,25 +26,25 @@ void *Task_1_through_3(
|
||||
)
|
||||
{
|
||||
int seconds;
|
||||
int status;
|
||||
|
||||
/* XXX temporary */
|
||||
|
||||
/* get id of this thread */
|
||||
|
||||
Task_id = pthread_self();
|
||||
printf( "Task's ID is 0x%08x\n", Task_id );
|
||||
|
||||
status = pthread_equal( Task_id, Task_id );
|
||||
if ( status )
|
||||
puts( "pthread_equal match case passed" );
|
||||
assert( status );
|
||||
|
||||
status = pthread_equal( Init_id, Task_id );
|
||||
if ( !status )
|
||||
puts( "pthread_equal different case passed" );
|
||||
assert( !status );
|
||||
|
||||
puts( "*** END OF POSIX TEST 1 ***" );
|
||||
exit( 0 );
|
||||
|
||||
for ( ; ; ) {
|
||||
/* grab the tod */
|
||||
|
||||
/* if we have run longer 35 seconds exit */
|
||||
|
||||
if ( seconds >= 35 ) {
|
||||
puts( "*** END OF POSIX TEST 1 ***" );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
/* put our task number and the current time */
|
||||
|
||||
/* delay based on our thread number */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -26,25 +26,25 @@ void *Task_1_through_3(
|
||||
)
|
||||
{
|
||||
int seconds;
|
||||
int status;
|
||||
|
||||
/* XXX temporary */
|
||||
|
||||
/* get id of this thread */
|
||||
|
||||
Task_id = pthread_self();
|
||||
printf( "Task's ID is 0x%08x\n", Task_id );
|
||||
|
||||
status = pthread_equal( Task_id, Task_id );
|
||||
if ( status )
|
||||
puts( "pthread_equal match case passed" );
|
||||
assert( status );
|
||||
|
||||
status = pthread_equal( Init_id, Task_id );
|
||||
if ( !status )
|
||||
puts( "pthread_equal different case passed" );
|
||||
assert( !status );
|
||||
|
||||
puts( "*** END OF POSIX TEST 1 ***" );
|
||||
exit( 0 );
|
||||
|
||||
for ( ; ; ) {
|
||||
/* grab the tod */
|
||||
|
||||
/* if we have run longer 35 seconds exit */
|
||||
|
||||
if ( seconds >= 35 ) {
|
||||
puts( "*** END OF POSIX TEST 1 ***" );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
/* put our task number and the current time */
|
||||
|
||||
/* delay based on our thread number */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user