Modifications necessary to support testing of exitting a pthread from

Charles-Antione Gauthier <charles.gauthier@iit.nrc.ca>.
This commit is contained in:
Joel Sherrill
1999-10-04 19:41:34 +00:00
parent 811804fec8
commit 7d96321834
13 changed files with 280 additions and 106 deletions

View File

@@ -18,7 +18,7 @@ TEST = psx08
MANAGERS = all
# C source names, if any, go here -- minus the .c
C_PIECES = init task task2
C_PIECES=init task1 task2 task3
C_FILES = $(C_PIECES:%=%.c)
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)

View File

@@ -44,11 +44,7 @@ void *POSIX_Init(
/* create thread */
puts( "Init: creating two tasks" );
status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status );
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
status = pthread_create( &Task1_id, NULL, Task_1, NULL );
assert( !status );
puts( "Init: pthread_join - ESRCH (invalid id)" );
@@ -56,27 +52,47 @@ void *POSIX_Init(
assert( status == ESRCH );
puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task_id, &return_pointer );
/* assert is below comment */
status = pthread_join( Task1_id, &return_pointer );
/* switch to Task 1 */
puts( "Init: returned from pthread_join" );
puts( "Init: returned from pthread_join through return" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task_id )
if ( return_pointer == &Task1_id )
puts( "Init: pthread_join returned correct pointer" );
else
printf(
"Init: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task_id
&Task1_id
);
puts( "Init: creating two pthreads" );
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status );
status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status );
puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task2_id, &return_pointer );
/* assert is below comment */
puts( "Init: returned from pthread_join through pthread_exit" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task2_id )
puts( "Init: pthread_join returned correct pointer" );
else
printf(
"Init: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task2_id
);
puts( "Init: exitting" );
pthread_exit( NULL );
return NULL; /* just so the compiler thinks we returned something */
return NULL;
}

View File

@@ -2,17 +2,21 @@
Init's ID is 0x0c010001
Init: pthread_detach - ESRCH (invalid id)
Init: pthread_detach self
Init: creating two tasks
Init: pthread_join - ESRCH (invalid id)
Init: pthread_join - SUCCESSFUL
Task_1: sleep 1 second
Task_2: join to Task_1
Task_1: join to detached task (Init) -- EINVAL
Task_1: join to self task (Init) -- EDEADLK
Task_1: exitting
Init: returned from pthread_join
Init: returned from pthread_join through return
Init: pthread_join returned correct pointer
Init: creating two pthreads
Init: pthread_join - SUCCESSFUL
Task_2: sleep 1 second
Task_3: join to Task_2
Task_2: join to detached task (Init) -- EINVAL
Task_2: join to self task (Init) -- EDEADLK
Task_2: exitting
Init: returned from pthread_join through pthread_exit
Init: pthread_join returned correct pointer
Init: exitting
Task_2: returned from pthread_join
Task_2: pthread_join returned correct pointer
Task_3: returned from pthread_join
Task_3: pthread_join returned correct pointer
*** END OF POSIX TEST 8 ***

View File

