Commit 17338900 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'VSOCK-add-vsock_test-test-suite'

Stefano Garzarella says:

====================
VSOCK: add vsock_test test suite

The vsock_diag.ko module already has a test suite but the core AF_VSOCK
functionality has no tests. This patch series adds several test cases that
exercise AF_VSOCK SOCK_STREAM socket semantics (send/recv, connect/accept,
half-closed connections, simultaneous connections).

The v1 of this series was originally sent by Stefan.

v3:
- Patch 6:
  * check the byte received in the recv_byte()
  * use send(2)/recv(2) instead of write(2)/read(2) to test also flags
    (e.g. MSG_PEEK)
- Patch 8:
  * removed unnecessary control_expectln("CLOSED") [Stefan].
- removed patches 9,10,11 added in the v2
- new Patch 9 add parameters to list and skip tests (e.g. useful for vmci
  that doesn't support half-closed socket in the host)
- new Patch 10 prints a list of options in the help
- new Patch 11 tests MSG_PEEK flags of recv(2)

v2: https://patchwork.ozlabs.org/cover/1140538/
v1: https://patchwork.ozlabs.org/cover/847998/


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a706a042 d6269a93
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
*.d
vsock_test
vsock_diag_test
+5 −4
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
all: test
test: vsock_diag_test
vsock_diag_test: vsock_diag_test.o timeout.o control.o
test: vsock_test vsock_diag_test
vsock_test: vsock_test.o timeout.o control.o util.o
vsock_diag_test: vsock_diag_test.o timeout.o control.o util.o

CFLAGS += -g -O2 -Werror -Wall -I. -I../../include/uapi -I../../include -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -D_GNU_SOURCE
CFLAGS += -g -O2 -Werror -Wall -I. -I../../include -I../../../usr/include -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -D_GNU_SOURCE
.PHONY: all test clean
clean:
	${RM} *.o *.d vsock_diag_test
	${RM} *.o *.d vsock_test vsock_diag_test
-include *.d
+2 −1
Original line number Diff line number Diff line
@@ -5,12 +5,13 @@ Hyper-V.

The following tests are available:

  * vsock_test - core AF_VSOCK socket functionality
  * vsock_diag_test - vsock_diag.ko module for listing open sockets

The following prerequisite steps are not automated and must be performed prior
to running tests:

1. Build the kernel and these tests.
1. Build the kernel, make headers_install, and build these tests.
2. Install the kernel and tests on the host.
3. Install the kernel and tests inside the guest.
4. Boot the guest and ensure that the AF_VSOCK transport is enabled.
+13 −2
Original line number Diff line number Diff line
@@ -205,11 +205,22 @@ void control_expectln(const char *str)
	char *line;

	line = control_readln();
	if (strcmp(str, line) != 0) {

	control_cmpln(line, str, true);

	free(line);
}

bool control_cmpln(char *line, const char *str, bool fail)
{
	if (strcmp(str, line) == 0)
		return true;

	if (fail) {
		fprintf(stderr, "expected \"%s\" on control socket, got \"%s\"\n",
			str, line);
		exit(EXIT_FAILURE);
	}

	free(line);
	return false;
}
+2 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef CONTROL_H
#define CONTROL_H

@@ -9,5 +10,6 @@ void control_cleanup(void);
void control_writeln(const char *str);
char *control_readln(void);
void control_expectln(const char *str);
bool control_cmpln(char *line, const char *str, bool fail);

#endif /* CONTROL_H */
Loading