source: rtems/testsuites/sptests/sp09/screen12.c @ fa8ad9c

4.104.11
Last change on this file since fa8ad9c was fa8ad9c, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 5, 2009 at 7:45:49 PM

2009-01-05 Joel Sherrill <joel.sherrill@…>

  • sp09/screen05.c, sp09/screen07.c, sp09/screen10.c, sp09/screen11.c, sp09/screen12.c, sp09/screen14.c: Use rtems_build_id rather than hard-coded hex numbers for bad object Ids.
  • Property mode set to 100644
File size: 12.5 KB
Line 
1/*  Screen12
2 *
3 *  This routine generates error screen 12 for test 9.
4 *
5 *  Input parameters:  NONE
6 *
7 *  Output parameters:  NONE
8 *
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include "system.h"
20
21void Screen12()
22{
23  void                   *segment_address_1;
24  void                   *segment_address_2;
25  void                   *segment_address_3;
26  uint32_t                good_back_flag;
27  uint32_t                good_front_flag;
28  uint32_t                offset;
29  ssize_t                 segment_size;
30  rtems_status_code       status;
31  Heap_Information_block  the_info;
32
33  /* Check invalid name error case */
34  status = rtems_region_create(
35    0,
36    Region_good_area,
37    0x40,
38    32,
39    RTEMS_DEFAULT_ATTRIBUTES,
40    &Junk_id
41  );
42  fatal_directive_status(
43    status,
44    RTEMS_INVALID_NAME,
45    "rtems_region_create with illegal name"
46  );
47  puts( "TA1 - rtems_region_create - RTEMS_INVALID_NAME" );
48
49  /* Check NULL starting address error case */
50  status = rtems_region_create(
51    Region_name[ 1 ],
52    NULL,
53    0x40,
54    32,
55    RTEMS_DEFAULT_ATTRIBUTES,
56    &Junk_id
57  );
58  fatal_directive_status(
59    status,
60    RTEMS_INVALID_ADDRESS,
61    "rtems_region_create with NULL address"
62  );
63  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
64
65#if defined(_C3x) || defined(_C4x)
66  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS - SKIPPED" );
67#else
68  status = rtems_region_create(
69    Region_name[ 1 ],
70    Region_bad_area,
71    0x40,
72    32,
73    RTEMS_DEFAULT_ATTRIBUTES,
74    &Junk_id
75  );
76  fatal_directive_status(
77    status,
78    RTEMS_INVALID_ADDRESS,
79    "rtems_region_create with illegal address"
80  );
81  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
82#endif
83
84#if defined(_C3x) || defined(_C4x)
85  puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE - SKIPPED" );
86#else
87  status = rtems_region_create(
88    Region_name[ 1 ],
89    Region_good_area,
90    34,
91    34,
92    RTEMS_DEFAULT_ATTRIBUTES,
93    &Junk_id
94  );
95  fatal_directive_status(
96    status,
97    RTEMS_INVALID_SIZE,
98    "rtems_region_create with illegal size"
99  );
100  puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE" );
101#endif
102
103  /* Check NULL id error case */
104  status = rtems_region_create(
105    Region_name[ 1 ],
106    Region_good_area,
107    REGION_LENGTH,
108    0x40,
109    RTEMS_DEFAULT_ATTRIBUTES,
110    NULL
111  );
112  fatal_directive_status(
113    status,
114    RTEMS_INVALID_ADDRESS,
115    "rtems_region_create with NULL id"
116  );
117  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
118
119  status = rtems_region_create(
120    Region_name[ 1 ],
121    &Region_good_area[ REGION_START_OFFSET ],
122    REGION_LENGTH,
123    0x40,
124    RTEMS_DEFAULT_ATTRIBUTES,
125    &Region_id[ 1 ]
126  );
127  directive_failed( status, "rtems_region_create" );
128  puts( "TA1 - rtems_region_create - RTEMS_SUCCESSFUL" );
129
130  status = rtems_region_extend(
131    Region_id[ 1 ],
132    &Region_good_area[ REGION_START_OFFSET ],
133    REGION_LENGTH - 1
134  );
135  fatal_directive_status(
136    status,
137    RTEMS_INVALID_ADDRESS,
138    "rtems_region_extend with address in heap"
139  );
140  puts( "TA1 - rtems_region_extend - address within - RTEMS_INVALID_ADDRESS" );
141
142  status = rtems_region_create(
143    Region_name[ 1 ],
144    Region_good_area,
145    REGION_LENGTH,
146    0x40,
147    RTEMS_DEFAULT_ATTRIBUTES,
148    &Junk_id
149  );
150  fatal_directive_status(
151    status,
152    RTEMS_TOO_MANY,
153    "rtems_region_create of too many"
154  );
155  puts( "TA1 - rtems_region_create - RTEMS_TOO_MANY" );
156
157  status = rtems_region_delete( 100 );
158  fatal_directive_status(
159    status,
160    RTEMS_INVALID_ID,
161    "rtems_region_delete with illegal id"
162  );
163  puts( "TA1 - rtems_region_delete - unknown RTEMS_INVALID_ID" );
164
165  status = rtems_region_delete( rtems_build_id( 1, 1, 1, 256 ) );
166  fatal_directive_status(
167    status,
168    RTEMS_INVALID_ID,
169    "rtems_region_delete with illegal id"
170  );
171  puts( "TA1 - rtems_region_delete - local RTEMS_INVALID_ID" );
172
173  status = rtems_region_ident( 0, &Junk_id );
174  fatal_directive_status(
175    status,
176    RTEMS_INVALID_NAME,
177    "rtems_region_ident with illegal name"
178  );
179  puts( "TA1 - rtems_region_ident - RTEMS_INVALID_NAME" );
180
181  /* Check get_information errors */
182  status = rtems_region_get_information( Region_id[ 1 ], NULL );
183  fatal_directive_status(
184    status,
185    RTEMS_INVALID_ADDRESS,
186    "rtems_region_get_information with NULL information"
187  );
188  puts( "TA1 - rtems_region_get_information - RTEMS_INVALID_ADDRESS" );
189
190  status = rtems_region_get_information( 100, &the_info );
191  fatal_directive_status(
192    status,
193    RTEMS_INVALID_ID,
194    "rtems_region_get_information with illegal id"
195  );
196  puts( "TA1 - rtems_region_get_information - unknown RTEMS_INVALID_ID" );
197
198  /* Check get_free_information errors */
199  status = rtems_region_get_free_information( Region_id[ 1 ], NULL );
200  fatal_directive_status(
201    status,
202    RTEMS_INVALID_ADDRESS,
203    "rtems_region_get_free_information with NULL information"
204  );
205  puts( "TA1 - rtems_region_get_free_information - RTEMS_INVALID_ADDRESS" );
206
207  status = rtems_region_get_free_information( 100, &the_info );
208  fatal_directive_status(
209    status,
210    RTEMS_INVALID_ID,
211    "rtems_region_get_free_information with illegal id"
212  );
213  puts( "TA1 - rtems_region_get_free_information - unknown RTEMS_INVALID_ID" );
214
215  status = rtems_region_get_segment(
216    100,
217    0x40,
218    RTEMS_DEFAULT_OPTIONS,
219    RTEMS_NO_TIMEOUT,
220    &segment_address_1
221  );
222  fatal_directive_status(
223    status,
224    RTEMS_INVALID_ID,
225    "rtems_region_get_segment with illegal id"
226  );
227  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ID" );
228
229  status = rtems_region_get_segment(
230     Region_id[ 1 ],
231     sizeof( Region_good_area ) * 2,
232     RTEMS_DEFAULT_OPTIONS,
233     RTEMS_NO_TIMEOUT,
234     &segment_address_1
235  );
236  fatal_directive_status(
237    status,
238    RTEMS_INVALID_SIZE,
239    "rtems_region_get_segment with illegal size"
240  );
241  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_SIZE" );
242
243  status = rtems_region_get_segment(
244     Region_id[ 1 ],
245     384,
246     RTEMS_DEFAULT_OPTIONS,
247     RTEMS_NO_TIMEOUT,
248     &segment_address_1
249  );
250  directive_failed( status, "rtems_region_get_segment" );
251  puts( "TA1 - rtems_region_get_segment - RTEMS_SUCCESSFUL" );
252
253  status = rtems_region_get_segment(
254     Region_id[ 1 ],
255     REGION_LENGTH / 2,
256     RTEMS_NO_WAIT,
257     RTEMS_NO_TIMEOUT,
258     &segment_address_2
259  );
260  fatal_directive_status(
261    status,
262    RTEMS_UNSATISFIED,
263    "rtems_region_get_segment unsatisfied"
264  );
265  puts( "TA1 - rtems_region_get_segment - RTEMS_UNSATISFIED" );
266
267  puts( "TA1 - rtems_region_get_segment - timeout in 3 seconds" );
268  status = rtems_region_get_segment(
269    Region_id[ 1 ],
270    128,
271    RTEMS_DEFAULT_OPTIONS,
272    3 * TICKS_PER_SECOND,
273    &segment_address_3
274  );
275  fatal_directive_status(
276    status,
277    RTEMS_TIMEOUT,
278    "rtems_region_get_segment timeout"
279  );
280  puts( "TA1 - rtems_region_get_segment - woke up with RTEMS_TIMEOUT" );
281
282  /* Check get_segment_size errors */
283  status = rtems_region_get_segment_size( Region_id[ 1 ], NULL, &segment_size );
284  fatal_directive_status(
285    status,
286    RTEMS_INVALID_ADDRESS,
287    "rtems_region_get_segment_size with NULL segment"
288  );
289  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );
290
291  status = rtems_region_get_segment_size(
292    Region_id[ 1 ], segment_address_1, NULL
293  );
294  fatal_directive_status(
295    status,
296    RTEMS_INVALID_ADDRESS,
297    "rtems_region_get_segment_size with NULL size"
298  );
299  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );
300
301  status = rtems_region_get_segment_size(
302    100, segment_address_1, &segment_size
303  );
304  fatal_directive_status(
305    status,
306    RTEMS_INVALID_ID,
307    "rtems_region_get_segment_size with illegal id"
308  );
309  puts( "TA1 - rtems_region_get_segment_size - unknown RTEMS_INVALID_ID" );
310
311  status = rtems_region_delete( Region_id[ 1 ] );
312  fatal_directive_status(
313    status,
314    RTEMS_RESOURCE_IN_USE,
315    "rtems_region_delete with buffers in use"
316  );
317  puts( "TA1 - rtems_region_delete - RTEMS_RESOURCE_IN_USE" );
318
319  /* Check resize_segment errors */
320  status = rtems_region_resize_segment(
321    Region_id[ 1 ], segment_address_3, 256, NULL
322  );
323  fatal_directive_status(
324    status,
325    RTEMS_INVALID_ADDRESS,
326    "rtems_region_resize_segment with NULL old size"
327  );
328  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );
329
330  status = rtems_region_resize_segment(
331    Region_id[ 1 ], NULL, 256, &segment_size
332  );
333  fatal_directive_status(
334    status,
335    RTEMS_INVALID_ADDRESS,
336    "rtems_region_resize_segment with NULL segment"
337  );
338  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );
339
340  status = rtems_region_resize_segment(
341    100, segment_address_3, 256, &segment_size
342  );
343  fatal_directive_status(
344    status,
345    RTEMS_INVALID_ID,
346    "rtems_region_resize_segment with illegal id"
347  );
348  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ID" );
349
350  /* Check return_segment errors */
351  status = rtems_region_return_segment( 100, segment_address_1 );
352  fatal_directive_status(
353    status,
354    RTEMS_INVALID_ID,
355    "rtems_region_return_segment with illegal id"
356  );
357  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ID" );
358
359  status = rtems_region_return_segment( Region_id[ 1 ], Region_good_area );
360  fatal_directive_status(
361    status,
362    RTEMS_INVALID_ADDRESS,
363    "rtems_region_return_segment with illegal segment"
364  );
365  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );
366
367/*
368 *  The following generate internal heap errors.  Thus this code
369 *  is subject to change if the heap code changes.
370 */
371
372  puts( "TA1 - rtems_debug_disable - RTEMS_DEBUG_REGION" );
373  rtems_debug_disable( RTEMS_DEBUG_REGION );
374
375#if 0
376
377  offset = (segment_address_1 - (void *)Region_good_area) / 4;
378
379/* bad FRONT_FLAG error */
380
381  good_front_flag = Region_good_area[ offset - 1 ];
382  Region_good_area[ offset - 1 ] = good_front_flag + 2;
383
384  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_1 );
385  fatal_directive_status(
386    status,
387    RTEMS_INVALID_ADDRESS,
388    "rtems_region_return_segment with back_flag != front_flag"
389  );
390  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );
391
392  Region_good_area[ offset - 1 ] = good_front_flag;
393
394/* bad FRONT_FLAG error */
395
396  good_back_flag = Region_good_area[ offset - 2 ];
397  Region_good_area[ offset - 2 ] = 1024;
398
399  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_1 );
400  fatal_directive_status(
401    status,
402    RTEMS_INVALID_ADDRESS,
403    "rtems_region_return_segment with back_flag != front_flag"
404  );
405  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );
406
407  Region_good_area[ offset - 2 ] = good_back_flag;
408
409#else
410  offset = 0;
411  good_front_flag = 0;
412  good_back_flag = 0;
413  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS - SKIPPED" );
414  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS - SKIPPED" );
415#endif
416
417  puts( "TA1 - rtems_debug_enable - RTEMS_DEBUG_REGION" );
418  rtems_debug_enable( RTEMS_DEBUG_REGION );
419
420  status = rtems_region_extend(
421    100,
422    Region_good_area,
423    128
424  );
425  fatal_directive_status(
426    status,
427    RTEMS_INVALID_ID,
428    "rtems_region_extend with illegal id"
429  );
430  puts( "TA1 - rtems_region_extend - RTEMS_INVALID_ID" );
431
432  status = rtems_region_extend(
433    Region_id[ 1 ],
434    &Region_good_area[ REGION_START_OFFSET + 16 ],
435    128
436  );
437  fatal_directive_status(
438    status,
439    RTEMS_INVALID_ADDRESS,
440    "rtems_region_extend with illegal starting address"
441  );
442  puts( "TA1 - rtems_region_extend - within heap - RTEMS_INVALID_ADDRESS" );
443
444  status = rtems_region_extend(
445    Region_id[ 1 ],
446    Region_bad_area,
447    128
448  );
449  fatal_directive_status(
450    status,
451    RTEMS_NOT_IMPLEMENTED,
452    "rtems_region_extend with unsupported starting address"
453  );
454  puts(
455    "TA1 - rtems_region_extend - non-contiguous lower - RTEMS_NOT_IMPLEMENTED"
456  );
457
458  status = rtems_region_extend(
459    Region_id[ 1 ],
460    &Region_good_area[ REGION_START_OFFSET - REGION_LENGTH ],
461    128
462  );
463  fatal_directive_status(
464    status,
465    RTEMS_NOT_IMPLEMENTED,
466    "rtems_region_extend with unsupported starting address"
467  );
468  puts(
469    "TA1 - rtems_region_extend - contiguous lower - RTEMS_NOT_IMPLEMENTED"
470  );
471
472  status = rtems_region_extend(
473    Region_id[ 1 ],
474    &Region_good_area[ REGION_START_OFFSET + REGION_LENGTH + 16 ],
475    128
476  );
477  fatal_directive_status(
478    status,
479    RTEMS_NOT_IMPLEMENTED,
480    "rtems_region_extend with unsupported starting address"
481  );
482  puts(
483    "TA1 - rtems_region_extend - non-contiguous higher - RTEMS_NOT_IMPLEMENTED"
484  );
485
486}
Note: See TracBrowser for help on using the repository browser.