source: rtems/testsuites/psxtests/psx08/init.c @ 42418a9

4.104.114.84.9
Last change on this file since 42418a9 was 42418a9, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 7, 1996 at 10:00:57 PM

added test cases for ESRCH from pthread_join and pthread_detach

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
3 *  On-Line Applications Research Corporation (OAR).
4 *  All rights assigned to U.S. Government, 1994.
5 *
6 *  This material may be reproduced by or for the U.S. Government pursuant
7 *  to the copyright license under the clause at DFARS 252.227-7013.  This
8 *  notice must appear in all copies of this file and its derivatives.
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  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 );
52  assert( !status );
53 
54  puts( "Init: pthread_join - ESRCH (invalid id)" );
55  status = pthread_join( -1, &return_pointer );
56  assert( status == ESRCH );
57
58  puts( "Init: pthread_join - SUCCESSFUL" );
59  status = pthread_join( Task_id, &return_pointer );
60  /* assert is below comment */
61
62     /* switch to Task 1 */
63
64  puts( "Init: returned from pthread_join" );
65  if ( status )
66    printf( "status = %d\n", status );
67  assert( !status );
68
69  if ( return_pointer == &Task_id )
70    puts( "Init: pthread_join returned correct pointer" );
71  else
72    printf(
73      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
74      return_pointer,
75      &Task_id
76    );
77 
78  puts( "Init: exitting" );
79  pthread_exit( NULL );
80
81  return NULL; /* just so the compiler thinks we returned something */
82}
Note: See TracBrowser for help on using the repository browser.