source: rtems/testsuites/sptests/sp33/init.c @ 4e76c71

4.104.11
Last change on this file since 4e76c71 was 1f7ee02, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 12, 2009 at 8:50:43 PM

2009-08-12 Joel Sherrill <joel.sherrill@…>

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