@@ -30,6 +30,10 @@ void *Task_2(
void *argument
);
void *Task_3(
void *argument
);
/* configuration information */
#define CONFIGURE_SPTEST
@@ -50,7 +54,8 @@ void *Task_2(
#endif
TEST_EXTERN pthread_t Init_id;
TEST_EXTERN pthread_t Task_id;
TEST_EXTERN pthread_t Task1_id;
TEST_EXTERN pthread_t Task2_id;
TEST_EXTERN pthread_t Task3_id;
/* end of include file */

View File

@@ -0,0 +1,34 @@
/* Task_1
*
* This routine serves as a test task. It verifies the basic task
* switching capabilities of the executive.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include "system.h"
#include <errno.h>
void *Task_1(
void *argument
)
{
int status;
puts( "Task_1: exitting" );
return( &Task1_id );
}

View File

@@ -27,26 +27,30 @@ void *Task_2(
)
{
int status;
void *return_pointer;
puts( "Task_2: join to Task_1" );
status = pthread_join( Task_id, &return_pointer );
puts( "Task_2: returned from pthread_join" );
if ( status )
puts( "Task_2: sleep 1 second" );
sleep( 1 );
/* switch to task 3 */
puts( "Task_2: join to detached task (Init) -- EINVAL" );
status = pthread_join( Init_id, NULL );
if ( status != EINVAL )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task_id )
puts( "Task_2: pthread_join returned correct pointer" );
else
printf(
"Task_2: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task_id
);
assert( status == EINVAL );
puts( "Task_2: join to self task (Init) -- EDEADLK" );
status = pthread_join( pthread_self(), NULL );
if ( status != EDEADLK )
printf( "status = %d\n", status );
assert( status == EDEADLK );
puts( "*** END OF POSIX TEST 8 ***" );
exit( 0 );
puts( "Task_2: exitting" );
pthread_exit( &Task2_id );
/* switch to init task */
return NULL; /* just so the compiler thinks we returned something */
}

View File

@@ -1,4 +1,4 @@
/* Task_1
/* Task_3
*
* This routine serves as a test task. It verifies the basic task
* switching capabilities of the executive.
@@ -22,35 +22,31 @@
#include "system.h"
#include <errno.h>
void *Task_1(
void *Task_3(
void *argument
)
{
int status;
void *return_pointer;
puts( "Task_1: sleep 1 second" );
sleep( 1 );
/* switch to task 2 */
puts( "Task_1: join to detached task (Init) -- EINVAL" );
status = pthread_join( Init_id, NULL );
if ( status != EINVAL )
puts( "Task_3: join to Task_2" );
status = pthread_join( Task2_id, &return_pointer );
puts( "Task_3: returned from pthread_join" );
if ( status )
printf( "status = %d\n", status );
assert( status == EINVAL );
puts( "Task_1: join to self task (Init) -- EDEADLK" );
status = pthread_join( pthread_self(), NULL );
if ( status != EDEADLK )
printf( "status = %d\n", status );
assert( status == EDEADLK );
assert( !status );
if ( return_pointer == &Task2_id )
puts( "Task_3: pthread_join returned correct pointer" );
else
printf(
"Task_3: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task2_id
);
puts( "Task_1: exitting" );
pthread_exit( &Task_id );
/* switch to init task */
puts( "*** END OF POSIX TEST 8 ***" );
exit( 0 );
return NULL; /* just so the compiler thinks we returned something */
}

View File

@@ -44,11 +44,7 @@ void *POSIX_Init(
/* create thread */
puts( "Init: creating two tasks" );
status = pthread_create( &Task_id, NULL, Task_1, NULL );
assert( !status );
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
status = pthread_create( &Task1_id, NULL, Task_1, NULL );
assert( !status );
puts( "Init: pthread_join - ESRCH (invalid id)" );
@@ -56,27 +52,47 @@ void *POSIX_Init(
assert( status == ESRCH );
puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task_id, &return_pointer );
/* assert is below comment */
status = pthread_join( Task1_id, &return_pointer );
/* switch to Task 1 */
puts( "Init: returned from pthread_join" );
puts( "Init: returned from pthread_join through return" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task_id )
if ( return_pointer == &Task1_id )
puts( "Init: pthread_join returned correct pointer" );
else
printf(
"Init: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task_id
&Task1_id
);
puts( "Init: creating two pthreads" );
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
assert( !status );
status = pthread_create( &Task3_id, NULL, Task_3, NULL );
assert( !status );
puts( "Init: pthread_join - SUCCESSFUL" );
status = pthread_join( Task2_id, &return_pointer );
/* assert is below comment */
puts( "Init: returned from pthread_join through pthread_exit" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task2_id )
puts( "Init: pthread_join returned correct pointer" );
else
printf(
"Init: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task2_id
);
puts( "Init: exitting" );
pthread_exit( NULL );
return NULL; /* just so the compiler thinks we returned something */
return NULL;
}

View File

