summaryrefslogtreecommitdiffstats
path: root/tests/test-runner.h
blob: 707504cc9f5dc8d299a31d3bc824e56bfcfebe16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#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);

void
exec_fd_leak_check(int nr_expected_fds); /* never returns */

#endif