1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 #ifndef UTIL_H 3 #define UTIL_H 4 5 /* Tests can either run as the client or the server */ 6 enum test_mode { 7 TEST_MODE_UNSET, 8 TEST_MODE_CLIENT, 9 TEST_MODE_SERVER 10 }; 11 12 /* Test runner options */ 13 struct test_opts { 14 enum test_mode mode; 15 unsigned int peer_cid; 16 }; 17 18 /* A test case definition. Test functions must print failures to stderr and 19 * terminate with exit(EXIT_FAILURE). 20 */ 21 struct test_case { 22 const char *name; /* human-readable name */ 23 24 /* Called when test mode is TEST_MODE_CLIENT */ 25 void (*run_client)(const struct test_opts *opts); 26 27 /* Called when test mode is TEST_MODE_SERVER */ 28 void (*run_server)(const struct test_opts *opts); 29 }; 30 31 void init_signals(void); 32 unsigned int parse_cid(const char *str); 33 void run_tests(const struct test_case *test_cases, 34 const struct test_opts *opts); 35 36 #endif /* UTIL_H */ 37