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:
@@ -14,7 +14,7 @@ static void test_write_cb(void *cbopaque, const char *s) {
|
||||
size_t prev_test_write_len = test_write_len;
|
||||
test_write_len += strlen(s); /* only increase the length */
|
||||
arg_store = *(uint64_t *)cbopaque; /* only pass along the argument */
|
||||
assert_zu_le(prev_test_write_len, test_write_len,
|
||||
expect_zu_le(prev_test_write_len, test_write_len,
|
||||
"Test write overflowed");
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ static void test_buf_writer_body(tsdn_t *tsdn, buf_writer_t *buf_writer) {
|
||||
char s[UNIT_MAX + 1];
|
||||
size_t n_unit, remain, i;
|
||||
ssize_t unit;
|
||||
assert_ptr_not_null(buf_writer->buf, "Buffer is null");
|
||||
expect_ptr_not_null(buf_writer->buf, "Buffer is null");
|
||||
write_cb_t *write_cb = buf_writer_get_write_cb(buf_writer);
|
||||
void *cbopaque = buf_writer_get_cbopaque(buf_writer);
|
||||
|
||||
@@ -41,7 +41,7 @@ static void test_buf_writer_body(tsdn_t *tsdn, buf_writer_t *buf_writer) {
|
||||
remain += unit;
|
||||
if (remain > buf_writer->buf_size) {
|
||||
/* Flushes should have happened. */
|
||||
assert_u64_eq(arg_store, arg, "Call "
|
||||
expect_u64_eq(arg_store, arg, "Call "
|
||||
"back argument didn't get through");
|
||||
remain %= buf_writer->buf_size;
|
||||
if (remain == 0) {
|
||||
@@ -49,12 +49,12 @@ static void test_buf_writer_body(tsdn_t *tsdn, buf_writer_t *buf_writer) {
|
||||
remain += buf_writer->buf_size;
|
||||
}
|
||||
}
|
||||
assert_zu_eq(test_write_len + remain, i * unit,
|
||||
expect_zu_eq(test_write_len + remain, i * unit,
|
||||
"Incorrect length after writing %zu strings"
|
||||
" of length %zu", i, unit);
|
||||
}
|
||||
buf_writer_flush(buf_writer);
|
||||
assert_zu_eq(test_write_len, n_unit * unit,
|
||||
expect_zu_eq(test_write_len, n_unit * unit,
|
||||
"Incorrect length after flushing at the end of"
|
||||
" writing %zu strings of length %zu", n_unit, unit);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ static void test_buf_writer_body(tsdn_t *tsdn, buf_writer_t *buf_writer) {
|
||||
TEST_BEGIN(test_buf_write_static) {
|
||||
buf_writer_t buf_writer;
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
assert_false(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
expect_false(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
test_buf, TEST_BUF_SIZE),
|
||||
"buf_writer_init() should not encounter error on static buffer");
|
||||
test_buf_writer_body(tsdn, &buf_writer);
|
||||
@@ -75,7 +75,7 @@ TEST_END
|
||||
TEST_BEGIN(test_buf_write_dynamic) {
|
||||
buf_writer_t buf_writer;
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
assert_false(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
expect_false(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
NULL, TEST_BUF_SIZE), "buf_writer_init() should not OOM");
|
||||
test_buf_writer_body(tsdn, &buf_writer);
|
||||
}
|
||||
@@ -84,13 +84,13 @@ TEST_END
|
||||
TEST_BEGIN(test_buf_write_oom) {
|
||||
buf_writer_t buf_writer;
|
||||
tsdn_t *tsdn = tsdn_fetch();
|
||||
assert_true(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
expect_true(buf_writer_init(tsdn, &buf_writer, test_write_cb, &arg,
|
||||
NULL, SC_LARGE_MAXCLASS + 1), "buf_writer_init() should OOM");
|
||||
assert_ptr_null(buf_writer.buf, "Buffer should be null");
|
||||
expect_ptr_null(buf_writer.buf, "Buffer should be null");
|
||||
write_cb_t *write_cb = buf_writer_get_write_cb(&buf_writer);
|
||||
assert_ptr_eq(write_cb, test_write_cb, "Should use test_write_cb");
|
||||
expect_ptr_eq(write_cb, test_write_cb, "Should use test_write_cb");
|
||||
void *cbopaque = buf_writer_get_cbopaque(&buf_writer);
|
||||
assert_ptr_eq(cbopaque, &arg, "Should use arg");
|
||||
expect_ptr_eq(cbopaque, &arg, "Should use arg");
|
||||
|
||||
char s[UNIT_MAX + 1];
|
||||
size_t n_unit, i;
|
||||
@@ -107,14 +107,14 @@ TEST_BEGIN(test_buf_write_oom) {
|
||||
for (i = 1; i <= n_unit; ++i) {
|
||||
arg = prng_lg_range_u64(&arg, 64);
|
||||
write_cb(cbopaque, s);
|
||||
assert_u64_eq(arg_store, arg,
|
||||
expect_u64_eq(arg_store, arg,
|
||||
"Call back argument didn't get through");
|
||||
assert_zu_eq(test_write_len, i * unit,
|
||||
expect_zu_eq(test_write_len, i * unit,
|
||||
"Incorrect length after writing %zu strings"
|
||||
" of length %zu", i, unit);
|
||||
}
|
||||
buf_writer_flush(&buf_writer);
|
||||
assert_zu_eq(test_write_len, n_unit * unit,
|
||||
expect_zu_eq(test_write_len, n_unit * unit,
|
||||
"Incorrect length after flushing at the end of"
|
||||
" writing %zu strings of length %zu", n_unit, unit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user