source: rtems/testsuites/sptests/sppartition_err01/init.c @ 99de42c

5
Last change on this file since 99de42c was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

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