mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Change assert_* to expect_* in tests
```
grep -Irl assert_ test/ | xargs sed -i \
's/witness_assert/witness_do_not_replace/g';
grep -Irl assert_ test/ | xargs sed -i \
's/malloc_mutex_assert_owner/malloc_mutex_do_not_replace_owner/g';
grep -Ir assert_ test/ | grep -o "[_a-zA-Z]*assert_[_a-zA-Z]*" | \
grep -v "^assert_"; # confirm no output
grep -Irl assert_ test/ | xargs sed -i 's/assert_/expect_/g';
grep -Irl witness_do_not_replace test/ | xargs sed -i \
's/witness_do_not_replace/witness_assert/g';
grep -Irl malloc_mutex_do_not_replace_owner test/ | xargs sed -i \
's/malloc_mutex_do_not_replace_owner/malloc_mutex_assert_owner/g';
```
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* some places and "ptr" in others. In the long run it would be nice to unify
|
||||
* these, but in the short run we'll use this shim.
|
||||
*/
|
||||
#define assert_p_eq assert_ptr_eq
|
||||
#define expect_p_eq expect_ptr_eq
|
||||
|
||||
/*
|
||||
* t: the non-atomic type, like "uint32_t".
|
||||
@@ -24,20 +24,20 @@
|
||||
\
|
||||
/* ATOMIC_INIT and load. */ \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, "Load or init failed"); \
|
||||
expect_##ta##_eq(val1, val, "Load or init failed"); \
|
||||
\
|
||||
/* Store. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
atomic_store_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val2, val, "Store failed"); \
|
||||
expect_##ta##_eq(val2, val, "Store failed"); \
|
||||
\
|
||||
/* Exchange. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_exchange_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, "Exchange returned invalid value"); \
|
||||
expect_##ta##_eq(val1, val, "Exchange returned invalid value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val2, val, "Exchange store invalid value"); \
|
||||
expect_##ta##_eq(val2, val, "Exchange store invalid value"); \
|
||||
\
|
||||
/* \
|
||||
* Weak CAS. Spurious failures are allowed, so we loop a few \
|
||||
@@ -49,17 +49,17 @@
|
||||
expected = val2; \
|
||||
success = atomic_compare_exchange_weak_##ta(&atom, \
|
||||
&expected, val3, ATOMIC_RELAXED, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, expected, \
|
||||
expect_##ta##_eq(val1, expected, \
|
||||
"CAS should update expected"); \
|
||||
} \
|
||||
assert_b_eq(val1 == val2, success, \
|
||||
expect_b_eq(val1 == val2, success, \
|
||||
"Weak CAS did the wrong state update"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
if (success) { \
|
||||
assert_##ta##_eq(val3, val, \
|
||||
expect_##ta##_eq(val3, val, \
|
||||
"Successful CAS should update atomic"); \
|
||||
} else { \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Unsuccessful CAS should not update atomic"); \
|
||||
} \
|
||||
\
|
||||
@@ -68,14 +68,14 @@
|
||||
expected = val2; \
|
||||
success = atomic_compare_exchange_strong_##ta(&atom, &expected, \
|
||||
val3, ATOMIC_RELAXED, ATOMIC_RELAXED); \
|
||||
assert_b_eq(val1 == val2, success, \
|
||||
expect_b_eq(val1 == val2, success, \
|
||||
"Strong CAS did the wrong state update"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
if (success) { \
|
||||
assert_##ta##_eq(val3, val, \
|
||||
expect_##ta##_eq(val3, val, \
|
||||
"Successful CAS should update atomic"); \
|
||||
} else { \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Unsuccessful CAS should not update atomic"); \
|
||||
} \
|
||||
\
|
||||
@@ -89,46 +89,46 @@
|
||||
/* Fetch-add. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_fetch_add_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Fetch-add should return previous value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1 + val2, val, \
|
||||
expect_##ta##_eq(val1 + val2, val, \
|
||||
"Fetch-add should update atomic"); \
|
||||
\
|
||||
/* Fetch-sub. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_fetch_sub_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Fetch-sub should return previous value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1 - val2, val, \
|
||||
expect_##ta##_eq(val1 - val2, val, \
|
||||
"Fetch-sub should update atomic"); \
|
||||
\
|
||||
/* Fetch-and. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_fetch_and_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Fetch-and should return previous value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1 & val2, val, \
|
||||
expect_##ta##_eq(val1 & val2, val, \
|
||||
"Fetch-and should update atomic"); \
|
||||
\
|
||||
/* Fetch-or. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_fetch_or_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Fetch-or should return previous value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1 | val2, val, \
|
||||
expect_##ta##_eq(val1 | val2, val, \
|
||||
"Fetch-or should update atomic"); \
|
||||
\
|
||||
/* Fetch-xor. */ \
|
||||
atomic_store_##ta(&atom, val1, ATOMIC_RELAXED); \
|
||||
val = atomic_fetch_xor_##ta(&atom, val2, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1, val, \
|
||||
expect_##ta##_eq(val1, val, \
|
||||
"Fetch-xor should return previous value"); \
|
||||
val = atomic_load_##ta(&atom, ATOMIC_RELAXED); \
|
||||
assert_##ta##_eq(val1 ^ val2, val, \
|
||||
expect_##ta##_eq(val1 ^ val2, val, \
|
||||
"Fetch-xor should update atomic"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user