aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner.c
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2012-04-19 16:52:32 +0300
committerPekka Paalanen <ppaalanen@gmail.com>2012-04-20 14:58:31 +0300
commite0561ac68d4db23906ca7e61bf191da4451711fd (patch)
treef1c35d58239fe67859cb47022e0fb17b1d27bc06 /tests/test-runner.c
parentprotocol: Add ping event and corresponding pong request (diff)
downloadwayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar.gz
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar.bz2
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar.lz
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar.xz
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.tar.zst
wayland-e0561ac68d4db23906ca7e61bf191da4451711fd.zip
tests: detect fd leaks
Detect file descriptor leaks in tests. Add a sanity test to verify that we catch the leaks. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'tests/test-runner.c')
-rw-r--r--tests/test-runner.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c
index 24ae317..c4a57a3 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <assert.h>
#include <dlfcn.h>
+#include <errno.h>
#include "test-runner.h"
static int num_alloc;
@@ -69,9 +70,12 @@ static void
run_test(const struct test *t)
{
int cur_alloc = num_alloc;
+ int cur_fds;
+ cur_fds = count_open_fds();
t->run();
assert(cur_alloc == num_alloc && "memory leak detected in test.");
+ assert(cur_fds == count_open_fds() && "fd leak detected");
exit(EXIT_SUCCESS);
}