1
0
mirror of https://github.com/fluencelabs/redis synced 2025-07-03 02:41:33 +00:00
Files
deps
geohash-int
hiredis
jemalloc
bin
doc
include
src
test
include
integration
src
stress
unit
SFMT.c
atomic.c
bitmap.c
ckh.c
hash.c
junk.c
junk_alloc.c
junk_free.c
lg_chunk.c
mallctl.c
math.c
mq.c
mtx.c
prof_accum.c
prof_active.c
prof_gdump.c
prof_idump.c
prof_reset.c
prof_thread_name.c
ql.c
qr.c
quarantine.c
rb.c
rtree.c
size_classes.c
stats.c
tsd.c
util.c
zero.c
test.sh.in
.autom4te.cfg
.gitattributes
.gitignore
COPYING
ChangeLog
INSTALL
Makefile.in
README
VERSION
autogen.sh
config.guess
config.stamp.in
config.sub
configure
configure.ac
coverage.sh
install-sh
jemalloc.pc.in
linenoise
lua
Makefile
README.md
update-jemalloc.sh
src
tests
utils
.gitignore
00-RELEASENOTES
BUGS
CONTRIBUTING
COPYING
INSTALL
MANIFESTO
Makefile
README.md
redis.conf
runtest
runtest-cluster
runtest-sentinel
sentinel.conf
redis/deps/jemalloc/test/unit/zero.c

79 lines
1.4 KiB
C
Raw Normal View History

#include "test/jemalloc_test.h"
#ifdef JEMALLOC_FILL
const char *malloc_conf =
"abort:false,junk:false,zero:true,redzone:false,quarantine:0";
#endif
static void
test_zero(size_t sz_min, size_t sz_max)
{
char *s;
size_t sz_prev, sz, i;
sz_prev = 0;
s = (char *)mallocx(sz_min, 0);
assert_ptr_not_null((void *)s, "Unexpected mallocx() failure");
for (sz = sallocx(s, 0); sz <= sz_max;
sz_prev = sz, sz = sallocx(s, 0)) {
if (sz_prev > 0) {
assert_c_eq(s[0], 'a',
"Previously allocated byte %zu/%zu is corrupted",
ZU(0), sz_prev);
assert_c_eq(s[sz_prev-1], 'a',
"Previously allocated byte %zu/%zu is corrupted",
sz_prev-1, sz_prev);
}
for (i = sz_prev; i < sz; i++) {
assert_c_eq(s[i], 0x0,
"Newly allocated byte %zu/%zu isn't zero-filled",
i, sz);
s[i] = 'a';
}
if (xallocx(s, sz+1, 0, 0) == sz) {
s = (char *)rallocx(s, sz+1, 0);
assert_ptr_not_null((void *)s,
"Unexpected rallocx() failure");
}
}
dallocx(s, 0);
}
TEST_BEGIN(test_zero_small)
{
test_skip_if(!config_fill);
test_zero(1, SMALL_MAXCLASS-1);
}
TEST_END
TEST_BEGIN(test_zero_large)
{
test_skip_if(!config_fill);
2015-10-06 16:18:30 +02:00
test_zero(SMALL_MAXCLASS+1, large_maxclass);
}
TEST_END
TEST_BEGIN(test_zero_huge)
{
test_skip_if(!config_fill);
2015-10-06 16:18:30 +02:00
test_zero(large_maxclass+1, chunksize*2);
}
TEST_END
int
main(void)
{
return (test(
test_zero_small,
test_zero_large,
test_zero_huge));
}