mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-23 01:40:43 -05:00
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>
This commit is contained in:
parent
2896b6a220
commit
e0561ac68d
5 changed files with 68 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue