Changeset f9126f6 in rtems
- Timestamp:
- 06/22/16 15:09:23 (7 years ago)
- Branches:
- 4.10
- Children:
- 95d5a0a9
- Parents:
- fc027be
- git-author:
- Sebastian Huber <sebastian.huber@…> (06/22/16 15:09:23)
- git-committer:
- Gedare Bloom <gedare@…> (03/23/18 15:33:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
testsuites/sptests/spmutex01/init.c
rfc027be rf9126f6 42 42 REQ_MTX_0_RELEASE = RTEMS_EVENT_3, 43 43 REQ_MTX_1_OBTAIN = RTEMS_EVENT_4, 44 REQ_MTX_1_RELEASE = RTEMS_EVENT_5, 45 REQ_MTX_2_OBTAIN = RTEMS_EVENT_6, 46 REQ_MTX_2_RELEASE = RTEMS_EVENT_7, 47 REQ_MTX_C11_OBTAIN = RTEMS_EVENT_8, 48 REQ_MTX_C11_RELEASE = RTEMS_EVENT_9, 49 REQ_MTX_POSIX_OBTAIN = RTEMS_EVENT_10, 50 REQ_MTX_POSIX_RELEASE = RTEMS_EVENT_11 44 REQ_MTX_1_OBTAIN_TIMEOUT = RTEMS_EVENT_5, 45 REQ_MTX_1_RELEASE = RTEMS_EVENT_6, 46 REQ_MTX_2_OBTAIN = RTEMS_EVENT_7, 47 REQ_MTX_2_RELEASE = RTEMS_EVENT_8, 48 REQ_MTX_C11_OBTAIN = RTEMS_EVENT_9, 49 REQ_MTX_C11_RELEASE = RTEMS_EVENT_10, 50 REQ_MTX_POSIX_OBTAIN = RTEMS_EVENT_11, 51 REQ_MTX_POSIX_RELEASE = RTEMS_EVENT_12 51 52 } request_id; 52 53 … … 111 112 } 112 113 114 static void wait(void) 115 { 116 rtems_status_code sc; 117 118 sc = rtems_task_wake_after(4); 119 rtems_test_assert(sc == RTEMS_SUCCESSFUL); 120 } 121 113 122 static rtems_event_set wait_for_events(void) 114 123 { … … 142 151 } 143 152 153 static void obtain_timeout(test_context *ctx, mutex_id id) 154 { 155 rtems_status_code sc; 156 157 sc = rtems_semaphore_obtain(ctx->mtx[id], RTEMS_WAIT, 2); 158 rtems_test_assert(sc == RTEMS_TIMEOUT); 159 } 160 144 161 static void obtain(test_context *ctx, mutex_id id) 145 162 { … … 250 267 } 251 268 269 static void change_prio( 270 test_context *ctx, 271 task_id id, 272 rtems_task_priority prio 273 ) 274 { 275 rtems_status_code sc; 276 277 sc = rtems_task_set_priority( 278 ctx->tasks[id], 279 prio, 280 &prio 281 ); 282 rtems_test_assert(sc == RTEMS_SUCCESSFUL); 283 } 284 252 285 static void helper(rtems_task_argument arg) 253 286 { … … 281 314 if ((events & REQ_MTX_1_OBTAIN) != 0) { 282 315 obtain(ctx, MTX_1); 316 ++ctx->generation[id]; 317 } 318 319 if ((events & REQ_MTX_1_OBTAIN_TIMEOUT) != 0) { 320 obtain_timeout(ctx, MTX_1); 283 321 ++ctx->generation[id]; 284 322 } … … 371 409 static void test_inherit(test_context *ctx) 372 410 { 411 assert_prio(ctx, M, 3); 373 412 obtain(ctx, MTX_0); 374 413 request(ctx, A_1, REQ_MTX_0_OBTAIN); 375 414 check_generations(ctx, NONE, NONE); 376 415 assert_prio(ctx, M, 1); 416 change_prio(ctx, A_1, 2); 417 assert_prio(ctx, M, 2); 418 change_prio(ctx, A_1, 3); 419 assert_prio(ctx, M, 3); 420 change_prio(ctx, A_1, 4); 421 assert_prio(ctx, M, 3); 422 change_prio(ctx, A_1, 1); 423 assert_prio(ctx, M, 1); 377 424 release(ctx, MTX_0); 378 425 check_generations(ctx, A_1, NONE); … … 384 431 static void test_inherit_fifo_for_equal_priority(test_context *ctx) 385 432 { 433 assert_prio(ctx, M, 3); 386 434 obtain(ctx, MTX_0); 387 435 request(ctx, A_2_0, REQ_MTX_0_OBTAIN); … … 402 450 } 403 451 452 static void test_inherit_nested_vertical(test_context *ctx) 453 { 454 assert_prio(ctx, M, 3); 455 obtain(ctx, MTX_0); 456 obtain(ctx, MTX_1); 457 request(ctx, A_1, REQ_MTX_1_OBTAIN); 458 check_generations(ctx, NONE, NONE); 459 assert_prio(ctx, M, 1); 460 release(ctx, MTX_1); 461 check_generations(ctx, A_1, NONE); 462 assert_prio(ctx, M, 3); 463 request(ctx, A_1, REQ_MTX_1_RELEASE); 464 check_generations(ctx, A_1, NONE); 465 release(ctx, MTX_0); 466 } 467 468 static void test_inherit_nested_vertical_timeout(test_context *ctx) 469 { 470 assert_prio(ctx, M, 3); 471 obtain(ctx, MTX_0); 472 obtain(ctx, MTX_1); 473 request(ctx, A_1, REQ_MTX_1_OBTAIN_TIMEOUT); 474 check_generations(ctx, NONE, NONE); 475 assert_prio(ctx, M, 1); 476 wait(); 477 check_generations(ctx, A_1, NONE); 478 assert_prio(ctx, M, 3); 479 release(ctx, MTX_1); 480 release(ctx, MTX_0); 481 } 482 483 static void test_inherit_nested_horizontal(test_context *ctx) 484 { 485 assert_prio(ctx, M, 3); 486 obtain(ctx, MTX_0); 487 request(ctx, A_2_0, REQ_MTX_1_OBTAIN); 488 check_generations(ctx, A_2_0, NONE); 489 request(ctx, A_2_0, REQ_MTX_0_OBTAIN); 490 check_generations(ctx, NONE, NONE); 491 assert_prio(ctx, M, 2); 492 request(ctx, A_1, REQ_MTX_1_OBTAIN_TIMEOUT); 493 check_generations(ctx, NONE, NONE); 494 assert_prio(ctx, A_2_0, 1); 495 assert_prio(ctx, M, 1); 496 wait(); 497 check_generations(ctx, A_1, NONE); 498 assert_prio(ctx, A_2_0, 2); 499 assert_prio(ctx, M, 2); 500 request(ctx, A_1, REQ_MTX_1_OBTAIN); 501 check_generations(ctx, NONE, NONE); 502 assert_prio(ctx, A_2_0, 1); 503 assert_prio(ctx, M, 1); 504 change_prio(ctx, A_1, 2); 505 assert_prio(ctx, M, 2); 506 change_prio(ctx, A_1, 3); 507 assert_prio(ctx, M, 2); 508 change_prio(ctx, A_2_0, 3); 509 assert_prio(ctx, M, 3); 510 change_prio(ctx, A_2_0, 2); 511 assert_prio(ctx, M, 2); 512 change_prio(ctx, A_1, 1); 513 assert_prio(ctx, M, 1); 514 release(ctx, MTX_0); 515 check_generations(ctx, A_2_0, NONE); 516 assert_prio(ctx, A_2_0, 1); 517 assert_prio(ctx, M, 3); 518 request(ctx, A_2_0, REQ_MTX_0_RELEASE); 519 check_generations(ctx, A_2_0, NONE); 520 assert_prio(ctx, A_2_0, 1); 521 request(ctx, A_2_0, REQ_MTX_1_RELEASE); 522 check_generations(ctx, A_1, A_2_0); 523 assert_prio(ctx, A_2_0, 2); 524 request(ctx, A_1, REQ_MTX_1_RELEASE); 525 check_generations(ctx, A_1, NONE); 526 } 527 404 528 static void test_deadlock_two_classic(test_context *ctx) 405 529 { … … 548 672 test_inherit(ctx); 549 673 test_inherit_fifo_for_equal_priority(ctx); 674 test_inherit_nested_vertical(ctx); 675 test_inherit_nested_vertical_timeout(ctx); 676 test_inherit_nested_horizontal(ctx); 550 677 test_deadlock_two_classic(ctx); 551 678 test_deadlock_three_classic(ctx);
Note: See TracChangeset
for help on using the changeset viewer.