path: root/tools/testing/vsock/util.h
blob: 033e7d59a42a1c811404b0b86340fc91317531d8 (plain) (tree)

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef UTIL_H
#define UTIL_H

/* Tests can either run as the client or the server */
enum test_mode {

/* Test runner options */
struct test_opts {
	enum test_mode mode;
	unsigned int peer_cid;

/* A test case definition.  Test functions must print failures to stderr and
 * terminate with exit(EXIT_FAILURE).
struct test_case {
	const char *name; /* human-readable name */

	/* Called when test mode is TEST_MODE_CLIENT */
	void (*run_client)(const struct test_opts *opts);

	/* Called when test mode is TEST_MODE_SERVER */
	void (*run_server)(const struct test_opts *opts);

void init_signals(void);
unsigned int parse_cid(const char *str);
void run_tests(const struct test_case *test_cases,
	       const struct test_opts *opts);

#endif /* UTIL_H */