diff options
author | Jose Fonseca <[email protected]> | 2015-02-13 09:46:44 +0000 |
---|---|---|
committer | Jose Fonseca <[email protected]> | 2015-02-13 19:39:27 +0000 |
commit | b09f25428ff5e908aefc03b8f9931599c3afd6d2 (patch) | |
tree | 7c3f8153216547cc7911c1e29f045186fcdd1aba | |
parent | e333035c47a6a4cc88f0f9ca2bced500538bebae (diff) |
uti/u_atomic: Don't test p_atomic_add with booleans.
Add another class of tests.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=89112
I failed to spot this in my previous change, because bool was a typedef
for char on the system I tested.
Reviewed-by: Roland Scheidegger <[email protected]>
-rw-r--r-- | src/util/u_atomic_test.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c index 8bddf8d1dea..939cfe44577 100644 --- a/src/util/u_atomic_test.c +++ b/src/util/u_atomic_test.c @@ -37,9 +37,9 @@ #include "u_atomic.h" -/* Test operations that are supported for all types, including 8 bits types */ -#define test_atomic_8bits(type, ones) \ - static void test_atomic_8bits_##type (void) { \ +/* Test only assignment-like operations, which are supported on all types */ +#define test_atomic_assign(type, ones) \ + static void test_atomic_assign_##type (void) { \ type v, r; \ \ p_atomic_set(&v, ones); \ @@ -56,6 +56,19 @@ assert(v == 0 && "p_atomic_cmpxchg"); \ assert(r == ones && "p_atomic_cmpxchg"); \ \ + (void) r; \ + } + + +/* Test arithmetic operations that are supported on 8 bits integer types */ +#define test_atomic_8bits(type, ones) \ + test_atomic_assign(type, ones) \ + \ + static void test_atomic_8bits_##type (void) { \ + type v, r; \ + \ + test_atomic_assign_##type(); \ + \ v = 23; \ p_atomic_add(&v, 42); \ r = p_atomic_read(&v); \ @@ -65,7 +78,7 @@ } -/* Test operations that are not supported for 8 bits types */ +/* Test all operations */ #define test_atomic(type, ones) \ test_atomic_8bits(type, ones) \ \ @@ -121,7 +134,7 @@ test_atomic(uint64_t, UINT64_C(0xffffffffffffffff)) test_atomic_8bits(int8_t, INT8_C(-1)) test_atomic_8bits(uint8_t, UINT8_C(0xff)) -test_atomic_8bits(bool, true) +test_atomic_assign(bool, true) int main() @@ -138,7 +151,7 @@ main() test_atomic_8bits_int8_t(); test_atomic_8bits_uint8_t(); - test_atomic_8bits_bool(); + test_atomic_assign_bool(); return 0; } |