Debian Codegraph @

tests/harness/gpiod-test.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]> */
3
4 /*
5 * Testing framework for the core library.
6 *
7 * This file contains functions and definitions extending the GLib unit testing
8 * framework with functionalities necessary to test the libgpiod core C API as
9 * well as the kernel-to-user-space interface.
10 */
11
12 #ifndef __GPIOD_TEST_H__
13 #define __GPIOD_TEST_H__
14
15 #include <glib.h>
16
17 /* These are private definitions and should not be used directly. */
18
19 struct _gpiod_test_case {
20 const gchar *path;
21 void (*func)(void);
22 };
23
24 void _gpiod_test_register(struct _gpiod_test_case *test);
25
26 #define _GPIOD_TEST_PATH(_name) \
27 "/gpiod/" GPIOD_TEST_GROUP "/" G_STRINGIFY(_name)
28
29 /*
30 * Register a test case function.
31 */
32 #define GPIOD_TEST_CASE(_name) \
33 static void _gpiod_test_func_##_name(void); \
34 static struct _gpiod_test_case _##_name##_test_case = { \
35 .path = _GPIOD_TEST_PATH(_name), \
36 .func = _gpiod_test_func_##_name, \
37 }; \
38 static __attribute__((constructor)) void \
39 _##_name##_test_register(void) \
40 { \
41 _gpiod_test_register(&_##_name##_test_case); \
42 } \
43 static void _gpiod_test_func_##_name(void)
44
45 #endif /* __GPIOD_TEST_H__ */