Changeset 4a8c334 in rtems


Ignore:
Timestamp:
Sep 3, 2013, 9:06:46 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
03e097b7
Parents:
3bac8a4c
git-author:
Sebastian Huber <sebastian.huber@…> (09/03/13 09:06:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/03/13 09:07:37)
Message:

smptests/smpatomic08: Add initialization test case

Location:
testsuites/smptests/smpatomic08
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/smpatomic08/init.c

    r3bac8a4c r4a8c334  
    1919#include <rtems/score/atomic.h>
    2020#include <rtems.h>
     21#include <string.h>
    2122
    2223#include "tmacros.h"
     
    379380}
    380381
     382static void test_static_and_dynamic_initialization(void)
     383{
     384  static Atomic_Ulong static_ulong =
     385    ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
     386  static Atomic_Pointer static_ptr =
     387    ATOMIC_INITIALIZER_PTR(&static_ptr);
     388  static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
     389
     390  Atomic_Ulong stack_ulong;
     391  Atomic_Pointer stack_ptr;
     392  Atomic_Flag stack_flag;
     393
     394  puts("=== static and dynamic initialization test case ===");
     395
     396  _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
     397  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
     398  _Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);
     399
     400  rtems_test_assert(
     401    memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
     402  );
     403  rtems_test_assert(
     404    memcmp(&stack_ptr, &static_ptr, sizeof(stack_ptr)) == 0
     405  );
     406  rtems_test_assert(
     407    memcmp(&stack_flag, &static_flag, sizeof(stack_flag)) == 0
     408  );
     409
     410  rtems_test_assert(
     411    _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
     412  );
     413  rtems_test_assert(
     414    _Atomic_Load_ptr(&stack_ptr, ATOMIC_ORDER_RELAXED) == &static_ptr
     415  );
     416  rtems_test_assert(
     417    !_Atomic_Flag_test_and_set(&stack_flag, ATOMIC_ORDER_RELAXED)
     418  );
     419}
     420
    381421static void test(void)
    382422{
     
    384424  rtems_status_code sc;
    385425  size_t worker_index;
     426
     427  test_static_and_dynamic_initialization();
    386428
    387429  ctx->worker_count = rtems_smp_get_processor_count();
  • testsuites/smptests/smpatomic08/smpatomic08.scn

    r3bac8a4c r4a8c334  
    11*** TEST SMPATOMIC 8 ***
     2=== static and dynamic initialization test case ===
    23=== atomic add test case ==
    34worker 0 value: 16686
Note: See TracChangeset for help on using the changeset viewer.