packing: Bump up to 1.3.1
[platform/upstream/libxkbcommon.git] / test / xvfb-wrapper.h
1 /* This is a wrapper around X11 tests to make it faster to use for the simple
2  * type of test cases.
3  *
4  * Use with the X11_TEST macro like this:
5  *
6  * X11_TEST(some_test) {
7  *  return 0;
8  * }
9  *
10  * int main(void) {
11  *  return x11_tests_run(void);
12  * }
13  *
14  */
15
16 #pragma once
17
18 typedef int (* x11_test_func_t)(char* display);
19
20 struct test_function {
21     const char *name;     /* function name */
22     const char *file;     /* file name */
23     x11_test_func_t func; /* test function */
24 } __attribute__((aligned(16)));
25
26 /**
27  * Defines a struct test_function in a custom ELF section that we can then
28  * loop over in x11_tests_run() to extract the tests. This removes the
29  * need of manually adding the tests to a suite or listing them somewhere.
30  */
31 #define X11_TEST(_func) \
32 static int _func(char* display); \
33 static const struct test_function _test_##_func \
34 __attribute__((used)) \
35 __attribute__((section("test_functions_section"))) = { \
36     .name = #_func, \
37     .func = _func, \
38     .file = __FILE__, \
39 }; \
40 static int _func(char* display)
41
42 int xvfb_wrapper(int (*f)(char* display));
43
44 int x11_tests_run(void);