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,11 +6,11 @@ TEST_BEGIN(test_new_delete) {
|
||||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash,
|
||||
expect_false(ckh_new(tsd, &ckh, 2, ckh_string_hash,
|
||||
ckh_string_keycomp), "Unexpected ckh_new() error");
|
||||
ckh_delete(tsd, &ckh);
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 3, ckh_pointer_hash,
|
||||
expect_false(ckh_new(tsd, &ckh, 3, ckh_pointer_hash,
|
||||
ckh_pointer_keycomp), "Unexpected ckh_new() error");
|
||||
ckh_delete(tsd, &ckh);
|
||||
}
|
||||
@@ -30,16 +30,16 @@ TEST_BEGIN(test_count_insert_search_remove) {
|
||||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash,
|
||||
expect_false(ckh_new(tsd, &ckh, 2, ckh_string_hash,
|
||||
ckh_string_keycomp), "Unexpected ckh_new() error");
|
||||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
expect_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %zu, but it returned %zu", ZU(0),
|
||||
ckh_count(&ckh));
|
||||
|
||||
/* Insert. */
|
||||
for (i = 0; i < sizeof(strs)/sizeof(const char *); i++) {
|
||||
ckh_insert(tsd, &ckh, strs[i], strs[i]);
|
||||
assert_zu_eq(ckh_count(&ckh), i+1,
|
||||
expect_zu_eq(ckh_count(&ckh), i+1,
|
||||
"ckh_count() should return %zu, but it returned %zu", i+1,
|
||||
ckh_count(&ckh));
|
||||
}
|
||||
@@ -57,17 +57,17 @@ TEST_BEGIN(test_count_insert_search_remove) {
|
||||
vp = (i & 2) ? &v.p : NULL;
|
||||
k.p = NULL;
|
||||
v.p = NULL;
|
||||
assert_false(ckh_search(&ckh, strs[i], kp, vp),
|
||||
expect_false(ckh_search(&ckh, strs[i], kp, vp),
|
||||
"Unexpected ckh_search() error");
|
||||
|
||||
ks = (i & 1) ? strs[i] : (const char *)NULL;
|
||||
vs = (i & 2) ? strs[i] : (const char *)NULL;
|
||||
assert_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
expect_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
expect_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
i);
|
||||
}
|
||||
assert_true(ckh_search(&ckh, missing, NULL, NULL),
|
||||
expect_true(ckh_search(&ckh, missing, NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
|
||||
/* Remove. */
|
||||
@@ -83,16 +83,16 @@ TEST_BEGIN(test_count_insert_search_remove) {
|
||||
vp = (i & 2) ? &v.p : NULL;
|
||||
k.p = NULL;
|
||||
v.p = NULL;
|
||||
assert_false(ckh_remove(tsd, &ckh, strs[i], kp, vp),
|
||||
expect_false(ckh_remove(tsd, &ckh, strs[i], kp, vp),
|
||||
"Unexpected ckh_remove() error");
|
||||
|
||||
ks = (i & 1) ? strs[i] : (const char *)NULL;
|
||||
vs = (i & 2) ? strs[i] : (const char *)NULL;
|
||||
assert_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
expect_ptr_eq((void *)ks, (void *)k.s, "Key mismatch, i=%zu",
|
||||
i);
|
||||
assert_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
expect_ptr_eq((void *)vs, (void *)v.s, "Value mismatch, i=%zu",
|
||||
i);
|
||||
assert_zu_eq(ckh_count(&ckh),
|
||||
expect_zu_eq(ckh_count(&ckh),
|
||||
sizeof(strs)/sizeof(const char *) - i - 1,
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
sizeof(strs)/sizeof(const char *) - i - 1,
|
||||
@@ -113,40 +113,40 @@ TEST_BEGIN(test_insert_iter_remove) {
|
||||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_pointer_hash,
|
||||
expect_false(ckh_new(tsd, &ckh, 2, ckh_pointer_hash,
|
||||
ckh_pointer_keycomp), "Unexpected ckh_new() error");
|
||||
|
||||
for (i = 0; i < NITEMS; i++) {
|
||||
p[i] = mallocx(i+1, 0);
|
||||
assert_ptr_not_null(p[i], "Unexpected mallocx() failure");
|
||||
expect_ptr_not_null(p[i], "Unexpected mallocx() failure");
|
||||
}
|
||||
|
||||
for (i = 0; i < NITEMS; i++) {
|
||||
size_t j;
|
||||
|
||||
for (j = i; j < NITEMS; j++) {
|
||||
assert_false(ckh_insert(tsd, &ckh, p[j], p[j]),
|
||||
expect_false(ckh_insert(tsd, &ckh, p[j], p[j]),
|
||||
"Unexpected ckh_insert() failure");
|
||||
assert_false(ckh_search(&ckh, p[j], &q, &r),
|
||||
expect_false(ckh_search(&ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_search() failure");
|
||||
assert_ptr_eq(p[j], q, "Key pointer mismatch");
|
||||
assert_ptr_eq(p[j], r, "Value pointer mismatch");
|
||||
expect_ptr_eq(p[j], q, "Key pointer mismatch");
|
||||
expect_ptr_eq(p[j], r, "Value pointer mismatch");
|
||||
}
|
||||
|
||||
assert_zu_eq(ckh_count(&ckh), NITEMS,
|
||||
expect_zu_eq(ckh_count(&ckh), NITEMS,
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
NITEMS, ckh_count(&ckh));
|
||||
|
||||
for (j = i + 1; j < NITEMS; j++) {
|
||||
assert_false(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
expect_false(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
"Unexpected ckh_search() failure");
|
||||
assert_false(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
expect_false(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_remove() failure");
|
||||
assert_ptr_eq(p[j], q, "Key pointer mismatch");
|
||||
assert_ptr_eq(p[j], r, "Value pointer mismatch");
|
||||
assert_true(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
expect_ptr_eq(p[j], q, "Key pointer mismatch");
|
||||
expect_ptr_eq(p[j], r, "Value pointer mismatch");
|
||||
expect_true(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
assert_true(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
expect_true(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_remove() success");
|
||||
}
|
||||
|
||||
@@ -159,11 +159,11 @@ TEST_BEGIN(test_insert_iter_remove) {
|
||||
for (tabind = 0; !ckh_iter(&ckh, &tabind, &q, &r);) {
|
||||
size_t k;
|
||||
|
||||
assert_ptr_eq(q, r, "Key and val not equal");
|
||||
expect_ptr_eq(q, r, "Key and val not equal");
|
||||
|
||||
for (k = 0; k < NITEMS; k++) {
|
||||
if (p[k] == q) {
|
||||
assert_false(seen[k],
|
||||
expect_false(seen[k],
|
||||
"Item %zu already seen", k);
|
||||
seen[k] = true;
|
||||
break;
|
||||
@@ -172,29 +172,29 @@ TEST_BEGIN(test_insert_iter_remove) {
|
||||
}
|
||||
|
||||
for (j = 0; j < i + 1; j++) {
|
||||
assert_true(seen[j], "Item %zu not seen", j);
|
||||
expect_true(seen[j], "Item %zu not seen", j);
|
||||
}
|
||||
for (; j < NITEMS; j++) {
|
||||
assert_false(seen[j], "Item %zu seen", j);
|
||||
expect_false(seen[j], "Item %zu seen", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NITEMS; i++) {
|
||||
assert_false(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
expect_false(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
"Unexpected ckh_search() failure");
|
||||
assert_false(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
expect_false(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
"Unexpected ckh_remove() failure");
|
||||
assert_ptr_eq(p[i], q, "Key pointer mismatch");
|
||||
assert_ptr_eq(p[i], r, "Value pointer mismatch");
|
||||
assert_true(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
expect_ptr_eq(p[i], q, "Key pointer mismatch");
|
||||
expect_ptr_eq(p[i], r, "Value pointer mismatch");
|
||||
expect_true(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
assert_true(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
expect_true(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
"Unexpected ckh_remove() success");
|
||||
dallocx(p[i], 0);
|
||||
}
|
||||
|
||||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
expect_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %zu, but it returned %zu",
|
||||
ZU(0), ckh_count(&ckh));
|
||||
ckh_delete(tsd, &ckh);
|
||||
|
||||
Reference in New Issue
Block a user