summaryrefslogtreecommitdiff
path: root/tests/test-runner.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-runner.c')
-rw-r--r--tests/test-runner.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c
index 6c30649..8c79dff 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -39,6 +39,8 @@ static void (*sys_free)(void*);
static void* (*sys_realloc)(void*, size_t);
static void* (*sys_calloc)(size_t, size_t);
+int leak_check_enabled;
+
extern const struct test __start_test_section, __stop_test_section;
__attribute__ ((visibility("default"))) void *
@@ -95,7 +97,7 @@ run_test(const struct test *t)
cur_fds = count_open_fds();
t->run();
- if (!getenv("NO_ASSERT_LEAK_CHECK")) {
+ if (leak_check_enabled) {
assert(cur_alloc == num_alloc && "memory leak detected in test.");
assert(cur_fds == count_open_fds() && "fd leak detected");
}
@@ -115,6 +117,8 @@ int main(int argc, char *argv[])
sys_malloc = dlsym(RTLD_NEXT, "malloc");
sys_free = dlsym(RTLD_NEXT, "free");
+ leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
+
if (argc == 2) {
t = find_test(argv[1]);
if (t == NULL) {