1
0
mirror of https://github.com/fluencelabs/redis synced 2025-07-03 02:41:33 +00:00
Files
deps
hiredis
jemalloc
bin
build-aux
doc
include
m4
msvc
scripts
src
test
include
integration
src
stress
unit
SFMT.c
a0.c
arena_reset.c
arena_reset_prof.c
arena_reset_prof.sh
atomic.c
background_thread.c
background_thread_enable.c
base.c
bit_util.c
bitmap.c
ckh.c
decay.c
decay.sh
div.c
emitter.c
extent_quantize.c
fork.c
hash.c
hooks.c
junk.c
junk.sh
junk_alloc.c
junk_alloc.sh
junk_free.c
junk_free.sh
log.c
mallctl.c
malloc_io.c
math.c
mq.c
mtx.c
nstime.c
pack.c
pack.sh
pages.c
ph.c
prng.c
prof_accum.c
prof_accum.sh
prof_active.c
prof_active.sh
prof_gdump.c
prof_gdump.sh
prof_idump.c
prof_idump.sh
prof_reset.c
prof_reset.sh
prof_tctx.c
prof_tctx.sh
prof_thread_name.c
prof_thread_name.sh
ql.c
qr.c
rb.c
retained.c
rtree.c
size_classes.c
slab.c
smoothstep.c
spin.c
stats.c
stats_print.c
ticker.c
tsd.c
witness.c
zero.c
zero.sh
test.sh.in
.appveyor.yml
.autom4te.cfg
.gitattributes
.gitignore
.travis.yml
COPYING
ChangeLog
INSTALL.md
Makefile.in
README
TUNING.md
VERSION
autogen.sh
config.stamp.in
configure
configure.ac
jemalloc.pc.in
run_tests.sh
linenoise
lua
Makefile
README.md
update-jemalloc.sh
src
tests
utils
.gitignore
00-RELEASENOTES
BUGS
CMakeLists.txt
CONTRIBUTING
COPYING
Dockerfile
INSTALL
MANIFESTO
Makefile
README.md
docker-compose.yml
redis.conf
runtest
runtest-cluster
runtest-sentinel
sentinel.conf
redis/deps/jemalloc/test/unit/hooks.c

39 lines
752 B
C
Raw Normal View History

2018-05-24 17:17:37 +02:00
#include "test/jemalloc_test.h"
static bool hook_called = false;
static void
hook() {
hook_called = true;
}
static int
func_to_hook(int arg1, int arg2) {
return arg1 + arg2;
}
#define func_to_hook JEMALLOC_HOOK(func_to_hook, hooks_libc_hook)
TEST_BEGIN(unhooked_call) {
hooks_libc_hook = NULL;
hook_called = false;
assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value.");
assert_false(hook_called, "Nulling out hook didn't take.");
}
TEST_END
TEST_BEGIN(hooked_call) {
hooks_libc_hook = &hook;
hook_called = false;
assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value.");
assert_true(hook_called, "Hook should have executed.");
}
TEST_END
int
main(void) {
return test(
unhooked_call,
hooked_call);
}