aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/vsock/util.h
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2019-12-18 19:07:00 +0100
committerDavid S. Miller <davem@davemloft.net>2019-12-20 21:09:21 -0800
commitdf7e0e0d237e5a4ee262befb11b599058a178966 (patch)
tree105b98425f52cf9666836aef64d282c6debc8f16 /tools/testing/vsock/util.h
parentVSOCK: add SPDX identifiers to vsock tests (diff)
downloadlinux-dev-df7e0e0d237e5a4ee262befb11b599058a178966.tar.xz
linux-dev-df7e0e0d237e5a4ee262befb11b599058a178966.zip
VSOCK: extract utility functions from vsock_diag_test.c
Move useful functions into a separate file in preparation for more vsock test programs. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--tools/testing/vsock/util.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
new file mode 100644
index 000000000000..033e7d59a42a
--- /dev/null
+++ b/tools/testing/vsock/util.h
@@ -0,0 +1,36 @@
+/* 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_MODE_UNSET,
+ TEST_MODE_CLIENT,
+ TEST_MODE_SERVER
+};
+
+/* 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 */