source: rtems/testsuites/psxtests/psx08/init.c @ 698c2e50

4.115
Last change on this file since 698c2e50 was 698c2e50, checked in by Sebastian Huber <sebastian.huber@…>, on 03/25/14 at 07:06:16

tests/psxtests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16#include <errno.h>
17
18const char rtems_test_name[] = "PSX 8";
19
20void *POSIX_Init(
21  void *argument
22)
23{
24  int    status;
25  void  *return_pointer;
26
27  TEST_BEGIN();
28
29  /* set the time of day, and print our buffer in multiple ways */
30
31  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
32
33  /* get id of this thread */
34
35  Init_id = pthread_self();
36  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
37
38  puts( "Init: pthread_detach - ESRCH (invalid id)" );
39  status = pthread_detach( (pthread_t) -1 );
40  rtems_test_assert( status == ESRCH );
41
42  /* detach this thread */
43
44  puts( "Init: pthread_detach self" );
45  status = pthread_detach( pthread_self() );
46  rtems_test_assert( !status );
47
48  /* create thread */
49
50  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
51  rtems_test_assert( !status );
52
53  puts( "Init: pthread_join - ESRCH (invalid id)" );
54  status = pthread_join( (pthread_t) -1, &return_pointer );
55  rtems_test_assert( status == ESRCH );
56
57  puts( "Init: pthread_join - SUCCESSFUL" );
58  status = pthread_join( Task1_id, &return_pointer );
59
60  puts( "Init: returned from pthread_join through return" );
61  if ( status )
62    printf( "status = %d\n", status );
63  rtems_test_assert( !status );
64
65  if ( return_pointer == &Task1_id )
66    puts( "Init: pthread_join returned correct pointer" );
67  else
68    printf(
69      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
70      return_pointer,
71      &Task1_id
72    );
73
74  puts( "Init: creating two pthreads" );
75  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
76  rtems_test_assert( !status );
77
78  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
79  rtems_test_assert( !status );
80
81  puts( "Init: pthread_join - SUCCESSFUL" );
82  status = pthread_join( Task2_id, &return_pointer );
83  /* assert is below comment */
84
85  puts( "Init: returned from pthread_join through pthread_exit" );
86  if ( status )
87    printf( "status = %d\n", status );
88  rtems_test_assert( !status );
89
90  if ( return_pointer == &Task2_id )
91    puts( "Init: pthread_join returned correct pointer" );
92  else
93    printf(
94      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
95      return_pointer,
96      &Task2_id
97    );
98
99  puts( "Init: exitting" );
100  return NULL;
101}
Note: See TracBrowser for help on using the repository browser.