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

@@ -37,21 +37,21 @@ TEST_BEGIN(test_base_hooks_default) {
if (config_stats) {
base_stats_get(tsdn, base, &allocated0, &resident, &mapped,
&n_thp);
assert_zu_ge(allocated0, sizeof(base_t),
expect_zu_ge(allocated0, sizeof(base_t),
"Base header should count as allocated");
if (opt_metadata_thp == metadata_thp_always) {
assert_zu_gt(n_thp, 0,
expect_zu_gt(n_thp, 0,
"Base should have 1 THP at least.");
}
}
assert_ptr_not_null(base_alloc(tsdn, base, 42, 1),
expect_ptr_not_null(base_alloc(tsdn, base, 42, 1),
"Unexpected base_alloc() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated1, &resident, &mapped,
&n_thp);
assert_zu_ge(allocated1 - allocated0, 42,
expect_zu_ge(allocated1 - allocated0, 42,
"At least 42 bytes were allocated by base_alloc()");
}
@@ -75,26 +75,26 @@ TEST_BEGIN(test_base_hooks_null) {
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
base = base_new(tsdn, 0, &hooks);
assert_ptr_not_null(base, "Unexpected base_new() failure");
expect_ptr_not_null(base, "Unexpected base_new() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated0, &resident, &mapped,
&n_thp);
assert_zu_ge(allocated0, sizeof(base_t),
expect_zu_ge(allocated0, sizeof(base_t),
"Base header should count as allocated");
if (opt_metadata_thp == metadata_thp_always) {
assert_zu_gt(n_thp, 0,
expect_zu_gt(n_thp, 0,
"Base should have 1 THP at least.");
}
}
assert_ptr_not_null(base_alloc(tsdn, base, 42, 1),
expect_ptr_not_null(base_alloc(tsdn, base, 42, 1),
"Unexpected base_alloc() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated1, &resident, &mapped,
&n_thp);
assert_zu_ge(allocated1 - allocated0, 42,
expect_zu_ge(allocated1 - allocated0, 42,
"At least 42 bytes were allocated by base_alloc()");
}
@@ -121,8 +121,8 @@ TEST_BEGIN(test_base_hooks_not_null) {
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
did_alloc = false;
base = base_new(tsdn, 0, &hooks);
assert_ptr_not_null(base, "Unexpected base_new() failure");
assert_true(did_alloc, "Expected alloc");
expect_ptr_not_null(base, "Unexpected base_new() failure");
expect_true(did_alloc, "Expected alloc");
/*
* Check for tight packing at specified alignment under simple
@@ -143,21 +143,21 @@ TEST_BEGIN(test_base_hooks_not_null) {
size_t align_ceil = ALIGNMENT_CEILING(alignment,
QUANTUM);
p = base_alloc(tsdn, base, 1, alignment);
assert_ptr_not_null(p,
expect_ptr_not_null(p,
"Unexpected base_alloc() failure");
assert_ptr_eq(p,
expect_ptr_eq(p,
(void *)(ALIGNMENT_CEILING((uintptr_t)p,
alignment)), "Expected quantum alignment");
q = base_alloc(tsdn, base, alignment, alignment);
assert_ptr_not_null(q,
expect_ptr_not_null(q,
"Unexpected base_alloc() failure");
assert_ptr_eq((void *)((uintptr_t)p + align_ceil), q,
expect_ptr_eq((void *)((uintptr_t)p + align_ceil), q,
"Minimal allocation should take up %zu bytes",
align_ceil);
r = base_alloc(tsdn, base, 1, alignment);
assert_ptr_not_null(r,
expect_ptr_not_null(r,
"Unexpected base_alloc() failure");
assert_ptr_eq((void *)((uintptr_t)q + align_ceil), r,
expect_ptr_eq((void *)((uintptr_t)q + align_ceil), r,
"Minimal allocation should take up %zu bytes",
align_ceil);
}
@@ -168,23 +168,23 @@ TEST_BEGIN(test_base_hooks_not_null) {
* that the first block's remaining space is considered for subsequent
* allocation.
*/
assert_zu_ge(edata_bsize_get(&base->blocks->edata), QUANTUM,
expect_zu_ge(edata_bsize_get(&base->blocks->edata), QUANTUM,
"Remainder insufficient for test");
/* Use up all but one quantum of block. */
while (edata_bsize_get(&base->blocks->edata) > QUANTUM) {
p = base_alloc(tsdn, base, QUANTUM, QUANTUM);
assert_ptr_not_null(p, "Unexpected base_alloc() failure");
expect_ptr_not_null(p, "Unexpected base_alloc() failure");
}
r_exp = edata_addr_get(&base->blocks->edata);
assert_zu_eq(base->extent_sn_next, 1, "One extant block expected");
expect_zu_eq(base->extent_sn_next, 1, "One extant block expected");
q = base_alloc(tsdn, base, QUANTUM + 1, QUANTUM);
assert_ptr_not_null(q, "Unexpected base_alloc() failure");
assert_ptr_ne(q, r_exp, "Expected allocation from new block");
assert_zu_eq(base->extent_sn_next, 2, "Two extant blocks expected");
expect_ptr_not_null(q, "Unexpected base_alloc() failure");
expect_ptr_ne(q, r_exp, "Expected allocation from new block");
expect_zu_eq(base->extent_sn_next, 2, "Two extant blocks expected");
r = base_alloc(tsdn, base, QUANTUM, QUANTUM);
assert_ptr_not_null(r, "Unexpected base_alloc() failure");
assert_ptr_eq(r, r_exp, "Expected allocation from first block");
assert_zu_eq(base->extent_sn_next, 2, "Two extant blocks expected");
expect_ptr_not_null(r, "Unexpected base_alloc() failure");
expect_ptr_eq(r, r_exp, "Expected allocation from first block");
expect_zu_eq(base->extent_sn_next, 2, "Two extant blocks expected");
/*
* Check for proper alignment support when normal blocks are too small.
@@ -199,9 +199,9 @@ TEST_BEGIN(test_base_hooks_not_null) {
for (i = 0; i < sizeof(alignments) / sizeof(size_t); i++) {
size_t alignment = alignments[i];
p = base_alloc(tsdn, base, QUANTUM, alignment);
assert_ptr_not_null(p,
expect_ptr_not_null(p,
"Unexpected base_alloc() failure");
assert_ptr_eq(p,
expect_ptr_eq(p,
(void *)(ALIGNMENT_CEILING((uintptr_t)p,
alignment)), "Expected %zu-byte alignment",
alignment);
@@ -211,11 +211,11 @@ TEST_BEGIN(test_base_hooks_not_null) {
called_dalloc = called_destroy = called_decommit = called_purge_lazy =
called_purge_forced = false;
base_delete(tsdn, base);
assert_true(called_dalloc, "Expected dalloc call");
assert_true(!called_destroy, "Unexpected destroy call");
assert_true(called_decommit, "Expected decommit call");
assert_true(called_purge_lazy, "Expected purge_lazy call");
assert_true(called_purge_forced, "Expected purge_forced call");
expect_true(called_dalloc, "Expected dalloc call");
expect_true(!called_destroy, "Unexpected destroy call");
expect_true(called_decommit, "Expected decommit call");
expect_true(called_purge_lazy, "Expected purge_lazy call");
expect_true(called_purge_forced, "Expected purge_forced call");
try_dalloc = true;
try_destroy = true;