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:
Yinan Zhang
2020-02-18 14:39:06 -08:00
parent 162c2bcf31
commit 21dfa4300d
85 changed files with 1854 additions and 1854 deletions

View File

@@ -8,52 +8,52 @@ TEST_BEGIN(test_cache_bin) {
/* Page aligned to make sure lowbits not overflowable. */
void **stack = mallocx(PAGE, MALLOCX_TCACHE_NONE | MALLOCX_ALIGN(PAGE));
assert_ptr_not_null(stack, "Unexpected mallocx failure");
expect_ptr_not_null(stack, "Unexpected mallocx failure");
/* Initialize to empty; bin 0. */
cache_bin_sz_t ncached_max = cache_bin_ncached_max_get(0);
void **empty_position = stack + ncached_max;
bin->cur_ptr.ptr = empty_position;
bin->low_water_position = bin->cur_ptr.lowbits;
bin->full_position = (uint32_t)(uintptr_t)stack;
assert_ptr_eq(cache_bin_empty_position_get(bin, 0), empty_position,
expect_ptr_eq(cache_bin_empty_position_get(bin, 0), empty_position,
"Incorrect empty position");
/* Not using assert_zu etc on cache_bin_sz_t since it may change. */
assert_true(cache_bin_ncached_get(bin, 0) == 0, "Incorrect cache size");
/* Not using expect_zu etc on cache_bin_sz_t since it may change. */
expect_true(cache_bin_ncached_get(bin, 0) == 0, "Incorrect cache size");
bool success;
void *ret = cache_bin_alloc_easy(bin, &success, 0);
assert_false(success, "Empty cache bin should not alloc");
assert_true(cache_bin_low_water_get(bin, 0) == 0,
expect_false(success, "Empty cache bin should not alloc");
expect_true(cache_bin_low_water_get(bin, 0) == 0,
"Incorrect low water mark");
cache_bin_ncached_set(bin, 0, 0);
assert_ptr_eq(bin->cur_ptr.ptr, empty_position, "Bin should be empty");
expect_ptr_eq(bin->cur_ptr.ptr, empty_position, "Bin should be empty");
for (cache_bin_sz_t i = 1; i < ncached_max + 1; i++) {
success = cache_bin_dalloc_easy(bin, (void *)(uintptr_t)i);
assert_true(success && cache_bin_ncached_get(bin, 0) == i,
expect_true(success && cache_bin_ncached_get(bin, 0) == i,
"Bin dalloc failure");
}
success = cache_bin_dalloc_easy(bin, (void *)1);
assert_false(success, "Bin should be full");
assert_ptr_eq(bin->cur_ptr.ptr, stack, "Incorrect bin cur_ptr");
expect_false(success, "Bin should be full");
expect_ptr_eq(bin->cur_ptr.ptr, stack, "Incorrect bin cur_ptr");
cache_bin_ncached_set(bin, 0, ncached_max);
assert_ptr_eq(bin->cur_ptr.ptr, stack, "cur_ptr should not change");
expect_ptr_eq(bin->cur_ptr.ptr, stack, "cur_ptr should not change");
/* Emulate low water after refill. */
bin->low_water_position = bin->full_position;
for (cache_bin_sz_t i = ncached_max; i > 0; i--) {
ret = cache_bin_alloc_easy(bin, &success, 0);
cache_bin_sz_t ncached = cache_bin_ncached_get(bin, 0);
assert_true(success && ncached == i - 1,
expect_true(success && ncached == i - 1,
"Cache bin alloc failure");
assert_ptr_eq(ret, (void *)(uintptr_t)i, "Bin alloc failure");
assert_true(cache_bin_low_water_get(bin, 0) == ncached,
expect_ptr_eq(ret, (void *)(uintptr_t)i, "Bin alloc failure");
expect_true(cache_bin_low_water_get(bin, 0) == ncached,
"Incorrect low water mark");
}
ret = cache_bin_alloc_easy(bin, &success, 0);
assert_false(success, "Empty cache bin should not alloc.");
assert_ptr_eq(bin->cur_ptr.ptr, stack + ncached_max,
expect_false(success, "Empty cache bin should not alloc.");
expect_ptr_eq(bin->cur_ptr.ptr, stack + ncached_max,
"Bin should be empty");
}
TEST_END