VSOCK: extract connect/accept functions from vsock_diag_test.c

Many test cases will need to connect to the server or accept incoming
connections.  This patch extracts these operations into utility
functions that can be reused.

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>
This commit is contained in:
Stefan Hajnoczi
2019-12-18 19:07:01 +01:00
committed by David S. Miller
parent df7e0e0d23
commit 9bb8a29d28
3 changed files with 119 additions and 76 deletions

View File

@@ -2,6 +2,9 @@
#ifndef UTIL_H
#define UTIL_H
#include <sys/socket.h>
#include <linux/vm_sockets.h>
/* Tests can either run as the client or the server */
enum test_mode {
TEST_MODE_UNSET,
@@ -30,6 +33,9 @@ struct test_case {
void init_signals(void);
unsigned int parse_cid(const char *str);
int vsock_stream_connect(unsigned int cid, unsigned int port);
int vsock_stream_accept(unsigned int cid, unsigned int port,
struct sockaddr_vm *clientaddrp);
void run_tests(const struct test_case *test_cases,
const struct test_opts *opts);