Rev 1787 | Rev 2020 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1787 | Rev 2019 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #include <test.h> |
29 | #include <test.h> |
30 | #include <print.h> |
30 | #include <print.h> |
31 | #include <atomic.h> |
31 | #include <atomic.h> |
32 | #include <debug.h> |
32 | #include <debug.h> |
33 | 33 | ||
- | 34 | #ifdef CONFIG_BENCH |
|
- | 35 | #include <arch/cycle.h> |
|
- | 36 | #endif |
|
- | 37 | ||
34 | void test(void) |
38 | void test_atomic1(void) |
35 | { |
39 | { |
- | 40 | #ifdef CONFIG_BENCH |
|
- | 41 | uint64_t t0 = get_cycle(); |
|
- | 42 | #endif |
|
36 | atomic_t a; |
43 | atomic_t a; |
37 | 44 | ||
38 | atomic_set(&a, 10); |
45 | atomic_set(&a, 10); |
39 | printf("Testing atomic_set() and atomic_get().\n"); |
46 | printf("Testing atomic_set() and atomic_get().\n"); |
40 | ASSERT(atomic_get(&a) == 10); |
47 | ASSERT(atomic_get(&a) == 10); |
Line 49... | Line 56... | ||
49 | ASSERT(atomic_get(&a) == 11); |
56 | ASSERT(atomic_get(&a) == 11); |
50 | printf("Testing atomic_predec()\n"); |
57 | printf("Testing atomic_predec()\n"); |
51 | ASSERT(atomic_postdec(&a) == 11); |
58 | ASSERT(atomic_postdec(&a) == 11); |
52 | ASSERT(atomic_get(&a) == 10); |
59 | ASSERT(atomic_get(&a) == 10); |
53 | 60 | ||
54 | printf("Test passed.\n"); |
61 | printf("Test passed.\n"); |
- | 62 | #ifdef CONFIG_BENCH |
|
- | 63 | uint64_t dt = get_cycle() - t0; |
|
- | 64 | printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt); |
|
- | 65 | #endif |
|
55 | return; |
66 | return; |
56 | } |
67 | } |