source: rtems/testsuites/psxtests/psx10/init.c @ aad3fe6

4.104.114.84.95
Last change on this file since aad3fe6 was aad3fe6, checked in by Mark Johannes <Mark.Johannes@…>, on 08/12/96 at 21:49:54

Init.c: added cases for signal, wait and broadcast

  • Property mode set to 100644
File size: 3.6 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 <sched.h>
16
17
18void *POSIX_Init(
19  void *argument
20)
21{
22  int                 status;
23  pthread_t           thread_id;
24  pthread_condattr_t  attr;
25  int                 pshared;
26  pthread_cond_t      cond = PTHREAD_COND_INITIALIZER;
27
28  puts( "\n\n*** POSIX TEST 10 ***" );
29
30  puts( "Init: pthread_condattr_init" );
31  status = pthread_condattr_init( &attr );
32  assert( !status );
33
34  puts( "Init: pthread_condattr_init - EINVAL" );
35  status = pthread_condattr_init( NULL );
36  if ( status != EINVAL )
37    printf( "status = %d\n", status );
38  assert( status == EINVAL );
39
40  puts( "Init: pthread_condattr_destroy" );
41  status = pthread_condattr_destroy( &attr );
42  assert( !status );
43
44  puts( "Init: pthread_condattr_destroy - EINVAL" );
45  status = pthread_condattr_destroy( NULL );
46  if ( status != EINVAL )
47    printf( "status = %d\n", status );
48  assert( status == EINVAL );
49
50  puts( "Init: pthread_condattr_init" );
51  status = pthread_condattr_init( &attr );
52  assert( !status );
53
54  puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED" );
55  status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
56  assert( !status );
57
58  puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_PRIVATE" );
59  status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
60  assert( !status );
61
62  status = pthread_condattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
63  if ( status != EINVAL )
64    printf( "status = %d\n", status );
65  assert( status == EINVAL );
66  puts( "Init: pthread_condattr_setpshared - EINVAL - attr" );
67
68  status = pthread_condattr_setpshared( &attr, 0xFFFFFF );
69  if ( status != EINVAL )
70    printf( "status = %d\n", status );
71  assert( status == EINVAL );
72  puts( "Init: pthread_condattr_setpshared - EINVAL - pshared" );
73
74  status = pthread_condattr_getpshared( &attr, &pshared );
75  assert( !status );
76  printf( "Init: pthread_condattr_getpshared - %d\n", pshared );
77
78  status = pthread_condattr_getpshared( NULL, &pshared );
79  if ( status != EINVAL )
80    printf( "status = %d\n", status );
81  assert( status == EINVAL );
82  puts( "Init: pthread_condattr_getpshared - EINVAL" );
83
84  puts( "Init: pthread_cond_init - NULL attr" );
85  status = pthread_cond_init( &cond, NULL );
86  assert( !status );
87
88  puts( "Init: pthread_cond_destroy" );
89  status = pthread_cond_destroy( &cond );
90  assert( !status );
91
92  puts( "Init: pthread_cond_init - attr" );
93  status = pthread_cond_init( &Cond1_id, &attr );
94  assert( !status );
95
96  /* create a thread */
97
98  empty_line();
99
100  status = pthread_create( &Task_id, NULL, Task_1, NULL );
101  assert( !status );
102
103  puts( "Init: sleep to switch to Task_1" );
104  sleep( 1 );
105
106  puts( "Init: pthread_cond_signal" );
107  status = pthread_cond_signal( &Cond1_id );
108  assert( !status );
109
110  empty_line();
111
112  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
113  assert( !status );
114
115  puts( "Init: sleep - switch to Task_1 and Task_2" );
116  sleep( 1 );
117
118  puts( "Init: pthread_cond_broadcast" );
119  status = pthread_cond_broadcast( &Cond1_id );
120  assert( !status );
121
122  puts( "Init: sleep - switch to Task_1" );
123  sleep( 1 );
124
125  /* exit this thread */
126
127  puts( "*** END OF POSIX TEST 5 ***" );
128  exit( 0 );
129
130  return NULL; /* just so the compiler thinks we returned something */
131}
Note: See TracBrowser for help on using the repository browser.