File indexing completed on 2025-05-11 08:24:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035
0036 const char rtems_test_name[] = "SPREGION_ERR 1";
0037
0038 static rtems_name Region_name[ 2 ];
0039 static rtems_id Region_id[ 2 ];
0040
0041 static uint8_t Region_good_area[4096] CPU_STRUCTURE_ALIGNMENT;
0042 #define Region_bad_area (void *) 0x00000005
0043 #define REGION_START_OFFSET 1024
0044 #define REGION_LENGTH 512
0045
0046 static void region_error_tests(void)
0047 {
0048 void *segment_address_1;
0049 void *segment_address_2;
0050 void *segment_address_3;
0051 uintptr_t segment_size;
0052 rtems_status_code status;
0053 Heap_Information_block the_info;
0054 rtems_id junk_id;
0055
0056 Region_name[ 1 ] = rtems_build_name( 'R', 'N', '1', ' ' );
0057
0058
0059 status = rtems_region_create(
0060 0,
0061 Region_good_area,
0062 0x40,
0063 32,
0064 RTEMS_DEFAULT_ATTRIBUTES,
0065 &junk_id
0066 );
0067 fatal_directive_status(
0068 status,
0069 RTEMS_INVALID_NAME,
0070 "rtems_region_create with illegal name"
0071 );
0072 puts( "TA1 - rtems_region_create - RTEMS_INVALID_NAME" );
0073
0074
0075 status = rtems_region_create(
0076 Region_name[ 1 ],
0077 NULL,
0078 0x40,
0079 32,
0080 RTEMS_DEFAULT_ATTRIBUTES,
0081 &junk_id
0082 );
0083 fatal_directive_status(
0084 status,
0085 RTEMS_INVALID_ADDRESS,
0086 "rtems_region_create with NULL address"
0087 );
0088 puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
0089
0090
0091 status = rtems_region_create(
0092 Region_name[ 1 ],
0093 Region_good_area,
0094 0,
0095 0,
0096 RTEMS_DEFAULT_ATTRIBUTES,
0097 &junk_id
0098 );
0099 fatal_directive_status(
0100 status,
0101 RTEMS_INVALID_SIZE,
0102 "rtems_region_create with illegal size"
0103 );
0104 puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE" );
0105
0106
0107 status = rtems_region_create(
0108 Region_name[ 1 ],
0109 Region_good_area,
0110 REGION_LENGTH,
0111 0x40,
0112 RTEMS_DEFAULT_ATTRIBUTES,
0113 NULL
0114 );
0115 fatal_directive_status(
0116 status,
0117 RTEMS_INVALID_ADDRESS,
0118 "rtems_region_create with NULL id"
0119 );
0120 puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
0121
0122 status = rtems_region_create(
0123 Region_name[ 1 ],
0124 &Region_good_area[ REGION_START_OFFSET ],
0125 REGION_LENGTH,
0126 0x40,
0127 RTEMS_DEFAULT_ATTRIBUTES,
0128 &Region_id[ 1 ]
0129 );
0130 directive_failed( status, "rtems_region_create" );
0131 puts( "TA1 - rtems_region_create - RTEMS_SUCCESSFUL" );
0132
0133
0134 status = rtems_region_extend(
0135 Region_id[ 1 ],
0136 NULL,
0137 REGION_LENGTH - 1
0138 );
0139 fatal_directive_status(
0140 status,
0141 RTEMS_INVALID_ADDRESS,
0142 "rtems_region_extend with NULL"
0143 );
0144 puts( "TA1 - rtems_region_extend - NULL address - RTEMS_INVALID_ADDRESS" );
0145
0146
0147 status = rtems_region_extend(
0148 Region_id[ 1 ],
0149 &Region_good_area[ REGION_START_OFFSET ],
0150 REGION_LENGTH - 1
0151 );
0152 fatal_directive_status(
0153 status,
0154 RTEMS_INVALID_ADDRESS,
0155 "rtems_region_extend with address in heap"
0156 );
0157 puts( "TA1 - rtems_region_extend - address within - RTEMS_INVALID_ADDRESS" );
0158
0159 status = rtems_region_create(
0160 Region_name[ 1 ],
0161 Region_good_area,
0162 REGION_LENGTH,
0163 0x40,
0164 RTEMS_DEFAULT_ATTRIBUTES,
0165 &junk_id
0166 );
0167 fatal_directive_status(
0168 status,
0169 RTEMS_TOO_MANY,
0170 "rtems_region_create of too many"
0171 );
0172 puts( "TA1 - rtems_region_create - RTEMS_TOO_MANY" );
0173
0174 status = rtems_region_delete( 100 );
0175 fatal_directive_status(
0176 status,
0177 RTEMS_INVALID_ID,
0178 "rtems_region_delete with illegal id"
0179 );
0180 puts( "TA1 - rtems_region_delete - unknown RTEMS_INVALID_ID" );
0181
0182 status = rtems_region_delete( rtems_build_id( 1, 1, 1, 256 ) );
0183 fatal_directive_status(
0184 status,
0185 RTEMS_INVALID_ID,
0186 "rtems_region_delete with illegal id"
0187 );
0188 puts( "TA1 - rtems_region_delete - local RTEMS_INVALID_ID" );
0189
0190 status = rtems_region_ident( 0, &junk_id );
0191 fatal_directive_status(
0192 status,
0193 RTEMS_INVALID_NAME,
0194 "rtems_region_ident with illegal name"
0195 );
0196 puts( "TA1 - rtems_region_ident - RTEMS_INVALID_NAME" );
0197
0198
0199 status = rtems_region_get_information( Region_id[ 1 ], NULL );
0200 fatal_directive_status(
0201 status,
0202 RTEMS_INVALID_ADDRESS,
0203 "rtems_region_get_information with NULL information"
0204 );
0205 puts( "TA1 - rtems_region_get_information - RTEMS_INVALID_ADDRESS" );
0206
0207 status = rtems_region_get_information( 100, &the_info );
0208 fatal_directive_status(
0209 status,
0210 RTEMS_INVALID_ID,
0211 "rtems_region_get_information with illegal id"
0212 );
0213 puts( "TA1 - rtems_region_get_information - unknown RTEMS_INVALID_ID" );
0214
0215
0216 status = rtems_region_get_free_information( Region_id[ 1 ], NULL );
0217 fatal_directive_status(
0218 status,
0219 RTEMS_INVALID_ADDRESS,
0220 "rtems_region_get_free_information with NULL information"
0221 );
0222 puts( "TA1 - rtems_region_get_free_information - RTEMS_INVALID_ADDRESS" );
0223
0224 status = rtems_region_get_free_information( 100, &the_info );
0225 fatal_directive_status(
0226 status,
0227 RTEMS_INVALID_ID,
0228 "rtems_region_get_free_information with illegal id"
0229 );
0230 puts( "TA1 - rtems_region_get_free_information - unknown RTEMS_INVALID_ID" );
0231
0232
0233 status = rtems_region_get_segment(
0234 100,
0235 0x40,
0236 RTEMS_DEFAULT_OPTIONS,
0237 RTEMS_NO_TIMEOUT,
0238 &segment_address_1
0239 );
0240 fatal_directive_status(
0241 status,
0242 RTEMS_INVALID_ID,
0243 "rtems_region_get_segment with illegal id"
0244 );
0245 puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ID" );
0246
0247
0248 status = rtems_region_get_segment(
0249 Region_id[ 1 ],
0250 2,
0251 RTEMS_DEFAULT_OPTIONS,
0252 RTEMS_NO_TIMEOUT,
0253 NULL
0254 );
0255 fatal_directive_status(
0256 status,
0257 RTEMS_INVALID_ADDRESS,
0258 "rtems_region_get_segment with NULL param"
0259 );
0260 puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ADDRESS" );
0261
0262
0263 status = rtems_region_get_segment(
0264 Region_id[ 1 ],
0265 0,
0266 RTEMS_DEFAULT_OPTIONS,
0267 RTEMS_NO_TIMEOUT,
0268 &segment_address_1
0269 );
0270 fatal_directive_status(
0271 status,
0272 RTEMS_INVALID_SIZE,
0273 "rtems_region_get_segment with 0 size"
0274 );
0275 puts( "TA1 - rtems_region_get_segment - 0 size - RTEMS_INVALID_SIZE" );
0276
0277
0278 status = rtems_region_get_segment(
0279 Region_id[ 1 ],
0280 sizeof( Region_good_area ) * 2,
0281 RTEMS_DEFAULT_OPTIONS,
0282 RTEMS_NO_TIMEOUT,
0283 &segment_address_1
0284 );
0285 fatal_directive_status(
0286 status,
0287 RTEMS_INVALID_SIZE,
0288 "rtems_region_get_segment with big size"
0289 );
0290 puts( "TA1 - rtems_region_get_segment - too big - RTEMS_INVALID_SIZE" );
0291
0292 status = rtems_region_get_segment(
0293 Region_id[ 1 ],
0294 REGION_LENGTH / 2,
0295 RTEMS_DEFAULT_OPTIONS,
0296 RTEMS_NO_TIMEOUT,
0297 &segment_address_1
0298 );
0299 directive_failed( status, "rtems_region_get_segment" );
0300 puts( "TA1 - rtems_region_get_segment - RTEMS_SUCCESSFUL" );
0301
0302 status = rtems_region_get_segment(
0303 Region_id[ 1 ],
0304 REGION_LENGTH / 2,
0305 RTEMS_NO_WAIT,
0306 RTEMS_NO_TIMEOUT,
0307 &segment_address_2
0308 );
0309 fatal_directive_status(
0310 status,
0311 RTEMS_UNSATISFIED,
0312 "rtems_region_get_segment unsatisfied"
0313 );
0314 puts( "TA1 - rtems_region_get_segment - RTEMS_UNSATISFIED" );
0315
0316 puts( "TA1 - rtems_region_get_segment - timeout in 3 seconds" );
0317 status = rtems_region_get_segment(
0318 Region_id[ 1 ],
0319 REGION_LENGTH / 2,
0320 RTEMS_DEFAULT_OPTIONS,
0321 3 * rtems_clock_get_ticks_per_second(),
0322 &segment_address_3
0323 );
0324 fatal_directive_status(
0325 status,
0326 RTEMS_TIMEOUT,
0327 "rtems_region_get_segment timeout"
0328 );
0329 puts( "TA1 - rtems_region_get_segment - woke up with RTEMS_TIMEOUT" );
0330
0331
0332 status = rtems_region_get_segment_size( Region_id[ 1 ], NULL, &segment_size );
0333 fatal_directive_status(
0334 status,
0335 RTEMS_INVALID_ADDRESS,
0336 "rtems_region_get_segment_size with NULL segment"
0337 );
0338 puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );
0339
0340 status = rtems_region_get_segment_size(
0341 Region_id[ 1 ], segment_address_1, NULL
0342 );
0343 fatal_directive_status(
0344 status,
0345 RTEMS_INVALID_ADDRESS,
0346 "rtems_region_get_segment_size with NULL size"
0347 );
0348 puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );
0349
0350 status = rtems_region_get_segment_size(
0351 100, segment_address_1, &segment_size
0352 );
0353 fatal_directive_status(
0354 status,
0355 RTEMS_INVALID_ID,
0356 "rtems_region_get_segment_size with illegal id"
0357 );
0358 puts( "TA1 - rtems_region_get_segment_size - unknown RTEMS_INVALID_ID" );
0359
0360 status = rtems_region_delete( Region_id[ 1 ] );
0361 fatal_directive_status(
0362 status,
0363 RTEMS_RESOURCE_IN_USE,
0364 "rtems_region_delete with buffers in use"
0365 );
0366 puts( "TA1 - rtems_region_delete - RTEMS_RESOURCE_IN_USE" );
0367
0368
0369 status = rtems_region_resize_segment(
0370 Region_id[ 1 ], segment_address_3, 256, NULL
0371 );
0372 fatal_directive_status(
0373 status,
0374 RTEMS_INVALID_ADDRESS,
0375 "rtems_region_resize_segment with NULL old size"
0376 );
0377 puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );
0378
0379 status = rtems_region_resize_segment(
0380 Region_id[ 1 ], NULL, 256, &segment_size
0381 );
0382 fatal_directive_status(
0383 status,
0384 RTEMS_INVALID_ADDRESS,
0385 "rtems_region_resize_segment with NULL segment"
0386 );
0387 puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );
0388
0389 status = rtems_region_resize_segment(
0390 100, segment_address_3, 256, &segment_size
0391 );
0392 fatal_directive_status(
0393 status,
0394 RTEMS_INVALID_ID,
0395 "rtems_region_resize_segment with illegal id"
0396 );
0397 puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ID" );
0398
0399
0400 status = rtems_region_return_segment( 100, segment_address_1 );
0401 fatal_directive_status(
0402 status,
0403 RTEMS_INVALID_ID,
0404 "rtems_region_return_segment with illegal id"
0405 );
0406 puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ID" );
0407
0408 status = rtems_region_return_segment( Region_id[ 1 ], Region_good_area );
0409 fatal_directive_status(
0410 status,
0411 RTEMS_INVALID_ADDRESS,
0412 "rtems_region_return_segment with illegal segment"
0413 );
0414 puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );
0415
0416
0417
0418
0419
0420
0421 status = rtems_region_extend(
0422 100,
0423 Region_good_area,
0424 128
0425 );
0426 fatal_directive_status(
0427 status,
0428 RTEMS_INVALID_ID,
0429 "rtems_region_extend with illegal id"
0430 );
0431 puts( "TA1 - rtems_region_extend - RTEMS_INVALID_ID" );
0432
0433 status = rtems_region_extend(
0434 Region_id[ 1 ],
0435 &Region_good_area[ REGION_START_OFFSET + 16 ],
0436 128
0437 );
0438 fatal_directive_status(
0439 status,
0440 RTEMS_INVALID_ADDRESS,
0441 "rtems_region_extend with illegal starting address"
0442 );
0443 puts( "TA1 - rtems_region_extend - within heap - RTEMS_INVALID_ADDRESS" );
0444 }
0445
0446 rtems_task Init(
0447 rtems_task_argument argument
0448 )
0449 {
0450 TEST_BEGIN();
0451
0452 region_error_tests();
0453
0454 TEST_END();
0455 rtems_test_exit( 0 );
0456 }