source: rtems/testsuites/sptests/sp09/screen12.c @ 7d3f9c6

4.115
Last change on this file since 7d3f9c6 was 7d3f9c6, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 07:37:03

Add HAVE_CONFIG_H.

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