source: rtems/testsuites/sptests/sppartition_err01/screen11.c @ 255178e

4.115
Last change on this file since 255178e was 255178e, checked in by Mandar Juvekar <mjuvekar0@…>, on 01/02/14 at 19:22:36

sptests: Refactor sp09 into sppartition_err01 and sp09.

  • Property mode set to 100644
File size: 8.0 KB
Line 
1/*  Screen11
2 *
3 *  This routine generates error screen 11 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
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include "system.h"
22
23uint32_t Other_Memory;
24
25void Screen11()
26{
27  void              *buffer_address_1;
28  void              *buffer_address_2;
29  void              *buffer_address_3;
30  rtems_status_code  status;
31  size_t             size;
32
33  status = rtems_partition_create(
34    0,
35    Partition_good_area,
36    128,
37    40,
38    RTEMS_DEFAULT_ATTRIBUTES,
39    &Junk_id
40  );
41  fatal_directive_status(
42    status,
43    RTEMS_INVALID_NAME,
44    "rtems_partition_create with illegal name"
45  );
46  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_NAME" );
47
48  status = rtems_partition_create(
49    Partition_name[ 1 ],
50    Partition_good_area,
51    0,
52    71,
53    RTEMS_DEFAULT_ATTRIBUTES,
54    &Junk_id
55  );
56  fatal_directive_status(
57    status,
58    RTEMS_INVALID_SIZE,
59    "rtems_partition_create with illegal length"
60  );
61  puts( "TA1 - rtems_partition_create - length - RTEMS_INVALID_SIZE" );
62
63  status = rtems_partition_create(
64    Partition_name[ 1 ],
65    Partition_good_area,
66    128,
67    0,
68    RTEMS_DEFAULT_ATTRIBUTES,
69    &Junk_id
70  );
71  fatal_directive_status(
72    status,
73    RTEMS_INVALID_SIZE,
74    "rtems_partition_create with illegal buffer size"
75  );
76  puts( "TA1 - rtems_partition_create - buffer size - RTEMS_INVALID_SIZE" );
77
78  status = rtems_partition_create(
79    Partition_name[ 1 ],
80    Partition_good_area,
81    128,
82    256,
83    RTEMS_DEFAULT_ATTRIBUTES,
84    &Junk_id
85  );
86  fatal_directive_status(
87    status,
88    RTEMS_INVALID_SIZE,
89    "rtems_partition_create with buffer_size > length"
90  );
91  puts(
92    "TA1 - rtems_partition_create - length < buffer size - RTEMS_INVALID_SIZE"
93  );
94
95  /*
96   * Attempt to create a partition with a buffer size that is not large
97   * enough to account for the overhead.
98   */
99  puts(
100    "TA1 - rtems_partition_create - buffer size < overhead - RTEMS_INVALID_SIZE"
101  );
102#define SIZEOF_CHAIN_NODE 2 * sizeof(void *)
103  for ( size=0 ; size < SIZEOF_CHAIN_NODE ; size++) {
104    status = rtems_partition_create(
105      Partition_name[ 1 ],
106      Partition_good_area,
107      size,
108      256,
109      RTEMS_DEFAULT_ATTRIBUTES,
110      &Junk_id
111    );
112    if ( status != RTEMS_INVALID_SIZE )
113      printf( "ERROR when size == %zu\n", size );
114
115    fatal_directive_status(
116      status,
117      RTEMS_INVALID_SIZE,
118      "rtems_partition_create with buffer_size > length"
119    );
120  }
121
122  /*
123   *  The check for an object being global is only made if
124   *  multiprocessing is enabled.
125   */
126
127#if defined(RTEMS_MULTIPROCESSING)
128  status = rtems_partition_create(
129    Partition_name[ 1 ],
130    Partition_good_area,
131    128,
132    64,
133    RTEMS_GLOBAL,
134    &Junk_id
135  );
136  fatal_directive_status(
137    status,
138    RTEMS_MP_NOT_CONFIGURED,
139    "rtems_partition_create of global"
140  );
141#endif
142  puts( "TA1 - rtems_partition_create - RTEMS_MP_NOT_CONFIGURED" );
143
144#if defined(_C3x) || defined(_C4x)
145  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_ADDRESS - SKIPPED" );
146#else
147  status = rtems_partition_create(
148    Partition_name[ 1 ],
149    Partition_bad_area,
150    128,
151    64,
152    RTEMS_GLOBAL,
153    &Junk_id
154  );
155  fatal_directive_status(
156    status,
157    RTEMS_INVALID_ADDRESS,
158    "rtems_partition_create with bad address"
159  );
160  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_ADDRESS" );
161#endif
162
163#if defined(_C3x) || defined(_C4x)
164  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_SIZE - SKIPPED" );
165#else
166  status = rtems_partition_create(
167    Partition_name[ 1 ],
168    Partition_good_area,
169    128,
170    35,
171    RTEMS_DEFAULT_ATTRIBUTES,
172    &Junk_id
173  );
174  fatal_directive_status(
175    status,
176    RTEMS_INVALID_SIZE,
177    "rtems_partition_create with unaligned buffer_size"
178  );
179  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_SIZE" );
180#endif
181
182  status = rtems_partition_delete( 100 );
183  fatal_directive_status(
184    status,
185    RTEMS_INVALID_ID,
186    "rtems_partition_delete with illegal id"
187  );
188  puts( "TA1 - rtems_partition_delete - unknown RTEMS_INVALID_ID" );
189
190  status = rtems_partition_delete( rtems_build_id( 1, 1, 1, 256 ) );
191  fatal_directive_status(
192    status,
193    RTEMS_INVALID_ID,
194    "rtems_partition_delete with illegal id"
195  );
196  puts( "TA1 - rtems_partition_delete - local RTEMS_INVALID_ID" );
197
198  /* get bad address */
199  status = rtems_partition_get_buffer( 100, NULL );
200  fatal_directive_status(
201    status,
202    RTEMS_INVALID_ADDRESS,
203    "rtems_partition_get_buffer with NULL param"
204  );
205  puts( "TA1 - rtems_partition_get_buffer - RTEMS_INVALID_ADDRESS" );
206
207  /* get bad Id */
208  status = rtems_partition_get_buffer( 100, &buffer_address_1 );
209  fatal_directive_status(
210    status,
211    RTEMS_INVALID_ID,
212    "rtems_partition_get_buffer with illegal id"
213  );
214  puts( "TA1 - rtems_partition_get_buffer - RTEMS_INVALID_ID" );
215
216  status = rtems_partition_ident( 0, RTEMS_SEARCH_ALL_NODES, &Junk_id );
217  fatal_directive_status(
218    status,
219    RTEMS_INVALID_NAME,
220    "rtems_partition_ident with illegal name"
221  );
222  puts( "TA1 - rtems_partition_ident - RTEMS_INVALID_NAME" );
223
224  status = rtems_partition_return_buffer( 100, buffer_address_1 );
225  fatal_directive_status(
226    status,
227    RTEMS_INVALID_ID,
228    "rtems_partition_return_buffer with illegal id"
229  );
230  puts( "TA1 - rtems_partition_return_buffer - RTEMS_INVALID_ID" );
231
232  /* create bad area */
233  status = rtems_partition_create(
234    Partition_name[ 1 ],
235    NULL,
236    128,
237    64,
238    RTEMS_DEFAULT_ATTRIBUTES,
239    &Junk_id
240  );
241  fatal_directive_status(
242    status,
243    RTEMS_INVALID_ADDRESS,
244    "rtems_partition_return_buffer with NULL area"
245  );
246  puts( "TA1 - rtems_partition_create - RTEMS_INVALID_ADDRESS" );
247
248  /* create OK */
249  status = rtems_partition_create(
250    Partition_name[ 1 ],
251    Partition_good_area,
252    128,
253    64,
254    RTEMS_DEFAULT_ATTRIBUTES,
255    &Partition_id[ 1 ]
256  );
257  directive_failed( status, "rtems_partition_create" );
258  puts( "TA1 - rtems_partition_create - RTEMS_SUCCESSFUL" );
259
260  status = rtems_partition_create(
261    Partition_name[ 1 ],
262    Partition_good_area,
263    128,
264    32,
265    RTEMS_DEFAULT_ATTRIBUTES,
266    &Junk_id
267  );
268  fatal_directive_status(
269    status,
270    RTEMS_TOO_MANY,
271    "rtems_partition_create of too many"
272  );
273  puts( "TA1 - rtems_partition_create - RTEMS_TOO_MANY" );
274
275  status = rtems_partition_get_buffer( Partition_id[ 1 ], &buffer_address_1 );
276  directive_failed( status, "rtems_partition_get_buffer");
277  puts( "TA1 - rtems_partition_get_buffer - RTEMS_SUCCESSFUL" );
278
279  status = rtems_partition_get_buffer( Partition_id[ 1 ], &buffer_address_2 );
280  directive_failed( status, "rtems_partition_get_buffer" );
281  puts( "TA1 - rtems_partition_get_buffer - RTEMS_SUCCESSFUL" );
282
283  status = rtems_partition_get_buffer( Partition_id[ 1 ], &buffer_address_3 );
284  fatal_directive_status(
285    status,
286    RTEMS_UNSATISFIED,
287    "rtems_partition_get_buffer unsatisfied"
288  );
289  puts( "TA1 - rtems_partition_get_buffer - RTEMS_UNSATISFIED" );
290
291  status = rtems_partition_delete( Partition_id[ 1 ] );
292  fatal_directive_status(
293    status,
294    RTEMS_RESOURCE_IN_USE,
295    "rtems_partition_delete with buffers in use"
296  );
297  puts( "TA1 - rtems_partition_delete - RTEMS_RESOURCE_IN_USE" );
298
299  status = rtems_partition_return_buffer(
300    Partition_id[ 1 ],
301    &Other_Memory
302  );
303  fatal_directive_status(
304    status,
305    RTEMS_INVALID_ADDRESS,
306    "rtems_partition_return_buffer with buffer address out of partition"
307  );
308  puts(
309    "TA1 - rtems_partition_return_buffer - RTEMS_INVALID_ADDRESS - out of range"
310  );
311
312  status = rtems_partition_return_buffer(
313    Partition_id[ 1 ],
314    &Partition_good_area[ 7 ]
315  );
316  fatal_directive_status(
317    status,
318    RTEMS_INVALID_ADDRESS,
319    "rtems_partition_return_buffer with buffer address not on boundary"
320  );
321  puts_nocr( "TA1 - rtems_partition_return_buffer - " );
322  puts     ( "RTEMS_INVALID_ADDRESS - not on boundary");
323}
Note: See TracBrowser for help on using the repository browser.