@@ -2,17 +2,21 @@
Init's ID is 0x0c010001
Init: pthread_detach - ESRCH (invalid id)
Init: pthread_detach self
Init: creating two tasks
Init: pthread_join - ESRCH (invalid id)
Init: pthread_join - SUCCESSFUL
Task_1: sleep 1 second
Task_2: join to Task_1
Task_1: join to detached task (Init) -- EINVAL
Task_1: join to self task (Init) -- EDEADLK
Task_1: exitting
Init: returned from pthread_join
Init: returned from pthread_join through return
Init: pthread_join returned correct pointer
Init: creating two pthreads
Init: pthread_join - SUCCESSFUL
Task_2: sleep 1 second
Task_3: join to Task_2
Task_2: join to detached task (Init) -- EINVAL
Task_2: join to self task (Init) -- EDEADLK
Task_2: exitting
Init: returned from pthread_join through pthread_exit
Init: pthread_join returned correct pointer
Init: exitting
Task_2: returned from pthread_join
Task_2: pthread_join returned correct pointer
Task_3: returned from pthread_join
Task_3: pthread_join returned correct pointer
*** END OF POSIX TEST 8 ***

View File

@@ -30,6 +30,10 @@ void *Task_2(
void *argument
);
void *Task_3(
void *argument
);
/* configuration information */
#define CONFIGURE_SPTEST
@@ -50,7 +54,8 @@ void *Task_2(
#endif
TEST_EXTERN pthread_t Init_id;
TEST_EXTERN pthread_t Task_id;
TEST_EXTERN pthread_t Task1_id;
TEST_EXTERN pthread_t Task2_id;
TEST_EXTERN pthread_t Task3_id;
/* end of include file */

View File

@@ -0,0 +1,34 @@
/* Task_1
*
* This routine serves as a test task. It verifies the basic task
* switching capabilities of the executive.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include "system.h"
#include <errno.h>
void *Task_1(
void *argument
)
{
int status;
puts( "Task_1: exitting" );
return( &Task1_id );
}

View File

@@ -27,26 +27,30 @@ void *Task_2(
)
{
int status;
void *return_pointer;
puts( "Task_2: join to Task_1" );
status = pthread_join( Task_id, &return_pointer );
puts( "Task_2: returned from pthread_join" );
if ( status )
puts( "Task_2: sleep 1 second" );
sleep( 1 );
/* switch to task 3 */
puts( "Task_2: join to detached task (Init) -- EINVAL" );
status = pthread_join( Init_id, NULL );
if ( status != EINVAL )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task_id )
puts( "Task_2: pthread_join returned correct pointer" );
else
printf(
"Task_2: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task_id
);
assert( status == EINVAL );
puts( "Task_2: join to self task (Init) -- EDEADLK" );
status = pthread_join( pthread_self(), NULL );
if ( status != EDEADLK )
printf( "status = %d\n", status );
assert( status == EDEADLK );
puts( "*** END OF POSIX TEST 8 ***" );
exit( 0 );
puts( "Task_2: exitting" );
pthread_exit( &Task2_id );
/* switch to init task */
return NULL; /* just so the compiler thinks we returned something */
}

View File

@@ -0,0 +1,52 @@
/* Task_3
*
* This routine serves as a test task. It verifies the basic task
* switching capabilities of the executive.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include "system.h"
#include <errno.h>
void *Task_3(
void *argument
)
{
int status;
void *return_pointer;
puts( "Task_3: join to Task_2" );
status = pthread_join( Task2_id, &return_pointer );
puts( "Task_3: returned from pthread_join" );
if ( status )
printf( "status = %d\n", status );
assert( !status );
if ( return_pointer == &Task2_id )
puts( "Task_3: pthread_join returned correct pointer" );
else
printf(
"Task_3: pthread_join returned incorrect pointer (%p != %p)\n",
return_pointer,
&Task2_id
);
puts( "*** END OF POSIX TEST 8 ***" );
exit( 0 );
return NULL; /* just so the compiler thinks we returned something */
}