source: rtems/testsuites/sptests/sp33/init.c @ 2186ba80

4.104.114.9
Last change on this file since 2186ba80 was 2186ba80, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 1, 2008 at 12:45:11 AM

2008-01-31 Joel Sherrill <joel.sherrill@…>

  • sp01/init.c, sp02/init.c, sp03/init.c, sp04/init.c, sp05/init.c, sp06/init.c, sp07/init.c, sp08/init.c, sp09/init.c, sp11/init.c, sp12/init.c, sp13/init.c, sp14/init.c, sp15/init.c, sp16/init.c, sp17/init.c, sp19/init.c, sp20/init.c, sp21/init.c, sp22/init.c, sp23/init.c, sp24/init.c, sp25/init.c, sp26/init.c, sp28/init.c, sp30/init.c, sp31/init.c, sp32/init.c, sp33/init.c, sp37/init.c, sp38/init.c, sp39/init.c, sp40/init.c, sp41/init.c, sp43/init.c, spfatal/init.c, spfatal_support/init.c, spsize/init.c: Change TEST_INIT to CONFIGURE_INIT. Make tmacros.h available to all POSIX tests. Add a clock_settime case for < 1988.
  • Property mode set to 100644
File size: 7.0 KB
Line 
1/* spmonotonic -- sanity check the rate monotonic manager
2 *
3 * license and distribution terms for this file may be found in the file
4 * LICENSE in this distribution or at
5 * http://www.rtems.com/license/LICENSE .
6 *
7 * $Id$
8 */
9
10#define CONFIGURE_INIT
11#include <tmacros.h>  /* includes bsp.h, stdio, etc... */
12
13/* prototype */
14rtems_task Init (rtems_task_argument ignored);
15
16#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
17
18#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
19#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
20#define CONFIGURE_MAXIMUM_TASKS     5
21#define CONFIGURE_MAXIMUM_BARRIERS  1
22
23#define CONFIGURE_INIT
24
25rtems_id    Barrier;
26
27int SuccessfulCase;
28int DeletedCase;
29
30rtems_task Waiter(
31  rtems_task_argument number
32)
33{
34  rtems_status_code status;
35
36  printf( "Waiter %d waiting on barrier\n", number );
37  status = rtems_barrier_wait( Barrier, RTEMS_NO_TIMEOUT );
38
39  printf( "Waiter %d back from barrier\n", number );
40
41  if ( SuccessfulCase == TRUE ) {
42    directive_failed(status, "rtems_barrier_wait");
43  } else if ( DeletedCase == TRUE ) {
44    fatal_directive_status(
45      status,
46      RTEMS_OBJECT_WAS_DELETED,
47      "rtems_barrier_wait did not get deleted"
48    );
49  }
50
51  rtems_task_delete( RTEMS_SELF );
52}
53
54#include <rtems/confdefs.h>
55
56rtems_task Init(
57  rtems_task_argument ignored
58)
59{
60  rtems_status_code status;
61  rtems_name        name = rtems_build_name('B','A','R','1');
62  uint32_t          released;
63  rtems_id          testId;
64  rtems_id          Tasks[CONFIGURE_MAXIMUM_TASKS-1];
65  uint32_t          i;
66
67  puts("\n\n*** TEST 33 ***");
68
69  /* Check bad argument cases */
70  puts( "Delete barrier with bad id" );
71  status = rtems_barrier_delete( 100 );
72  fatal_directive_status(
73    status,
74    RTEMS_INVALID_ID,
75    "rtems_barrier_delete did not return RTEMS_INVALID_ID"
76  );
77
78  puts( "Release barrier with bad id" );
79  status = rtems_barrier_release( 100, &released );
80  fatal_directive_status(
81    status,
82    RTEMS_INVALID_ID,
83    "rtems_barrier_release did not return RTEMS_INVALID_ID"
84  );
85
86  puts( "Wait on barrier with bad id" );
87  status = rtems_barrier_wait( 100, 10 );
88  fatal_directive_status(
89    status,
90    RTEMS_INVALID_ID,
91    "rtems_barrier_wait did not return RTEMS_INVALID_ID"
92  );
93
94  /* Create barrier with automatic release and 0 maximum waiters */
95  puts( "Create barrier with automatic release and 0 max waiters" );
96  status = rtems_barrier_create(
97    name, RTEMS_BARRIER_AUTOMATIC_RELEASE, 0, &Barrier
98  );
99  fatal_directive_status(
100    status,
101    RTEMS_INVALID_NUMBER,
102    "rtems_barrier_create did not return RTEMS_INVALID_NUMBER"
103  );
104
105  /* Create barrier */
106  puts( "Create barrier" );
107  status = rtems_barrier_create( name, RTEMS_DEFAULT_ATTRIBUTES, 0, &Barrier );
108  directive_failed(status, "rtems_barrier_create");
109
110  /* Check for creating too many */
111  puts( "Create too many barriers" );
112  status = rtems_barrier_create( name, RTEMS_DEFAULT_ATTRIBUTES, 0, &Barrier );
113  fatal_directive_status(
114    status,
115    RTEMS_TOO_MANY,
116    "rtems_barrier_create did not return RTEMS_TOO_MANY"
117  );
118
119  puts( "Check barrier ident" );
120  status = rtems_barrier_ident( name, &testId );
121  directive_failed(status, "rtems_barrier_ident");
122  if ( testId != Barrier ) {
123    printf( "ERROR -- rtems_barrier_create -- did not get Id expected\n" );
124    exit( 0 );
125  }
126
127  puts( "Wait on barrier w/timeout and TIMEOUT" );
128  status = rtems_barrier_wait( Barrier, 25 );
129  fatal_directive_status(
130    status,
131    RTEMS_TIMEOUT,
132    "rtems_barrier_wait did not timeout"
133  );
134
135  /* Release no tasks */
136  status = rtems_barrier_release( Barrier, &released );
137  directive_failed(status, "rtems_barrier_release");
138  if ( released != 0 ) {
139    printf( "ERROR -- rtems_barrier_release -- released != 0, = %d", released);
140    exit(0);
141  }
142
143  /*  Create some tasks to wait for the barrier */
144  SuccessfulCase = TRUE;
145  DeletedCase    = FALSE;
146  puts( "\n*** Testing manual release of barrier ***" );
147  for (i=0 ; i<(CONFIGURE_MAXIMUM_TASKS-1) ; i++) {
148    status = rtems_task_create(
149      rtems_build_name('W','A','I','T'),
150      1,
151      RTEMS_MINIMUM_STACK_SIZE,
152      RTEMS_DEFAULT_MODES,
153      RTEMS_DEFAULT_ATTRIBUTES,
154      &Tasks[ i ]
155    );
156    directive_failed( status, "rtems_task_create of Waiter" );
157
158    status = rtems_task_start( Tasks[ i ], Waiter, i );
159    directive_failed( status, "rtems_task_start of Waiter" );
160  }
161
162  puts( "Delay to let Waiters block" ); 
163  status = rtems_task_wake_after( TICKS_PER_SECOND );
164  directive_failed(status, "rtems_task_wake_after");
165
166  /* Release tasks which were waiting */
167  puts( "Releasing tasks" );
168  status = rtems_barrier_release( Barrier, &released );
169  directive_failed(status, "rtems_barrier_release");
170  if ( released != (CONFIGURE_MAXIMUM_TASKS-1) ) {
171    printf( "ERROR -- rtems_barrier_release -- released != %d, = %d",
172         (CONFIGURE_MAXIMUM_TASKS-1), released);
173    exit(0);
174  }
175
176  puts( "Delay to let Waiters print a message" ); 
177  status = rtems_task_wake_after( TICKS_PER_SECOND );
178  directive_failed(status, "rtems_task_wake_after");
179
180  /*  Create some tasks to wait for the barrier */
181  SuccessfulCase = FALSE;
182  DeletedCase    = TRUE;
183  puts( "\n*** Testing Deletion of barrier ***" );
184  for (i=0 ; i<(CONFIGURE_MAXIMUM_TASKS-1) ; i++) {
185    status = rtems_task_create(
186      rtems_build_name('W','A','I','T'),
187      1,
188      RTEMS_MINIMUM_STACK_SIZE,
189      RTEMS_DEFAULT_MODES,
190      RTEMS_DEFAULT_ATTRIBUTES,
191      &Tasks[ i ]
192    );
193    directive_failed( status, "rtems_task_create of Waiter" );
194
195    status = rtems_task_start( Tasks[ i ], Waiter, i );
196    directive_failed( status, "rtems_task_start of Waiter" );
197  }
198
199  puts( "Delay to let Waiters block" ); 
200  status = rtems_task_wake_after( TICKS_PER_SECOND );
201  directive_failed(status, "rtems_task_wake_after");
202
203  puts( "Delete barrier" );
204  status = rtems_barrier_delete( Barrier );
205  directive_failed(status, "rtems_barrier_delete");
206
207  puts( "Delay to let Waiters print a message" ); 
208  status = rtems_task_wake_after( TICKS_PER_SECOND );
209  directive_failed(status, "rtems_task_wake_after");
210
211  /* Create barrier with automatic release */
212  puts( "Create barrier" );
213  status = rtems_barrier_create(
214    name, RTEMS_BARRIER_AUTOMATIC_RELEASE, CONFIGURE_MAXIMUM_TASKS-1, &Barrier
215  );
216  directive_failed(status, "rtems_barrier_create");
217
218  /*  Create some tasks to wait for the barrier */
219  SuccessfulCase = TRUE;
220  DeletedCase    = FALSE;
221  puts( "\n*** Testing automatic release of barrier ***" );
222  for (i=0 ; i<(CONFIGURE_MAXIMUM_TASKS-1) ; i++) {
223    status = rtems_task_create(
224      rtems_build_name('W','A','I','T'),
225      1,
226      RTEMS_MINIMUM_STACK_SIZE,
227      RTEMS_DEFAULT_MODES,
228      RTEMS_DEFAULT_ATTRIBUTES,
229      &Tasks[ i ]
230    );
231    directive_failed( status, "rtems_task_create of Waiter" );
232
233    status = rtems_task_start( Tasks[ i ], Waiter, i );
234    directive_failed( status, "rtems_task_start of Waiter" );
235  }
236
237  puts( "Delay to let task wait on barrier" ); 
238  status = rtems_task_wake_after( TICKS_PER_SECOND );
239  directive_failed(status, "rtems_task_wake_after");
240
241  /* the end */
242  puts("*** END OF TEST 33 ***");
243  rtems_test_exit(0);
244}
Note: See TracBrowser for help on using the repository browser.