Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:46

0001 /*
0002  * Copyright (c) 2018 embedded brains GmbH & Co. KG
0003  *
0004  * The license and distribution terms for this file may be
0005  * found in the file LICENSE in this distribution or at
0006  * http://www.rtems.com/license/LICENSE.
0007  */
0008 
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012 
0013 #include <rtems.h>
0014 #include <rtems/score/objectimpl.h>
0015 #include <rtems/sysinit.h>
0016 
0017 #include <tmacros.h>
0018 
0019 const char rtems_test_name[] = "SPCONFIG 2";
0020 
0021 static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E');
0022 
0023 static void test_barrier_create(void)
0024 {
0025   rtems_status_code sc;
0026   rtems_id id;
0027 
0028   sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id);
0029   rtems_test_assert(sc == RTEMS_TOO_MANY);
0030 }
0031 
0032 static void test_barrier_delete(void)
0033 {
0034   rtems_status_code sc;
0035   rtems_id id;
0036 
0037   sc = rtems_barrier_delete(0);
0038   rtems_test_assert(sc == RTEMS_INVALID_ID);
0039 
0040   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0);
0041   sc = rtems_barrier_delete(id);
0042   rtems_test_assert(sc == RTEMS_INVALID_ID);
0043 }
0044 
0045 static void test_barrier_get(void)
0046 {
0047   rtems_status_code sc;
0048   rtems_id id;
0049 
0050   sc = rtems_barrier_wait(0, RTEMS_NO_TIMEOUT);
0051   rtems_test_assert(sc == RTEMS_INVALID_ID);
0052 
0053   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0);
0054   sc = rtems_barrier_wait(id, RTEMS_NO_TIMEOUT);
0055   rtems_test_assert(sc == RTEMS_INVALID_ID);
0056 }
0057 
0058 static void test_message_queue_create(void)
0059 {
0060   rtems_status_code sc;
0061   rtems_id id;
0062 
0063   sc = rtems_message_queue_create(
0064     name,
0065     1,
0066     1,
0067     RTEMS_DEFAULT_ATTRIBUTES,
0068     &id
0069   );
0070   rtems_test_assert(sc == RTEMS_TOO_MANY);
0071 }
0072 
0073 static void test_message_queue_delete(void)
0074 {
0075   rtems_status_code sc;
0076   rtems_id id;
0077 
0078   sc = rtems_message_queue_delete(0);
0079   rtems_test_assert(sc == RTEMS_INVALID_ID);
0080 
0081   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0);
0082   sc = rtems_message_queue_delete(id);
0083   rtems_test_assert(sc == RTEMS_INVALID_ID);
0084 }
0085 
0086 static void test_message_queue_get(void)
0087 {
0088   rtems_status_code sc;
0089   rtems_id id;
0090   uint32_t count;
0091 
0092   sc = rtems_message_queue_flush(0, &count);
0093   rtems_test_assert(sc == RTEMS_INVALID_ID);
0094 
0095   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0);
0096   sc = rtems_message_queue_flush(id, &count);
0097   rtems_test_assert(sc == RTEMS_INVALID_ID);
0098 }
0099 
0100 static void test_partition_create(void)
0101 {
0102   rtems_status_code sc;
0103   rtems_id id;
0104   long buf[32];
0105 
0106   sc = rtems_partition_create(
0107     name,
0108     buf,
0109     sizeof(buf),
0110     sizeof(buf),
0111     RTEMS_DEFAULT_ATTRIBUTES,
0112     &id
0113   );
0114   rtems_test_assert(sc == RTEMS_TOO_MANY);
0115 }
0116 
0117 static void test_partition_delete(void)
0118 {
0119   rtems_status_code sc;
0120   rtems_id id;
0121 
0122   sc = rtems_partition_delete(0);
0123   rtems_test_assert(sc == RTEMS_INVALID_ID);
0124 
0125   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0);
0126   sc = rtems_partition_delete(id);
0127   rtems_test_assert(sc == RTEMS_INVALID_ID);
0128 }
0129 
0130 static void test_partition_get(void)
0131 {
0132   rtems_status_code sc;
0133   rtems_id id;
0134 
0135   sc = rtems_partition_return_buffer(0, NULL);
0136   rtems_test_assert(sc == RTEMS_INVALID_ID);
0137 
0138   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0);
0139   sc = rtems_partition_return_buffer(id, NULL);
0140   rtems_test_assert(sc == RTEMS_INVALID_ID);
0141 }
0142 
0143 static void test_rate_monotonic_create(void)
0144 {
0145   rtems_status_code sc;
0146   rtems_id id;
0147 
0148   sc = rtems_rate_monotonic_create(name, &id);
0149   rtems_test_assert(sc == RTEMS_TOO_MANY);
0150 }
0151 
0152 static void test_rate_monotonic_delete(void)
0153 {
0154   rtems_status_code sc;
0155   rtems_id id;
0156 
0157   sc = rtems_rate_monotonic_delete(0);
0158   rtems_test_assert(sc == RTEMS_INVALID_ID);
0159 
0160   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0);
0161   sc = rtems_rate_monotonic_delete(id);
0162   rtems_test_assert(sc == RTEMS_INVALID_ID);
0163 }
0164 
0165 static void test_rate_monotonic_get(void)
0166 {
0167   rtems_status_code sc;
0168   rtems_id id;
0169 
0170   sc = rtems_rate_monotonic_cancel(0);
0171   rtems_test_assert(sc == RTEMS_INVALID_ID);
0172 
0173   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0);
0174   sc = rtems_rate_monotonic_cancel(id);
0175   rtems_test_assert(sc == RTEMS_INVALID_ID);
0176 }
0177 
0178 static void test_region_create(void)
0179 {
0180   rtems_status_code sc;
0181   rtems_id id;
0182   long buf[32];
0183 
0184   sc = rtems_region_create(
0185     name,
0186     buf,
0187     sizeof(buf),
0188     1,
0189     RTEMS_DEFAULT_ATTRIBUTES,
0190     &id
0191   );
0192   rtems_test_assert(sc == RTEMS_TOO_MANY);
0193 }
0194 
0195 static void test_region_delete(void)
0196 {
0197   rtems_status_code sc;
0198   rtems_id id;
0199 
0200   sc = rtems_region_delete(0);
0201   rtems_test_assert(sc == RTEMS_INVALID_ID);
0202 
0203   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0);
0204   sc = rtems_region_delete(id);
0205   rtems_test_assert(sc == RTEMS_INVALID_ID);
0206 }
0207 
0208 static void test_region_get(void)
0209 {
0210   rtems_status_code sc;
0211   rtems_id id;
0212 
0213   sc = rtems_region_return_segment(0, NULL);
0214   rtems_test_assert(sc == RTEMS_INVALID_ID);
0215 
0216   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0);
0217   sc = rtems_region_return_segment(id, NULL);
0218   rtems_test_assert(sc == RTEMS_INVALID_ID);
0219 }
0220 
0221 static void test_semaphore_create(void)
0222 {
0223   rtems_status_code sc;
0224   rtems_id id;
0225 
0226   sc = rtems_semaphore_create(
0227     name,
0228     0,
0229     RTEMS_DEFAULT_ATTRIBUTES,
0230     0,
0231     &id
0232   );
0233   rtems_test_assert(sc == RTEMS_TOO_MANY);
0234 }
0235 
0236 static void test_semaphore_delete(void)
0237 {
0238   rtems_status_code sc;
0239   rtems_id id;
0240 
0241   sc = rtems_semaphore_delete(0);
0242   rtems_test_assert(sc == RTEMS_INVALID_ID);
0243 
0244   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0);
0245   sc = rtems_semaphore_delete(id);
0246   rtems_test_assert(sc == RTEMS_INVALID_ID);
0247 }
0248 
0249 static void test_semaphore_get(void)
0250 {
0251   rtems_status_code sc;
0252   rtems_id id;
0253 
0254   sc = rtems_semaphore_release(0);
0255   rtems_test_assert(sc == RTEMS_INVALID_ID);
0256 
0257   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0);
0258   sc = rtems_semaphore_release(id);
0259   rtems_test_assert(sc == RTEMS_INVALID_ID);
0260 }
0261 
0262 static void test_task_create(void)
0263 {
0264   rtems_status_code sc;
0265   rtems_id id;
0266 
0267   sc = rtems_task_create(
0268     name,
0269     1,
0270     RTEMS_MINIMUM_STACK_SIZE,
0271     RTEMS_DEFAULT_MODES,
0272     RTEMS_DEFAULT_ATTRIBUTES,
0273     &id
0274   );
0275   rtems_test_assert(sc == RTEMS_TOO_MANY);
0276 }
0277 
0278 static void test_task_delete(void)
0279 {
0280   rtems_status_code sc;
0281   rtems_id id;
0282 
0283   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0);
0284   sc = rtems_task_delete(id);
0285   rtems_test_assert(sc == RTEMS_INVALID_ID);
0286 }
0287 
0288 static void test_task_get(void)
0289 {
0290   rtems_status_code sc;
0291   rtems_id id;
0292 
0293   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0);
0294   sc = rtems_task_resume(id);
0295   rtems_test_assert(sc == RTEMS_INVALID_ID);
0296 }
0297 
0298 static void test_timer_create(void)
0299 {
0300   rtems_status_code sc;
0301   rtems_id id;
0302 
0303   sc = rtems_timer_create(name, &id);
0304   rtems_test_assert(sc == RTEMS_TOO_MANY);
0305 }
0306 
0307 static void test_timer_delete(void)
0308 {
0309   rtems_status_code sc;
0310   rtems_id id;
0311 
0312   sc = rtems_timer_delete(0);
0313   rtems_test_assert(sc == RTEMS_INVALID_ID);
0314 
0315   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0);
0316   sc = rtems_timer_delete(id);
0317   rtems_test_assert(sc == RTEMS_INVALID_ID);
0318 }
0319 
0320 static void test_timer_get(void)
0321 {
0322   rtems_status_code sc;
0323   rtems_id id;
0324 
0325   sc = rtems_timer_reset(0);
0326   rtems_test_assert(sc == RTEMS_INVALID_ID);
0327 
0328   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0);
0329   sc = rtems_timer_reset(id);
0330   rtems_test_assert(sc == RTEMS_INVALID_ID);
0331 }
0332 
0333 static void test_user_extensions_create(void)
0334 {
0335   rtems_status_code sc;
0336   rtems_id id;
0337   rtems_extensions_table table;
0338 
0339   memset(&table, 0, sizeof(table));
0340   sc = rtems_extension_create(name, &table, &id);
0341   rtems_test_assert(sc == RTEMS_TOO_MANY);
0342 }
0343 
0344 static void test_user_extensions_delete(void)
0345 {
0346   rtems_status_code sc;
0347   rtems_id id;
0348 
0349   sc = rtems_extension_delete(0);
0350   rtems_test_assert(sc == RTEMS_INVALID_ID);
0351 
0352   id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_EXTENSIONS, 1, 0);
0353   sc = rtems_extension_delete(id);
0354   rtems_test_assert(sc == RTEMS_INVALID_ID);
0355 }
0356 
0357 static void test_id_to_name(rtems_id api, rtems_id cls, rtems_id idx, bool *found)
0358 {
0359   rtems_status_code sc;
0360   rtems_id id;
0361   rtems_name name_of_id;
0362 
0363   id = rtems_build_id(api, cls, 1, idx);
0364   sc = rtems_object_get_classic_name(id, &name_of_id);
0365 
0366   if (sc == RTEMS_SUCCESSFUL) {
0367     if (name_of_id == rtems_build_name('U', 'I', '1', ' ')) {
0368       rtems_test_assert(id == rtems_task_self());
0369       rtems_test_assert(!found[0]);
0370       found[0] = true;
0371     } else {
0372       rtems_test_assert(name_of_id == rtems_build_name('I', 'D', 'L', 'E'));
0373       rtems_test_assert(!found[1]);
0374       found[1] = true;
0375     }
0376   } else {
0377     rtems_test_assert(sc == RTEMS_INVALID_ID);
0378   }
0379 }
0380 
0381 static void test_some_id_to_name(void)
0382 {
0383   rtems_id api;
0384   bool found[2];
0385 
0386   found[0] = false;
0387   found[1] = false;
0388 
0389   for (api = 0; api < 8; ++api) {
0390     rtems_id cls;
0391 
0392     for (cls = 0; cls < 32; ++cls) {
0393       test_id_to_name(api, cls, 0, found);
0394       test_id_to_name(api, cls, 1, found);
0395       test_id_to_name(api, cls, 2, found);
0396       test_id_to_name(api, cls, 65534, found);
0397       test_id_to_name(api, cls, 65535, found);
0398     }
0399   }
0400 
0401   rtems_test_assert(found[0]);
0402   rtems_test_assert(found[1]);
0403 }
0404 
0405 static void Init(rtems_task_argument arg)
0406 {
0407   test_barrier_create();
0408   test_barrier_delete();
0409   test_barrier_get();
0410   test_message_queue_create();
0411   test_message_queue_delete();
0412   test_message_queue_get();
0413   test_partition_create();
0414   test_partition_delete();
0415   test_partition_get();
0416   test_rate_monotonic_create();
0417   test_rate_monotonic_delete();
0418   test_rate_monotonic_get();
0419   test_region_create();
0420   test_region_delete();
0421   test_region_get();
0422   test_semaphore_create();
0423   test_semaphore_delete();
0424   test_semaphore_get();
0425   test_task_create();
0426   test_task_delete();
0427   test_task_get();
0428   test_timer_create();
0429   test_timer_delete();
0430   test_timer_get();
0431   test_user_extensions_create();
0432   test_user_extensions_delete();
0433   test_some_id_to_name();
0434   TEST_END();
0435   rtems_test_exit(0);
0436 }
0437 
0438 static void before_object_information_initialization(void)
0439 {
0440   rtems_print_printer_printk(&rtems_test_printer);
0441   TEST_BEGIN();
0442   test_barrier_get();
0443   test_message_queue_get();
0444   test_partition_get();
0445   test_rate_monotonic_get();
0446   test_semaphore_get();
0447   test_task_get();
0448   test_timer_get();
0449 }
0450 
0451 RTEMS_SYSINIT_ITEM(
0452   before_object_information_initialization,
0453   RTEMS_SYSINIT_INITIAL_EXTENSIONS,
0454   RTEMS_SYSINIT_ORDER_LAST
0455 );
0456 
0457 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0458 
0459 #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
0460 
0461 #define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
0462 
0463 #define CONFIGURE_MAXIMUM_TASKS 1
0464 
0465 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0466 
0467 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0468 
0469 #define CONFIGURE_INIT
0470 
0471 #include <rtems/confdefs.h>