Changeset fee154be in rtems
 Timestamp:
 Sep 28, 2013, 6:54:36 AM (7 years ago)
 Branches:
 4.11, 5, master
 Children:
 27a034ef
 Parents:
 382f714
 gitauthor:
 WeiY <wei.a.yang@…> (09/28/13 06:54:36)
 gitcommitter:
 Sebastian Huber <sebastian.huber@…> (10/08/13 14:06:59)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

testsuites/smptests/smpatomic08/init.c
r382f714 rfee154be 7 7 * Germany 8 8 * <rtems@embeddedbrains.de> 9 * 10 * Copyright (c) 2013 Deng Hengyi. 9 11 * 10 12 * The license and distribution terms for this file may be … … 455 457 } 456 458 459 typedef void (*simple_test_body)(test_context *ctx); 460 461 static void test_simple_atomic_add_body(test_context *ctx) 462 { 463 unsigned long a = 2, b = 1; 464 unsigned long c; 465 466 puts("=== atomic simple add test case ==\n"); 467 468 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 469 _Atomic_Fetch_add_ulong(&ctx>atomic_value, b, ATOMIC_ORDER_RELAXED); 470 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 471 rtems_test_assert(c == (a + b)); 472 } 473 474 static void test_simple_atomic_sub_body(test_context *ctx) 475 { 476 unsigned long a = 2, b = 1; 477 unsigned long c; 478 479 puts("=== atomic simple sub test case ==\n"); 480 481 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 482 _Atomic_Fetch_sub_ulong(&ctx>atomic_value, b, ATOMIC_ORDER_RELAXED); 483 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 484 rtems_test_assert(c == (a  b)); 485 } 486 487 static void test_simple_atomic_or_body(test_context *ctx) 488 { 489 unsigned long a = 2, b = 1; 490 unsigned long c; 491 492 puts("=== atomic simple or test case ==\n"); 493 494 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 495 _Atomic_Fetch_or_ulong(&ctx>atomic_value, b, ATOMIC_ORDER_RELAXED); 496 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 497 rtems_test_assert(c == (a  b)); 498 } 499 500 static void test_simple_atomic_and_body(test_context *ctx) 501 { 502 unsigned long a = 2, b = 1; 503 unsigned long c; 504 505 puts("=== atomic simple and test case ==\n"); 506 507 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 508 _Atomic_Fetch_and_ulong(&ctx>atomic_value, b, ATOMIC_ORDER_RELAXED); 509 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 510 rtems_test_assert(c == (a & b)); 511 } 512 513 static void test_simple_atomic_exchange_body(test_context *ctx) 514 { 515 unsigned long a = 2, b = 1; 516 unsigned long c; 517 518 puts("=== atomic simple exchange test case ==\n"); 519 520 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 521 _Atomic_Exchange_ulong(&ctx>atomic_value, b, ATOMIC_ORDER_RELAXED); 522 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 523 rtems_test_assert(c == b); 524 } 525 526 static void test_simple_atomic_compare_exchange_body(test_context *ctx) 527 { 528 unsigned long a = 2, b = 1; 529 unsigned long c; 530 531 puts("=== atomic simple compare exchange test case ==\n"); 532 533 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); 534 _Atomic_Compare_exchange_ulong(&ctx>atomic_value, &a, b, 535 ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED); 536 c = _Atomic_Load_ulong(&ctx>atomic_value, ATOMIC_ORDER_RELAXED); 537 rtems_test_assert(c == b); 538 } 539 540 static const simple_test_body simple_test_bodies[] = { 541 test_simple_atomic_add_body, 542 test_simple_atomic_sub_body, 543 test_simple_atomic_or_body, 544 test_simple_atomic_and_body, 545 test_simple_atomic_exchange_body, 546 test_simple_atomic_compare_exchange_body, 547 }; 548 549 #define SIMPLE_TEST_COUNT RTEMS_ARRAY_SIZE(simple_test_bodies) 550 551 static void simple_tests(void) 552 { 553 test_context *ctx = &test_instance; 554 size_t test; 555 556 for (test = 0; test < SIMPLE_TEST_COUNT; ++test) { 557 const simple_test_body *test_body = &simple_test_bodies[test]; 558 559 (*test_body)(ctx); 560 } 561 } 562 457 563 static void Init(rtems_task_argument arg) 458 564 { 459 565 puts("\n\n*** TEST SMPATOMIC 8 ***"); 566 567 simple_tests(); 460 568 461 569 test();
Note: See TracChangeset
for help on using the changeset viewer.