mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +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 @@ get_nsizes_impl(const char *cmd) {
|
||||
size_t z;
|
||||
|
||||
z = sizeof(unsigned);
|
||||
assert_d_eq(mallctl(cmd, (void *)&ret, &z, NULL, 0), 0,
|
||||
expect_d_eq(mallctl(cmd, (void *)&ret, &z, NULL, 0), 0,
|
||||
"Unexpected mallctl(\"%s\", ...) failure", cmd);
|
||||
|
||||
return ret;
|
||||
@@ -25,11 +25,11 @@ get_size_impl(const char *cmd, size_t ind) {
|
||||
size_t miblen = 4;
|
||||
|
||||
z = sizeof(size_t);
|
||||
assert_d_eq(mallctlnametomib(cmd, mib, &miblen),
|
||||
expect_d_eq(mallctlnametomib(cmd, mib, &miblen),
|
||||
0, "Unexpected mallctlnametomib(\"%s\", ...) failure", cmd);
|
||||
mib[2] = ind;
|
||||
z = sizeof(size_t);
|
||||
assert_d_eq(mallctlbymib(mib, miblen, (void *)&ret, &z, NULL, 0),
|
||||
expect_d_eq(mallctlbymib(mib, miblen, (void *)&ret, &z, NULL, 0),
|
||||
0, "Unexpected mallctlbymib([\"%s\", %zu], ...) failure", cmd, ind);
|
||||
|
||||
return ret;
|
||||
@@ -50,28 +50,28 @@ TEST_BEGIN(test_grow_and_shrink) {
|
||||
#define MAXSZ ZU(12 * 1024 * 1024)
|
||||
|
||||
p = mallocx(1, 0);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
szs[0] = sallocx(p, 0);
|
||||
|
||||
for (i = 0; i < NCYCLES; i++) {
|
||||
for (j = 1; j < NSZS && szs[j-1] < MAXSZ; j++) {
|
||||
q = rallocx(p, szs[j-1]+1, 0);
|
||||
assert_ptr_not_null(q,
|
||||
expect_ptr_not_null(q,
|
||||
"Unexpected rallocx() error for size=%zu-->%zu",
|
||||
szs[j-1], szs[j-1]+1);
|
||||
szs[j] = sallocx(q, 0);
|
||||
assert_zu_ne(szs[j], szs[j-1]+1,
|
||||
expect_zu_ne(szs[j], szs[j-1]+1,
|
||||
"Expected size to be at least: %zu", szs[j-1]+1);
|
||||
p = q;
|
||||
}
|
||||
|
||||
for (j--; j > 0; j--) {
|
||||
q = rallocx(p, szs[j-1], 0);
|
||||
assert_ptr_not_null(q,
|
||||
expect_ptr_not_null(q,
|
||||
"Unexpected rallocx() error for size=%zu-->%zu",
|
||||
szs[j], szs[j-1]);
|
||||
tsz = sallocx(q, 0);
|
||||
assert_zu_eq(tsz, szs[j-1],
|
||||
expect_zu_eq(tsz, szs[j-1],
|
||||
"Expected size=%zu, got size=%zu", szs[j-1], tsz);
|
||||
p = q;
|
||||
}
|
||||
@@ -113,23 +113,23 @@ TEST_BEGIN(test_zero) {
|
||||
for (i = 0; i < sizeof(start_sizes)/sizeof(size_t); i++) {
|
||||
size_t start_size = start_sizes[i];
|
||||
p = mallocx(start_size, MALLOCX_ZERO);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
psz = sallocx(p, 0);
|
||||
|
||||
assert_false(validate_fill(p, 0, 0, psz),
|
||||
expect_false(validate_fill(p, 0, 0, psz),
|
||||
"Expected zeroed memory");
|
||||
memset(p, FILL_BYTE, psz);
|
||||
assert_false(validate_fill(p, FILL_BYTE, 0, psz),
|
||||
expect_false(validate_fill(p, FILL_BYTE, 0, psz),
|
||||
"Expected filled memory");
|
||||
|
||||
for (j = 1; j < RANGE; j++) {
|
||||
q = rallocx(p, start_size+j, MALLOCX_ZERO);
|
||||
assert_ptr_not_null(q, "Unexpected rallocx() error");
|
||||
expect_ptr_not_null(q, "Unexpected rallocx() error");
|
||||
qsz = sallocx(q, 0);
|
||||
if (q != p || qsz != psz) {
|
||||
assert_false(validate_fill(q, FILL_BYTE, 0,
|
||||
expect_false(validate_fill(q, FILL_BYTE, 0,
|
||||
psz), "Expected filled memory");
|
||||
assert_false(validate_fill(q, 0, psz, qsz-psz),
|
||||
expect_false(validate_fill(q, 0, psz, qsz-psz),
|
||||
"Expected zeroed memory");
|
||||
}
|
||||
if (psz != qsz) {
|
||||
@@ -139,7 +139,7 @@ TEST_BEGIN(test_zero) {
|
||||
}
|
||||
p = q;
|
||||
}
|
||||
assert_false(validate_fill(p, FILL_BYTE, 0, psz),
|
||||
expect_false(validate_fill(p, FILL_BYTE, 0, psz),
|
||||
"Expected filled memory");
|
||||
dallocx(p, 0);
|
||||
}
|
||||
@@ -154,13 +154,13 @@ TEST_BEGIN(test_align) {
|
||||
|
||||
align = ZU(1);
|
||||
p = mallocx(1, MALLOCX_ALIGN(align));
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
|
||||
for (align <<= 1; align <= MAX_ALIGN; align <<= 1) {
|
||||
q = rallocx(p, 1, MALLOCX_ALIGN(align));
|
||||
assert_ptr_not_null(q,
|
||||
expect_ptr_not_null(q,
|
||||
"Unexpected rallocx() error for align=%zu", align);
|
||||
assert_ptr_null(
|
||||
expect_ptr_null(
|
||||
(void *)((uintptr_t)q & (align-1)),
|
||||
"%p inadequately aligned for align=%zu",
|
||||
q, align);
|
||||
@@ -180,23 +180,23 @@ TEST_BEGIN(test_lg_align_and_zero) {
|
||||
|
||||
lg_align = 0;
|
||||
p = mallocx(1, MALLOCX_LG_ALIGN(lg_align)|MALLOCX_ZERO);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
||||
|
||||
for (lg_align++; lg_align <= MAX_LG_ALIGN; lg_align++) {
|
||||
q = rallocx(p, 1, MALLOCX_LG_ALIGN(lg_align)|MALLOCX_ZERO);
|
||||
assert_ptr_not_null(q,
|
||||
expect_ptr_not_null(q,
|
||||
"Unexpected rallocx() error for lg_align=%u", lg_align);
|
||||
assert_ptr_null(
|
||||
expect_ptr_null(
|
||||
(void *)((uintptr_t)q & ((ZU(1) << lg_align)-1)),
|
||||
"%p inadequately aligned for lg_align=%u", q, lg_align);
|
||||
sz = sallocx(q, 0);
|
||||
if ((sz << 1) <= MAX_VALIDATE) {
|
||||
assert_false(validate_fill(q, 0, 0, sz),
|
||||
expect_false(validate_fill(q, 0, 0, sz),
|
||||
"Expected zeroed memory");
|
||||
} else {
|
||||
assert_false(validate_fill(q, 0, 0, MAX_VALIDATE),
|
||||
expect_false(validate_fill(q, 0, 0, MAX_VALIDATE),
|
||||
"Expected zeroed memory");
|
||||
assert_false(validate_fill(
|
||||
expect_false(validate_fill(
|
||||
(void *)((uintptr_t)q+sz-MAX_VALIDATE),
|
||||
0, 0, MAX_VALIDATE), "Expected zeroed memory");
|
||||
}
|
||||
@@ -225,18 +225,18 @@ TEST_BEGIN(test_overflow) {
|
||||
largemax = get_large_size(get_nlarge()-1);
|
||||
|
||||
p = mallocx(1, 0);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
expect_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
|
||||
assert_ptr_null(rallocx(p, largemax+1, 0),
|
||||
expect_ptr_null(rallocx(p, largemax+1, 0),
|
||||
"Expected OOM for rallocx(p, size=%#zx, 0)", largemax+1);
|
||||
|
||||
assert_ptr_null(rallocx(p, ZU(PTRDIFF_MAX)+1, 0),
|
||||
expect_ptr_null(rallocx(p, ZU(PTRDIFF_MAX)+1, 0),
|
||||
"Expected OOM for rallocx(p, size=%#zx, 0)", ZU(PTRDIFF_MAX)+1);
|
||||
|
||||
assert_ptr_null(rallocx(p, SIZE_T_MAX, 0),
|
||||
expect_ptr_null(rallocx(p, SIZE_T_MAX, 0),
|
||||
"Expected OOM for rallocx(p, size=%#zx, 0)", SIZE_T_MAX);
|
||||
|
||||
assert_ptr_null(rallocx(p, 1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
|
||||
expect_ptr_null(rallocx(p, 1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
|
||||
"Expected OOM for rallocx(p, size=1, MALLOCX_ALIGN(%#zx))",
|
||||
ZU(PTRDIFF_MAX)+1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user