source: rtems/testsuites/psxtests/psx08/init.c @ 7d96321

4.104.114.84.9
Last change on this file since 7d96321 was 7d96321, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 4, 1999 at 7:41:34 PM

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

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1998.
3 *  On-Line Applications Research Corporation (OAR).
4 *  Copyright assigned to U.S. Government, 1994.
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.OARcorp.com/rtems/license.html.
9 *
10 *  $Id$
11 */
12
13#define CONFIGURE_INIT
14#include "system.h"
15#include <errno.h>
16
17void *POSIX_Init(
18  void *argument
19)
20{
21  int    status;
22  void  *return_pointer;
23
24  puts( "\n\n*** POSIX TEST 8 ***" );
25
26  /* set the time of day, and print our buffer in multiple ways */
27
28  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
29
30  /* get id of this thread */
31
32  Init_id = pthread_self();
33  printf( "Init's ID is 0x%08x\n", Init_id );
34
35  puts( "Init: pthread_detach - ESRCH (invalid id)" );
36  status = pthread_detach( -1 );
37  assert( status == ESRCH );
38
39  /* detach this thread */
40
41  puts( "Init: pthread_detach self" );
42  status = pthread_detach( pthread_self() );
43  assert( !status );
44
45  /* create thread */
46 
47  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
48  assert( !status );
49 
50  puts( "Init: pthread_join - ESRCH (invalid id)" );
51  status = pthread_join( -1, &return_pointer );
52  assert( status == ESRCH );
53
54  puts( "Init: pthread_join - SUCCESSFUL" );
55  status = pthread_join( Task1_id, &return_pointer );
56
57  puts( "Init: returned from pthread_join through return" );
58  if ( status )
59    printf( "status = %d\n", status );
60  assert( !status );
61
62  if ( return_pointer == &Task1_id )
63    puts( "Init: pthread_join returned correct pointer" );
64  else
65    printf(
66      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
67      return_pointer,
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
94    );
95 
96  puts( "Init: exitting" );
97  return NULL;
98}
Note: See TracBrowser for help on using the repository browser.