source: rtems/testsuites/sptests/sppartition_err01/init.c @ 7132d3d

4.115
Last change on this file since 7132d3d was 7132d3d, checked in by Joel Sherrill <joel.sherrill@…>, on 01/04/14 at 17:04:51

sppartition_err01: Remove dead parts, reduce, and clean up.

Also fix naming issues.

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