mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-12 04:28:22 -05:00
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>
37 lines
739 B
C
37 lines
739 B
C
#ifndef _TEST_RUNNER_H_
|
|
#define _TEST_RUNNER_H_
|
|
|
|
#ifdef NDEBUG
|
|
#error "Tests must not be built with NDEBUG defined, they rely on assert()."
|
|
#endif
|
|
|
|
struct test {
|
|
const char *name;
|
|
void (*run)(void);
|
|
int must_fail;
|
|
} __attribute__ ((aligned (16)));
|
|
|
|
#define TEST(name) \
|
|
static void name(void); \
|
|
\
|
|
const struct test test##name \
|
|
__attribute__ ((section ("test_section"))) = { \
|
|
#name, name, 0 \
|
|
}; \
|
|
\
|
|
static void name(void)
|
|
|
|
#define FAIL_TEST(name) \
|
|
static void name(void); \
|
|
\
|
|
const struct test test##name \
|
|
__attribute__ ((section ("test_section"))) = { \
|
|
#name, name, 1 \
|
|
}; \
|
|
\
|
|
static void name(void)
|
|
|
|
int
|
|
count_open_fds(void);
|
|
|
|
#endif
|