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;
|
||||
@@ -47,7 +47,7 @@ get_large_size(size_t ind) {
|
||||
*/
|
||||
static void
|
||||
purge(void) {
|
||||
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
||||
expect_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
||||
"Unexpected mallctl error");
|
||||
}
|
||||
|
||||
@@ -66,16 +66,16 @@ TEST_BEGIN(test_overflow) {
|
||||
|
||||
largemax = get_large_size(get_nlarge()-1);
|
||||
|
||||
assert_ptr_null(mallocx(largemax+1, 0),
|
||||
expect_ptr_null(mallocx(largemax+1, 0),
|
||||
"Expected OOM for mallocx(size=%#zx, 0)", largemax+1);
|
||||
|
||||
assert_ptr_null(mallocx(ZU(PTRDIFF_MAX)+1, 0),
|
||||
expect_ptr_null(mallocx(ZU(PTRDIFF_MAX)+1, 0),
|
||||
"Expected OOM for mallocx(size=%#zx, 0)", ZU(PTRDIFF_MAX)+1);
|
||||
|
||||
assert_ptr_null(mallocx(SIZE_T_MAX, 0),
|
||||
expect_ptr_null(mallocx(SIZE_T_MAX, 0),
|
||||
"Expected OOM for mallocx(size=%#zx, 0)", SIZE_T_MAX);
|
||||
|
||||
assert_ptr_null(mallocx(1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
|
||||
expect_ptr_null(mallocx(1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
|
||||
"Expected OOM for mallocx(size=1, MALLOCX_ALIGN(%#zx))",
|
||||
ZU(PTRDIFF_MAX)+1);
|
||||
}
|
||||
@@ -85,11 +85,11 @@ static void *
|
||||
remote_alloc(void *arg) {
|
||||
unsigned arena;
|
||||
size_t sz = sizeof(unsigned);
|
||||
assert_d_eq(mallctl("arenas.create", (void *)&arena, &sz, NULL, 0), 0,
|
||||
expect_d_eq(mallctl("arenas.create", (void *)&arena, &sz, NULL, 0), 0,
|
||||
"Unexpected mallctl() failure");
|
||||
size_t large_sz;
|
||||
sz = sizeof(size_t);
|
||||
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large_sz, &sz,
|
||||
expect_d_eq(mallctl("arenas.lextent.0.size", (void *)&large_sz, &sz,
|
||||
NULL, 0), 0, "Unexpected mallctl failure");
|
||||
|
||||
void *ptr = mallocx(large_sz, MALLOCX_ARENA(arena)
|
||||
@@ -105,7 +105,7 @@ TEST_BEGIN(test_remote_free) {
|
||||
void *ret;
|
||||
thd_create(&thd, remote_alloc, (void *)&ret);
|
||||
thd_join(thd, NULL);
|
||||
assert_ptr_not_null(ret, "Unexpected mallocx failure");
|
||||
expect_ptr_not_null(ret, "Unexpected mallocx failure");
|
||||
|
||||
/* Avoid TCACHE_NONE to explicitly test tcache_flush(). */
|
||||
dallocx(ret, 0);
|
||||
@@ -131,7 +131,7 @@ TEST_BEGIN(test_oom) {
|
||||
oom = true;
|
||||
}
|
||||
}
|
||||
assert_true(oom,
|
||||
expect_true(oom,
|
||||
"Expected OOM during series of calls to mallocx(size=%zu, 0)",
|
||||
largemax);
|
||||
for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) {
|
||||
@@ -142,14 +142,14 @@ TEST_BEGIN(test_oom) {
|
||||
purge();
|
||||
|
||||
#if LG_SIZEOF_PTR == 3
|
||||
assert_ptr_null(mallocx(0x8000000000000000ULL,
|
||||
expect_ptr_null(mallocx(0x8000000000000000ULL,
|
||||
MALLOCX_ALIGN(0x8000000000000000ULL)),
|
||||
"Expected OOM for mallocx()");
|
||||
assert_ptr_null(mallocx(0x8000000000000000ULL,
|
||||
expect_ptr_null(mallocx(0x8000000000000000ULL,
|
||||
MALLOCX_ALIGN(0x80000000)),
|
||||
"Expected OOM for mallocx()");
|
||||
#else
|
||||
assert_ptr_null(mallocx(0x80000000UL, MALLOCX_ALIGN(0x80000000UL)),
|
||||
expect_ptr_null(mallocx(0x80000000UL, MALLOCX_ALIGN(0x80000000UL)),
|
||||
"Expected OOM for mallocx()");
|
||||
#endif
|
||||
}
|
||||
@@ -166,28 +166,28 @@ TEST_BEGIN(test_basic) {
|
||||
size_t nsz, rsz;
|
||||
void *p;
|
||||
nsz = nallocx(sz, 0);
|
||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||
expect_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||
p = mallocx(sz, 0);
|
||||
assert_ptr_not_null(p,
|
||||
expect_ptr_not_null(p,
|
||||
"Unexpected mallocx(size=%zx, flags=0) error", sz);
|
||||
rsz = sallocx(p, 0);
|
||||
assert_zu_ge(rsz, sz, "Real size smaller than expected");
|
||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
||||
expect_zu_ge(rsz, sz, "Real size smaller than expected");
|
||||
expect_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
||||
dallocx(p, 0);
|
||||
|
||||
p = mallocx(sz, 0);
|
||||
assert_ptr_not_null(p,
|
||||
expect_ptr_not_null(p,
|
||||
"Unexpected mallocx(size=%zx, flags=0) error", sz);
|
||||
dallocx(p, 0);
|
||||
|
||||
nsz = nallocx(sz, MALLOCX_ZERO);
|
||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||
expect_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||
p = mallocx(sz, MALLOCX_ZERO);
|
||||
assert_ptr_not_null(p,
|
||||
expect_ptr_not_null(p,
|
||||
"Unexpected mallocx(size=%zx, flags=MALLOCX_ZERO) error",
|
||||
nsz);
|
||||
rsz = sallocx(p, 0);
|
||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
||||
expect_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
||||
dallocx(p, 0);
|
||||
purge();
|
||||
}
|
||||
@@ -224,22 +224,22 @@ TEST_BEGIN(test_alignment_and_size) {
|
||||
for (i = 0; i < NITER; i++) {
|
||||
nsz = nallocx(sz, MALLOCX_ALIGN(alignment) |
|
||||
MALLOCX_ZERO | MALLOCX_ARENA(0));
|
||||
assert_zu_ne(nsz, 0,
|
||||
expect_zu_ne(nsz, 0,
|
||||
"nallocx() error for alignment=%zu, "
|
||||
"size=%zu (%#zx)", alignment, sz, sz);
|
||||
ps[i] = mallocx(sz, MALLOCX_ALIGN(alignment) |
|
||||
MALLOCX_ZERO | MALLOCX_ARENA(0));
|
||||
assert_ptr_not_null(ps[i],
|
||||
expect_ptr_not_null(ps[i],
|
||||
"mallocx() error for alignment=%zu, "
|
||||
"size=%zu (%#zx)", alignment, sz, sz);
|
||||
rsz = sallocx(ps[i], 0);
|
||||
assert_zu_ge(rsz, sz,
|
||||
expect_zu_ge(rsz, sz,
|
||||
"Real size smaller than expected for "
|
||||
"alignment=%zu, size=%zu", alignment, sz);
|
||||
assert_zu_eq(nsz, rsz,
|
||||
expect_zu_eq(nsz, rsz,
|
||||
"nallocx()/sallocx() size mismatch for "
|
||||
"alignment=%zu, size=%zu", alignment, sz);
|
||||
assert_ptr_null(
|
||||
expect_ptr_null(
|
||||
(void *)((uintptr_t)ps[i] & (alignment-1)),
|
||||
"%p inadequately aligned for"
|
||||
" alignment=%zu, size=%zu", ps[i],
|
||||
|
||||
Reference in New Issue
Block a user