[b6c5fe0] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup psxtests |
---|
| 5 | * |
---|
| 6 | * @brief Test that the workspace size estimate is correct. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[d507c037] | 10 | * Copyright (c) 2014. On-Line Applications Research Corporation (OAR). |
---|
[7bdb765] | 11 | * Copyright (c) 2011-2014 embedded brains GmbH. All rights reserved. |
---|
[b6c5fe0] | 12 | * |
---|
| 13 | * embedded brains GmbH |
---|
[7bdb765] | 14 | * Dornierstr. 4 |
---|
[b6c5fe0] | 15 | * 82178 Puchheim |
---|
| 16 | * Germany |
---|
| 17 | * <rtems@embedded-brains.de> |
---|
| 18 | * |
---|
| 19 | * The license and distribution terms for this file may be |
---|
| 20 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 21 | * http://www.rtems.org/license/LICENSE. |
---|
[b6c5fe0] | 22 | */ |
---|
| 23 | |
---|
| 24 | #ifdef HAVE_CONFIG_H |
---|
| 25 | #include "config.h" |
---|
| 26 | #endif |
---|
| 27 | |
---|
[698c2e50] | 28 | #include <rtems/test.h> |
---|
[b6c5fe0] | 29 | #include <tmacros.h> |
---|
| 30 | |
---|
| 31 | #include <sys/stat.h> |
---|
| 32 | #include <fcntl.h> |
---|
[73699608] | 33 | #include <inttypes.h> |
---|
| 34 | #include <mqueue.h> |
---|
[b6c5fe0] | 35 | #include <pthread.h> |
---|
[73699608] | 36 | #include <semaphore.h> |
---|
| 37 | #include <signal.h> |
---|
[b6c5fe0] | 38 | #include <stdio.h> |
---|
[73699608] | 39 | #include <time.h> |
---|
[a9127a2e] | 40 | #include <limits.h> |
---|
[b6c5fe0] | 41 | |
---|
[c5d2760] | 42 | #include <rtems/libcsupport.h> |
---|
| 43 | |
---|
[698c2e50] | 44 | const char rtems_test_name[] = "PSXCONFIG 1"; |
---|
| 45 | |
---|
[73699608] | 46 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5 |
---|
[b6c5fe0] | 47 | |
---|
[7bdb765] | 48 | #define CONFIGURE_MAXIMUM_POSIX_KEYS 23 |
---|
| 49 | #ifdef CONFIGURE_MAXIMUM_POSIX_KEYS |
---|
| 50 | #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS CONFIGURE_MAXIMUM_POSIX_KEYS |
---|
| 51 | #endif |
---|
| 52 | |
---|
[c5d2760] | 53 | #define CONFIGURE_MAXIMUM_BARRIERS 2 |
---|
| 54 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 7 |
---|
[b6c5fe0] | 55 | #define CONFIGURE_MAXIMUM_PARTITIONS 37 |
---|
| 56 | #define CONFIGURE_MAXIMUM_PERIODS 41 |
---|
| 57 | #define CONFIGURE_MAXIMUM_REGIONS 43 |
---|
| 58 | #define CONFIGURE_MAXIMUM_SEMAPHORES 47 |
---|
| 59 | #define CONFIGURE_MAXIMUM_TASKS 11 |
---|
| 60 | #define CONFIGURE_MAXIMUM_TIMERS 59 |
---|
[73699608] | 61 | #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17 |
---|
[b6c5fe0] | 62 | |
---|
[73699608] | 63 | #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 31 |
---|
[b6c5fe0] | 64 | #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29 |
---|
[73699608] | 65 | #define POSIX_MQ_COUNT 5 |
---|
[b6c5fe0] | 66 | #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 19 |
---|
[73699608] | 67 | #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 7 |
---|
| 68 | #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS 31 |
---|
| 69 | #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 41 |
---|
[698c2e50] | 70 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
| 71 | |
---|
[b6c5fe0] | 72 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 3 |
---|
[73699608] | 73 | #define CONFIGURE_MAXIMUM_POSIX_TIMERS 47 |
---|
[b6c5fe0] | 74 | |
---|
[73699608] | 75 | #ifndef CONFIGURE_MAXIMUM_TASKS |
---|
| 76 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
| 77 | #endif |
---|
| 78 | |
---|
| 79 | #ifdef CONFIGURE_MAXIMUM_MESSAGE_QUEUES |
---|
| 80 | #define MQ_0_COUNT 2 |
---|
| 81 | #define MQ_1_COUNT 3 |
---|
| 82 | #define MQ_2_COUNT 5 |
---|
| 83 | #define MQ_3_COUNT 7 |
---|
| 84 | #define MQ_4_COUNT 11 |
---|
| 85 | #define MQ_5_COUNT 13 |
---|
| 86 | #define MQ_6_COUNT 17 |
---|
| 87 | |
---|
| 88 | #define MQ_0_SIZE 101 |
---|
| 89 | #define MQ_1_SIZE 103 |
---|
| 90 | #define MQ_2_SIZE 107 |
---|
| 91 | #define MQ_3_SIZE 109 |
---|
| 92 | #define MQ_4_SIZE 113 |
---|
| 93 | #define MQ_5_SIZE 127 |
---|
| 94 | #define MQ_6_SIZE 131 |
---|
| 95 | |
---|
| 96 | #define MQ_BUFFER_MEMORY \ |
---|
| 97 | (CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_0_COUNT, MQ_0_SIZE) \ |
---|
| 98 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_1_COUNT, MQ_1_SIZE) \ |
---|
| 99 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_2_COUNT, MQ_2_SIZE) \ |
---|
| 100 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_3_COUNT, MQ_3_SIZE) \ |
---|
| 101 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_4_COUNT, MQ_4_SIZE) \ |
---|
| 102 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_5_COUNT, MQ_5_SIZE) \ |
---|
| 103 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(MQ_6_COUNT, MQ_6_SIZE)) |
---|
| 104 | |
---|
| 105 | static const uint8_t mq_counts [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = { |
---|
| 106 | MQ_0_COUNT, |
---|
| 107 | MQ_1_COUNT, |
---|
| 108 | MQ_2_COUNT, |
---|
| 109 | MQ_3_COUNT, |
---|
| 110 | MQ_4_COUNT, |
---|
| 111 | MQ_5_COUNT, |
---|
| 112 | MQ_6_COUNT |
---|
| 113 | }; |
---|
| 114 | |
---|
| 115 | static const uint8_t mq_sizes [CONFIGURE_MAXIMUM_MESSAGE_QUEUES] = { |
---|
| 116 | MQ_0_SIZE, |
---|
| 117 | MQ_1_SIZE, |
---|
| 118 | MQ_2_SIZE, |
---|
| 119 | MQ_3_SIZE, |
---|
| 120 | MQ_4_SIZE, |
---|
| 121 | MQ_5_SIZE, |
---|
| 122 | MQ_6_SIZE |
---|
| 123 | }; |
---|
| 124 | #else |
---|
| 125 | #define MQ_BUFFER_MEMORY 0 |
---|
| 126 | #endif |
---|
| 127 | |
---|
| 128 | #ifdef POSIX_MQ_COUNT |
---|
| 129 | #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES POSIX_MQ_COUNT |
---|
| 130 | |
---|
| 131 | #define POSIX_MQ_0_COUNT 2 |
---|
| 132 | #define POSIX_MQ_1_COUNT 3 |
---|
| 133 | #define POSIX_MQ_2_COUNT 5 |
---|
| 134 | #define POSIX_MQ_3_COUNT 7 |
---|
| 135 | #define POSIX_MQ_4_COUNT 11 |
---|
| 136 | |
---|
| 137 | #define POSIX_MQ_0_SIZE 137 |
---|
| 138 | #define POSIX_MQ_1_SIZE 139 |
---|
| 139 | #define POSIX_MQ_2_SIZE 149 |
---|
| 140 | #define POSIX_MQ_3_SIZE 151 |
---|
| 141 | #define POSIX_MQ_4_SIZE 157 |
---|
| 142 | |
---|
| 143 | #define POSIX_MQ_BUFFER_MEMORY \ |
---|
| 144 | (CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_0_COUNT, POSIX_MQ_0_SIZE) \ |
---|
| 145 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_1_COUNT, POSIX_MQ_1_SIZE) \ |
---|
| 146 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_2_COUNT, POSIX_MQ_2_SIZE) \ |
---|
| 147 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_3_COUNT, POSIX_MQ_3_SIZE) \ |
---|
| 148 | + CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(POSIX_MQ_4_COUNT, POSIX_MQ_4_SIZE)) |
---|
| 149 | |
---|
| 150 | static const uint8_t posix_mq_counts [POSIX_MQ_COUNT] = { |
---|
| 151 | POSIX_MQ_0_COUNT, |
---|
| 152 | POSIX_MQ_1_COUNT, |
---|
| 153 | POSIX_MQ_2_COUNT, |
---|
| 154 | POSIX_MQ_3_COUNT, |
---|
| 155 | POSIX_MQ_4_COUNT |
---|
| 156 | }; |
---|
| 157 | |
---|
| 158 | static const uint8_t posix_mq_sizes [POSIX_MQ_COUNT] = { |
---|
| 159 | POSIX_MQ_0_SIZE, |
---|
| 160 | POSIX_MQ_1_SIZE, |
---|
| 161 | POSIX_MQ_2_SIZE, |
---|
| 162 | POSIX_MQ_3_SIZE, |
---|
| 163 | POSIX_MQ_4_SIZE |
---|
| 164 | }; |
---|
| 165 | #else |
---|
| 166 | #define POSIX_MQ_BUFFER_MEMORY 0 |
---|
| 167 | #endif |
---|
| 168 | |
---|
| 169 | #define CONFIGURE_MESSAGE_BUFFER_MEMORY \ |
---|
| 170 | (MQ_BUFFER_MEMORY + POSIX_MQ_BUFFER_MEMORY) |
---|
[b6c5fe0] | 171 | |
---|
[6e4c01e] | 172 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 173 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 174 | |
---|
| 175 | #define CONFIGURE_MAXIMUM_DRIVERS 2 |
---|
| 176 | |
---|
[698c2e50] | 177 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
| 178 | |
---|
[6e4c01e] | 179 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 180 | |
---|
| 181 | #define CONFIGURE_INIT |
---|
| 182 | |
---|
| 183 | static rtems_task Init(rtems_task_argument argument); |
---|
| 184 | |
---|
| 185 | #include <rtems/confdefs.h> |
---|
| 186 | |
---|
[b6c5fe0] | 187 | typedef struct { |
---|
[c7dc99ef] | 188 | uint64_t data [16]; |
---|
[b6c5fe0] | 189 | } area; |
---|
| 190 | |
---|
[73699608] | 191 | #ifdef CONFIGURE_MAXIMUM_PARTITIONS |
---|
| 192 | static area partition_areas [CONFIGURE_MAXIMUM_PARTITIONS]; |
---|
| 193 | #endif |
---|
| 194 | |
---|
| 195 | #ifdef CONFIGURE_MAXIMUM_REGIONS |
---|
| 196 | static area region_areas [CONFIGURE_MAXIMUM_REGIONS]; |
---|
| 197 | #endif |
---|
[b6c5fe0] | 198 | |
---|
[e4fd35d] | 199 | static char posix_name [_POSIX_PATH_MAX + 1]; |
---|
[b6c5fe0] | 200 | |
---|
[73699608] | 201 | static char *get_posix_name(char a, char b, char c, int i) |
---|
| 202 | { |
---|
[e4fd35d] | 203 | posix_name [_POSIX_PATH_MAX - 4] = a; |
---|
| 204 | posix_name [_POSIX_PATH_MAX - 3] = b; |
---|
| 205 | posix_name [_POSIX_PATH_MAX - 2] = c; |
---|
| 206 | posix_name [_POSIX_PATH_MAX - 1] = 'A' + i; |
---|
[73699608] | 207 | |
---|
| 208 | return posix_name; |
---|
| 209 | } |
---|
| 210 | |
---|
[f97536d] | 211 | static void *posix_thread(void *arg RTEMS_UNUSED) |
---|
[b6c5fe0] | 212 | { |
---|
| 213 | rtems_test_assert(0); |
---|
| 214 | } |
---|
| 215 | |
---|
[f97536d] | 216 | static void posix_key_dtor(void *key RTEMS_UNUSED) |
---|
[b6c5fe0] | 217 | { |
---|
| 218 | /* Do nothing */ |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | static void print_info(void) |
---|
| 222 | { |
---|
| 223 | Heap_Information_block info; |
---|
| 224 | bool ok = rtems_workspace_get_information(&info); |
---|
| 225 | rtems_test_assert(ok); |
---|
| 226 | |
---|
| 227 | printf( |
---|
| 228 | "used blocks = %" PRIu32 ", " |
---|
| 229 | "largest used block = %" PRIu32 ", " |
---|
| 230 | "used space = %" PRIu32 "\n" |
---|
| 231 | "free blocks = %" PRIu32 ", " |
---|
| 232 | "largest free block = %" PRIu32 ", " |
---|
| 233 | "free space = %" PRIu32 "\n", |
---|
| 234 | info.Used.number, |
---|
| 235 | info.Used.largest, |
---|
| 236 | info.Used.total, |
---|
| 237 | info.Free.number, |
---|
| 238 | info.Free.largest, |
---|
| 239 | info.Free.total |
---|
| 240 | ); |
---|
| 241 | } |
---|
| 242 | |
---|
[73699608] | 243 | static rtems_task Init(rtems_task_argument argument) |
---|
[b6c5fe0] | 244 | { |
---|
| 245 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
[73699608] | 246 | int eno = 0; |
---|
| 247 | int rv = 0; |
---|
[b6c5fe0] | 248 | rtems_id id = RTEMS_ID_NONE; |
---|
| 249 | rtems_name name = rtems_build_name('C', 'O', 'N', 'F'); |
---|
| 250 | rtems_extensions_table table; |
---|
[c5d2760] | 251 | rtems_resource_snapshot snapshot; |
---|
[b6c5fe0] | 252 | int i = 0; |
---|
[7bdb765] | 253 | pthread_key_t key; |
---|
[b6c5fe0] | 254 | |
---|
[698c2e50] | 255 | TEST_BEGIN(); |
---|
[b6c5fe0] | 256 | |
---|
[73699608] | 257 | memset(posix_name, 'P', sizeof(posix_name) - 1); |
---|
| 258 | |
---|
[b6c5fe0] | 259 | print_info(); |
---|
| 260 | |
---|
[c5d2760] | 261 | rtems_resource_snapshot_take(&snapshot); |
---|
| 262 | rtems_test_assert(rtems_resource_snapshot_equal(&snapshot, &snapshot)); |
---|
| 263 | rtems_test_assert(rtems_resource_snapshot_check(&snapshot)); |
---|
| 264 | |
---|
[73699608] | 265 | #ifdef CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS |
---|
| 266 | for (i = 3; i < CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS; ++i) { |
---|
| 267 | int oflag = O_WRONLY | O_CREAT | O_TRUNC; |
---|
| 268 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
---|
| 269 | char path [] = { 'F', 'I', 'L', 'E', 'A' + i, '\0' }; |
---|
| 270 | int fd = open(path, oflag, mode); |
---|
| 271 | rtems_test_assert(fd == i); |
---|
| 272 | } |
---|
[c5d2760] | 273 | rtems_resource_snapshot_take(&snapshot); |
---|
| 274 | rtems_test_assert( |
---|
| 275 | snapshot.open_files == CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS |
---|
| 276 | ); |
---|
[73699608] | 277 | #endif |
---|
[b6c5fe0] | 278 | |
---|
[73699608] | 279 | #ifdef CONFIGURE_MAXIMUM_USER_EXTENSIONS |
---|
[b6c5fe0] | 280 | memset(&table, 0, sizeof(table)); |
---|
| 281 | for (i = 0; i < CONFIGURE_MAXIMUM_USER_EXTENSIONS; ++i) { |
---|
| 282 | sc = rtems_extension_create(name, &table, &id); |
---|
| 283 | directive_failed(sc, "rtems_extension_create"); |
---|
| 284 | } |
---|
[c5d2760] | 285 | rtems_resource_snapshot_take(&snapshot); |
---|
| 286 | rtems_test_assert( |
---|
| 287 | snapshot.rtems_api.active_extensions == CONFIGURE_MAXIMUM_USER_EXTENSIONS |
---|
| 288 | ); |
---|
[73699608] | 289 | #endif |
---|
[b6c5fe0] | 290 | |
---|
[7bdb765] | 291 | #ifdef CONFIGURE_MAXIMUM_POSIX_KEYS |
---|
| 292 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_KEYS; ++i) { |
---|
| 293 | eno = pthread_key_create(&key, posix_key_dtor); |
---|
| 294 | rtems_test_assert(eno == 0); |
---|
| 295 | |
---|
[ab90136b] | 296 | eno = pthread_setspecific(key, (void *) (uintptr_t)(i + 1)); |
---|
[7bdb765] | 297 | rtems_test_assert(eno == 0); |
---|
| 298 | } |
---|
| 299 | eno = pthread_key_create(&key, posix_key_dtor); |
---|
| 300 | rtems_test_assert(eno == EAGAIN); |
---|
| 301 | rtems_resource_snapshot_take(&snapshot); |
---|
| 302 | rtems_test_assert( |
---|
[07d71279] | 303 | snapshot.active_posix_keys == _CONFIGURE_POSIX_KEYS |
---|
[7bdb765] | 304 | ); |
---|
| 305 | rtems_test_assert( |
---|
| 306 | snapshot.active_posix_key_value_pairs == CONFIGURE_MAXIMUM_POSIX_KEYS |
---|
| 307 | ); |
---|
| 308 | #else |
---|
| 309 | (void) key; |
---|
| 310 | #endif |
---|
| 311 | |
---|
[73699608] | 312 | #ifdef CONFIGURE_MAXIMUM_BARRIERS |
---|
[b6c5fe0] | 313 | for (i = 0; i < CONFIGURE_MAXIMUM_BARRIERS; ++i) { |
---|
| 314 | sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id); |
---|
| 315 | directive_failed(sc, "rtems_barrier_create"); |
---|
| 316 | } |
---|
[c5d2760] | 317 | rtems_resource_snapshot_take(&snapshot); |
---|
| 318 | rtems_test_assert( |
---|
| 319 | snapshot.rtems_api.active_barriers == CONFIGURE_MAXIMUM_BARRIERS |
---|
| 320 | ); |
---|
[73699608] | 321 | #endif |
---|
[b6c5fe0] | 322 | |
---|
[73699608] | 323 | #ifdef CONFIGURE_MAXIMUM_MESSAGE_QUEUES |
---|
[b6c5fe0] | 324 | for (i = 0; i < CONFIGURE_MAXIMUM_MESSAGE_QUEUES; ++i) { |
---|
| 325 | sc = rtems_message_queue_create( |
---|
| 326 | name, |
---|
| 327 | mq_counts [i], |
---|
| 328 | mq_sizes [i], |
---|
| 329 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 330 | &id |
---|
| 331 | ); |
---|
| 332 | directive_failed(sc, "rtems_message_queue_create"); |
---|
| 333 | } |
---|
[c5d2760] | 334 | rtems_resource_snapshot_take(&snapshot); |
---|
| 335 | rtems_test_assert( |
---|
| 336 | snapshot.rtems_api.active_message_queues |
---|
| 337 | == CONFIGURE_MAXIMUM_MESSAGE_QUEUES |
---|
| 338 | ); |
---|
[73699608] | 339 | #endif |
---|
[b6c5fe0] | 340 | |
---|
[73699608] | 341 | #ifdef CONFIGURE_MAXIMUM_PARTITIONS |
---|
[b6c5fe0] | 342 | for (i = 0; i < CONFIGURE_MAXIMUM_PARTITIONS; ++i) { |
---|
| 343 | sc = rtems_partition_create( |
---|
| 344 | name, |
---|
| 345 | partition_areas + i, |
---|
| 346 | sizeof(partition_areas [0]), |
---|
| 347 | sizeof(partition_areas [0]), |
---|
| 348 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 349 | &id |
---|
| 350 | ); |
---|
| 351 | directive_failed(sc, "rtems_partition_create"); |
---|
| 352 | } |
---|
[c5d2760] | 353 | rtems_resource_snapshot_take(&snapshot); |
---|
| 354 | rtems_test_assert( |
---|
| 355 | snapshot.rtems_api.active_partitions == CONFIGURE_MAXIMUM_PARTITIONS |
---|
| 356 | ); |
---|
[73699608] | 357 | #endif |
---|
[b6c5fe0] | 358 | |
---|
[73699608] | 359 | #ifdef CONFIGURE_MAXIMUM_PERIODS |
---|
[b6c5fe0] | 360 | for (i = 0; i < CONFIGURE_MAXIMUM_PERIODS; ++i) { |
---|
| 361 | sc = rtems_rate_monotonic_create(name, &id); |
---|
| 362 | directive_failed(sc, "rtems_rate_monotonic_create"); |
---|
| 363 | } |
---|
[c5d2760] | 364 | rtems_resource_snapshot_take(&snapshot); |
---|
| 365 | rtems_test_assert( |
---|
| 366 | snapshot.rtems_api.active_periods == CONFIGURE_MAXIMUM_PERIODS |
---|
| 367 | ); |
---|
[73699608] | 368 | #endif |
---|
[b6c5fe0] | 369 | |
---|
[73699608] | 370 | #ifdef CONFIGURE_MAXIMUM_REGIONS |
---|
[b6c5fe0] | 371 | for (i = 0; i < CONFIGURE_MAXIMUM_REGIONS; ++i) { |
---|
| 372 | sc = rtems_region_create( |
---|
| 373 | name, |
---|
| 374 | region_areas + i, |
---|
| 375 | sizeof(region_areas [0]), |
---|
| 376 | 1, |
---|
| 377 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 378 | &id |
---|
| 379 | ); |
---|
| 380 | directive_failed(sc, "rtems_region_create"); |
---|
| 381 | } |
---|
[c5d2760] | 382 | rtems_resource_snapshot_take(&snapshot); |
---|
| 383 | rtems_test_assert( |
---|
| 384 | snapshot.rtems_api.active_regions == CONFIGURE_MAXIMUM_REGIONS |
---|
| 385 | ); |
---|
[73699608] | 386 | #endif |
---|
[b6c5fe0] | 387 | |
---|
[73699608] | 388 | #ifdef CONFIGURE_MAXIMUM_SEMAPHORES |
---|
[b6c5fe0] | 389 | for (i = 0; i < CONFIGURE_MAXIMUM_SEMAPHORES; ++i) { |
---|
| 390 | sc = rtems_semaphore_create( |
---|
| 391 | name, |
---|
| 392 | 0, |
---|
| 393 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 394 | 0, |
---|
| 395 | &id |
---|
| 396 | ); |
---|
| 397 | directive_failed(sc, "rtems_semaphore_create"); |
---|
| 398 | } |
---|
[c5d2760] | 399 | rtems_resource_snapshot_take(&snapshot); |
---|
| 400 | rtems_test_assert( |
---|
| 401 | snapshot.rtems_api.active_semaphores >= CONFIGURE_MAXIMUM_SEMAPHORES |
---|
| 402 | ); |
---|
[73699608] | 403 | #endif |
---|
[b6c5fe0] | 404 | |
---|
[73699608] | 405 | #ifdef CONFIGURE_MAXIMUM_TASKS |
---|
| 406 | for (i = 1; i < CONFIGURE_MAXIMUM_TASKS; ++i) { |
---|
[b6c5fe0] | 407 | sc = rtems_task_create( |
---|
| 408 | name, |
---|
| 409 | RTEMS_MINIMUM_PRIORITY, |
---|
| 410 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 411 | RTEMS_DEFAULT_MODES, |
---|
[03cc73a] | 412 | RTEMS_LOCAL | RTEMS_FLOATING_POINT, |
---|
[b6c5fe0] | 413 | &id |
---|
| 414 | ); |
---|
| 415 | directive_failed(sc, "rtems_task_create"); |
---|
| 416 | } |
---|
[c5d2760] | 417 | rtems_resource_snapshot_take(&snapshot); |
---|
| 418 | rtems_test_assert( |
---|
| 419 | snapshot.rtems_api.active_tasks == CONFIGURE_MAXIMUM_TASKS |
---|
| 420 | ); |
---|
[73699608] | 421 | #endif |
---|
[b6c5fe0] | 422 | |
---|
[73699608] | 423 | #ifdef CONFIGURE_MAXIMUM_TIMERS |
---|
[b6c5fe0] | 424 | for (i = 0; i < CONFIGURE_MAXIMUM_TIMERS; ++i) { |
---|
| 425 | sc = rtems_timer_create(name, &id); |
---|
| 426 | directive_failed(sc, "rtems_timer_create"); |
---|
| 427 | } |
---|
[c5d2760] | 428 | rtems_resource_snapshot_take(&snapshot); |
---|
| 429 | rtems_test_assert( |
---|
| 430 | snapshot.rtems_api.active_timers == CONFIGURE_MAXIMUM_TIMERS |
---|
| 431 | ); |
---|
[73699608] | 432 | #endif |
---|
| 433 | |
---|
| 434 | #ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS |
---|
| 435 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_BARRIERS; ++i) { |
---|
| 436 | pthread_barrier_t barrier; |
---|
| 437 | eno = pthread_barrier_init(&barrier, NULL, 1); |
---|
| 438 | rtems_test_assert(eno == 0); |
---|
| 439 | } |
---|
[c5d2760] | 440 | rtems_resource_snapshot_take(&snapshot); |
---|
| 441 | rtems_test_assert( |
---|
| 442 | snapshot.posix_api.active_barriers == CONFIGURE_MAXIMUM_POSIX_BARRIERS |
---|
| 443 | ); |
---|
[73699608] | 444 | #endif |
---|
[b6c5fe0] | 445 | |
---|
[73699608] | 446 | #ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES |
---|
[b6c5fe0] | 447 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES; ++i) { |
---|
| 448 | pthread_cond_t cond; |
---|
| 449 | eno = pthread_cond_init(&cond, NULL); |
---|
| 450 | rtems_test_assert(eno == 0); |
---|
| 451 | } |
---|
[c5d2760] | 452 | rtems_resource_snapshot_take(&snapshot); |
---|
| 453 | rtems_test_assert( |
---|
| 454 | snapshot.posix_api.active_condition_variables |
---|
| 455 | == CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES |
---|
| 456 | ); |
---|
[73699608] | 457 | #endif |
---|
[b6c5fe0] | 458 | |
---|
[73699608] | 459 | #ifdef POSIX_MQ_COUNT |
---|
| 460 | for (i = 0; i < POSIX_MQ_COUNT; ++i) { |
---|
| 461 | int oflag = O_RDWR | O_CREAT | O_EXCL; |
---|
| 462 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
---|
| 463 | struct mq_attr attr = { |
---|
| 464 | .mq_maxmsg = posix_mq_counts [i], |
---|
| 465 | .mq_msgsize = posix_mq_sizes [i] |
---|
| 466 | }; |
---|
| 467 | char *path = get_posix_name('M', 'S', 'Q', i); |
---|
| 468 | mqd_t mq = mq_open(path, oflag, mode, &attr); |
---|
| 469 | rtems_test_assert(mq >= 0); |
---|
| 470 | } |
---|
[c5d2760] | 471 | rtems_resource_snapshot_take(&snapshot); |
---|
| 472 | rtems_test_assert( |
---|
| 473 | snapshot.posix_api.active_message_queues |
---|
| 474 | == CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES |
---|
| 475 | ); |
---|
[73699608] | 476 | #endif |
---|
[b6c5fe0] | 477 | |
---|
[73699608] | 478 | #ifdef CONFIGURE_MAXIMUM_POSIX_MUTEXES |
---|
[b6c5fe0] | 479 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MUTEXES; ++i) { |
---|
| 480 | pthread_mutex_t mutex; |
---|
| 481 | eno = pthread_mutex_init(&mutex, NULL); |
---|
| 482 | rtems_test_assert(eno == 0); |
---|
| 483 | } |
---|
[c5d2760] | 484 | rtems_resource_snapshot_take(&snapshot); |
---|
| 485 | rtems_test_assert( |
---|
[51f823c9] | 486 | snapshot.posix_api.active_mutexes == CONFIGURE_MAXIMUM_POSIX_MUTEXES |
---|
[c5d2760] | 487 | ); |
---|
[73699608] | 488 | #endif |
---|
| 489 | |
---|
| 490 | #ifdef CONFIGURE_MAXIMUM_POSIX_RWLOCKS |
---|
| 491 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_RWLOCKS; ++i) { |
---|
| 492 | pthread_rwlock_t rwlock; |
---|
| 493 | eno = pthread_rwlock_init(&rwlock, NULL); |
---|
| 494 | rtems_test_assert(eno == 0); |
---|
| 495 | } |
---|
[c5d2760] | 496 | rtems_resource_snapshot_take(&snapshot); |
---|
| 497 | rtems_test_assert( |
---|
| 498 | snapshot.posix_api.active_rwlocks == CONFIGURE_MAXIMUM_POSIX_RWLOCKS |
---|
| 499 | ); |
---|
[73699608] | 500 | #endif |
---|
| 501 | |
---|
| 502 | #ifdef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES |
---|
| 503 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_SEMAPHORES; ++i) { |
---|
| 504 | int oflag = O_RDWR | O_CREAT | O_EXCL; |
---|
| 505 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
---|
| 506 | unsigned int value = 0; |
---|
| 507 | char *path = get_posix_name('S', 'E', 'M', i); |
---|
| 508 | sem_t *sem = sem_open(path, oflag, mode, value); |
---|
| 509 | rtems_test_assert(sem != SEM_FAILED); |
---|
| 510 | } |
---|
[c5d2760] | 511 | rtems_resource_snapshot_take(&snapshot); |
---|
| 512 | rtems_test_assert( |
---|
| 513 | snapshot.posix_api.active_semaphores == CONFIGURE_MAXIMUM_POSIX_SEMAPHORES |
---|
| 514 | ); |
---|
[73699608] | 515 | #endif |
---|
| 516 | |
---|
| 517 | #ifdef CONFIGURE_MAXIMUM_POSIX_THREADS |
---|
[b6c5fe0] | 518 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_THREADS; ++i) { |
---|
| 519 | pthread_t thread; |
---|
| 520 | eno = pthread_create(&thread, NULL, posix_thread, NULL); |
---|
| 521 | rtems_test_assert(eno == 0); |
---|
| 522 | } |
---|
[c5d2760] | 523 | rtems_resource_snapshot_take(&snapshot); |
---|
| 524 | rtems_test_assert( |
---|
| 525 | snapshot.posix_api.active_threads == CONFIGURE_MAXIMUM_POSIX_THREADS |
---|
| 526 | ); |
---|
[73699608] | 527 | #endif |
---|
| 528 | |
---|
| 529 | #ifdef CONFIGURE_MAXIMUM_POSIX_TIMERS |
---|
| 530 | for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_TIMERS; ++i) { |
---|
| 531 | timer_t timer_id; |
---|
| 532 | rv = timer_create(CLOCK_REALTIME, NULL, &timer_id); |
---|
| 533 | rtems_test_assert(rv == 0); |
---|
| 534 | } |
---|
[c5d2760] | 535 | rtems_resource_snapshot_take(&snapshot); |
---|
| 536 | rtems_test_assert( |
---|
| 537 | snapshot.posix_api.active_timers == CONFIGURE_MAXIMUM_POSIX_TIMERS |
---|
| 538 | ); |
---|
[73699608] | 539 | #endif |
---|
[b6c5fe0] | 540 | |
---|
| 541 | printf("object creation done\n"); |
---|
| 542 | print_info(); |
---|
| 543 | |
---|
[698c2e50] | 544 | TEST_END(); |
---|
[b6c5fe0] | 545 | |
---|
| 546 | rtems_test_exit(0); |
---|
| 547 | } |
---|