From e0561ac68d4db23906ca7e61bf191da4451711fd Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 19 Apr 2012 16:52:32 +0300 Subject: 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 --- tests/test-runner.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/test-runner.c') 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 #include #include +#include #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); } -- cgit v1.2.3-70-g09d2