aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner.c
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2012-08-16 18:12:05 -0700
committerKristian Høgsberg <krh@bitplanet.net>2012-08-29 14:10:24 -0400
commit91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b (patch)
treec84f078a6adf3cae843073d8f47aa18dc8e22d35 /tests/test-runner.c
parenttests: Allow disabling leak checking assertions by env (diff)
downloadwayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar.gz
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar.bz2
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar.lz
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar.xz
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.tar.zst
wayland-91931bcabb0fba1a8b76f92cefa33fdeb1b74a8b.zip
tests: ensure sanity leak check tests pass when leak checks are disabled.
This finalizes Robert Bradfords patch to allow NO_ASSERT_LEAK_CHECK environment variable to disable leak checks in unit tests. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
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) {