Changeset 7d96321 in rtems


Ignore:
Timestamp:
Oct 4, 1999, 7:41:34 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
92b211a
Parents:
811804fe
Message:

Modifications necessary to support testing of exitting a pthread from
Charles-Antione Gauthier <charles.gauthier@…>.

Files:
3 added
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psx08/Makefile.in

    r811804fe r7d96321  
    1919
    2020# C source names, if any, go here -- minus the .c
    21 C_PIECES = init task task2
     21C_PIECES=init task1 task2 task3
    2222C_FILES = $(C_PIECES:%=%.c)
    2323C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
  • c/src/tests/psxtests/psx08/init.c

    r811804fe r7d96321  
    4545  /* create thread */
    4646 
    47   puts( "Init: creating two tasks" );
    48   status = pthread_create( &Task_id, NULL, Task_1, NULL );
    49   assert( !status );
    50  
    51   status = pthread_create( &Task2_id, NULL, Task_2, NULL );
     47  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
    5248  assert( !status );
    5349 
     
    5753
    5854  puts( "Init: pthread_join - SUCCESSFUL" );
    59   status = pthread_join( Task_id, &return_pointer );
    60   /* assert is below comment */
     55  status = pthread_join( Task1_id, &return_pointer );
    6156
    62      /* switch to Task 1 */
    63 
    64   puts( "Init: returned from pthread_join" );
     57  puts( "Init: returned from pthread_join through return" );
    6558  if ( status )
    6659    printf( "status = %d\n", status );
    6760  assert( !status );
    6861
    69   if ( return_pointer == &Task_id )
     62  if ( return_pointer == &Task1_id )
    7063    puts( "Init: pthread_join returned correct pointer" );
    7164  else
     
    7366      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
    7467      return_pointer,
    75       &Task_id
     68      &Task1_id
     69    );
     70 
     71  puts( "Init: creating two pthreads" );
     72  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
     73  assert( !status );
     74 
     75  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
     76  assert( !status );
     77 
     78  puts( "Init: pthread_join - SUCCESSFUL" );
     79  status = pthread_join( Task2_id, &return_pointer );
     80  /* assert is below comment */
     81
     82  puts( "Init: returned from pthread_join through pthread_exit" );
     83  if ( status )
     84    printf( "status = %d\n", status );
     85  assert( !status );
     86
     87  if ( return_pointer == &Task2_id )
     88    puts( "Init: pthread_join returned correct pointer" );
     89  else
     90    printf(
     91      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
     92      return_pointer,
     93      &Task2_id
    7694    );
    7795 
    7896  puts( "Init: exitting" );
    79   pthread_exit( NULL );
    80 
    81   return NULL; /* just so the compiler thinks we returned something */
     97  return NULL;
    8298}
  • c/src/tests/psxtests/psx08/psx08.scn

    r811804fe r7d96321  
    33Init: pthread_detach - ESRCH (invalid id)
    44Init: pthread_detach self
    5 Init: creating two tasks
    65Init: pthread_join - ESRCH (invalid id)
    76Init: pthread_join - SUCCESSFUL
    8 Task_1: sleep 1 second
    9 Task_2: join to Task_1
    10 Task_1: join to detached task (Init) -- EINVAL
    11 Task_1: join to self task (Init) -- EDEADLK
    127Task_1: exitting
    13 Init: returned from pthread_join
     8Init: returned from pthread_join through return
     9Init: pthread_join returned correct pointer
     10Init: creating two pthreads
     11Init: pthread_join - SUCCESSFUL
     12Task_2: sleep 1 second
     13Task_3: join to Task_2
     14Task_2: join to detached task (Init) -- EINVAL
     15Task_2: join to self task (Init) -- EDEADLK
     16Task_2: exitting
     17Init: returned from pthread_join through pthread_exit
    1418Init: pthread_join returned correct pointer
    1519Init: exitting
    16 Task_2: returned from pthread_join
    17 Task_2: pthread_join returned correct pointer
     20Task_3: returned from pthread_join
     21Task_3: pthread_join returned correct pointer
    1822*** END OF POSIX TEST 8 ***
  • c/src/tests/psxtests/psx08/system.h

    r811804fe r7d96321  
    3131);
    3232
     33void *Task_3(
     34  void *argument
     35);
     36
    3337/* configuration information */
    3438
     
    5155
    5256TEST_EXTERN pthread_t        Init_id;
    53 TEST_EXTERN pthread_t        Task_id;
     57TEST_EXTERN pthread_t        Task1_id;
    5458TEST_EXTERN pthread_t        Task2_id;
     59TEST_EXTERN pthread_t        Task3_id;
    5560
    5661/* end of include file */
  • c/src/tests/psxtests/psx08/task2.c

    r811804fe r7d96321  
    2828{
    2929  int   status;
    30   void  *return_pointer;
    3130
    32   puts( "Task_2: join to Task_1" );
    33   status = pthread_join( Task_id, &return_pointer );
    34   puts( "Task_2: returned from pthread_join" );
    35   if ( status )
     31  puts( "Task_2: sleep 1 second" );
     32
     33  sleep( 1 );
     34
     35  /* switch to task 3 */
     36
     37  puts( "Task_2: join to detached task (Init) -- EINVAL" );
     38  status = pthread_join( Init_id, NULL );
     39  if ( status != EINVAL )
    3640    printf( "status = %d\n", status );
    37   assert( !status );
    38  
    39   if ( return_pointer == &Task_id )
    40     puts( "Task_2: pthread_join returned correct pointer" );
    41   else
    42     printf(
    43       "Task_2: pthread_join returned incorrect pointer (%p != %p)\n",
    44       return_pointer,
    45       &Task_id
    46     );
     41  assert( status == EINVAL );
     42 
     43  puts( "Task_2: join to self task (Init) -- EDEADLK" );
     44  status = pthread_join( pthread_self(), NULL );
     45  if ( status != EDEADLK )
     46    printf( "status = %d\n", status );
     47  assert( status == EDEADLK );
    4748
    48   puts( "*** END OF POSIX TEST 8 ***" );
    49   exit( 0 );
     49  puts( "Task_2: exitting" );
     50
     51  pthread_exit( &Task2_id );
     52
     53     /* switch to init task */
    5054
    5155  return NULL; /* just so the compiler thinks we returned something */
  • c/src/tests/psxtests/psx08/task3.c

    r811804fe r7d96321  
    1 /*  Task_1
     1/*  Task_3
    22 *
    33 *  This routine serves as a test task.  It verifies the basic task
     
    2323#include <errno.h>
    2424
    25 void *Task_1(
     25void *Task_3(
    2626  void *argument
    2727)
    2828{
    2929  int   status;
     30  void  *return_pointer;
    3031
    31   puts( "Task_1: sleep 1 second" );
     32  puts( "Task_3: join to Task_2" );
     33  status = pthread_join( Task2_id, &return_pointer );
     34  puts( "Task_3: returned from pthread_join" );
     35  if ( status )
     36    printf( "status = %d\n", status );
     37  assert( !status );
     38 
     39  if ( return_pointer == &Task2_id )
     40    puts( "Task_3: pthread_join returned correct pointer" );
     41  else
     42    printf(
     43      "Task_3: pthread_join returned incorrect pointer (%p != %p)\n",
     44      return_pointer,
     45      &Task2_id
     46    );
    3247
    33   sleep( 1 );
    34 
    35      /* switch to task 2 */
    36 
    37   puts( "Task_1: join to detached task (Init) -- EINVAL" );
    38   status = pthread_join( Init_id, NULL );
    39   if ( status != EINVAL )
    40     printf( "status = %d\n", status );
    41   assert( status == EINVAL );
    42  
    43   puts( "Task_1: join to self task (Init) -- EDEADLK" );
    44   status = pthread_join( pthread_self(), NULL );
    45   if ( status != EDEADLK )
    46     printf( "status = %d\n", status );
    47   assert( status == EDEADLK );
    48 
    49   puts( "Task_1: exitting" );
    50 
    51   pthread_exit( &Task_id );
    52 
    53      /* switch to init task */
     48  puts( "*** END OF POSIX TEST 8 ***" );
     49  exit( 0 );
    5450
    5551  return NULL; /* just so the compiler thinks we returned something */
  • testsuites/psxtests/psx08/init.c

    r811804fe r7d96321  
    4545  /* create thread */
    4646 
    47   puts( "Init: creating two tasks" );
    48   status = pthread_create( &Task_id, NULL, Task_1, NULL );
    49   assert( !status );
    50  
    51   status = pthread_create( &Task2_id, NULL, Task_2, NULL );
     47  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
    5248  assert( !status );
    5349 
     
    5753
    5854  puts( "Init: pthread_join - SUCCESSFUL" );
    59   status = pthread_join( Task_id, &return_pointer );
    60   /* assert is below comment */
     55  status = pthread_join( Task1_id, &return_pointer );
    6156
    62      /* switch to Task 1 */
    63 
    64   puts( "Init: returned from pthread_join" );
     57  puts( "Init: returned from pthread_join through return" );
    6558  if ( status )
    6659    printf( "status = %d\n", status );
    6760  assert( !status );
    6861
    69   if ( return_pointer == &Task_id )
     62  if ( return_pointer == &Task1_id )
    7063    puts( "Init: pthread_join returned correct pointer" );
    7164  else
     
    7366      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
    7467      return_pointer,
    75       &Task_id
     68      &Task1_id
     69    );
     70 
     71  puts( "Init: creating two pthreads" );
     72  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
     73  assert( !status );
     74 
     75  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
     76  assert( !status );
     77 
     78  puts( "Init: pthread_join - SUCCESSFUL" );
     79  status = pthread_join( Task2_id, &return_pointer );
     80  /* assert is below comment */
     81
     82  puts( "Init: returned from pthread_join through pthread_exit" );
     83  if ( status )
     84    printf( "status = %d\n", status );
     85  assert( !status );
     86
     87  if ( return_pointer == &Task2_id )
     88    puts( "Init: pthread_join returned correct pointer" );
     89  else
     90    printf(
     91      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
     92      return_pointer,
     93      &Task2_id
    7694    );
    7795 
    7896  puts( "Init: exitting" );
    79   pthread_exit( NULL );
    80 
    81   return NULL; /* just so the compiler thinks we returned something */
     97  return NULL;
    8298}
  • testsuites/psxtests/psx08/psx08.scn

    r811804fe r7d96321  
    33Init: pthread_detach - ESRCH (invalid id)
    44Init: pthread_detach self
    5 Init: creating two tasks
    65Init: pthread_join - ESRCH (invalid id)
    76Init: pthread_join - SUCCESSFUL
    8 Task_1: sleep 1 second
    9 Task_2: join to Task_1
    10 Task_1: join to detached task (Init) -- EINVAL
    11 Task_1: join to self task (Init) -- EDEADLK
    127Task_1: exitting
    13 Init: returned from pthread_join
     8Init: returned from pthread_join through return
     9Init: pthread_join returned correct pointer
     10Init: creating two pthreads
     11Init: pthread_join - SUCCESSFUL
     12Task_2: sleep 1 second
     13Task_3: join to Task_2
     14Task_2: join to detached task (Init) -- EINVAL
     15Task_2: join to self task (Init) -- EDEADLK
     16Task_2: exitting
     17Init: returned from pthread_join through pthread_exit
    1418Init: pthread_join returned correct pointer
    1519Init: exitting
    16 Task_2: returned from pthread_join
    17 Task_2: pthread_join returned correct pointer
     20Task_3: returned from pthread_join
     21Task_3: pthread_join returned correct pointer
    1822*** END OF POSIX TEST 8 ***
  • testsuites/psxtests/psx08/system.h

    r811804fe r7d96321  
    3131);
    3232
     33void *Task_3(
     34  void *argument
     35);
     36
    3337/* configuration information */
    3438
     
    5155
    5256TEST_EXTERN pthread_t        Init_id;
    53 TEST_EXTERN pthread_t        Task_id;
     57TEST_EXTERN pthread_t        Task1_id;
    5458TEST_EXTERN pthread_t        Task2_id;
     59TEST_EXTERN pthread_t        Task3_id;
    5560
    5661/* end of include file */
  • testsuites/psxtests/psx08/task2.c

    r811804fe r7d96321  
    2828{
    2929  int   status;
    30   void  *return_pointer;
    3130
    32   puts( "Task_2: join to Task_1" );
    33   status = pthread_join( Task_id, &return_pointer );
    34   puts( "Task_2: returned from pthread_join" );
    35   if ( status )
     31  puts( "Task_2: sleep 1 second" );
     32
     33  sleep( 1 );
     34
     35  /* switch to task 3 */
     36
     37  puts( "Task_2: join to detached task (Init) -- EINVAL" );
     38  status = pthread_join( Init_id, NULL );
     39  if ( status != EINVAL )
    3640    printf( "status = %d\n", status );
    37   assert( !status );
    38  
    39   if ( return_pointer == &Task_id )
    40     puts( "Task_2: pthread_join returned correct pointer" );
    41   else
    42     printf(
    43       "Task_2: pthread_join returned incorrect pointer (%p != %p)\n",
    44       return_pointer,
    45       &Task_id
    46     );
     41  assert( status == EINVAL );
     42 
     43  puts( "Task_2: join to self task (Init) -- EDEADLK" );
     44  status = pthread_join( pthread_self(), NULL );
     45  if ( status != EDEADLK )
     46    printf( "status = %d\n", status );
     47  assert( status == EDEADLK );
    4748
    48   puts( "*** END OF POSIX TEST 8 ***" );
    49   exit( 0 );
     49  puts( "Task_2: exitting" );
     50
     51  pthread_exit( &Task2_id );
     52
     53     /* switch to init task */
    5054
    5155  return NULL; /* just so the compiler thinks we returned something */
Note: See TracChangeset for help on using the changeset viewer.