nbdkit/0001-Skip-vsock-related-che...

74 lines
2.3 KiB
Diff

From 5c4dcc9ade4b2d46d69478f711bd98b14b99c3d2 Mon Sep 17 00:00:00 2001
From: Hilko Bengen <bengen@hilluzination.de>
Date: Mon, 25 Oct 2021 23:34:20 +0200
Subject: [PATCH] Skip vsock-related checks if AF_VSOCK is not supported.
(cherry picked from commit 068cd85375e9bd309f65ba3971db643e817fe912)
---
tests/functions.sh.in | 10 ++++++++++
tests/test-ip-filter-anyvsock.sh | 1 +
tests/test-nbd-vsock.sh | 1 +
tests/test-vsock.sh | 1 +
4 files changed, 13 insertions(+)
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 403fa56e..d6c4255c 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -239,6 +239,16 @@ requires_non_root ()
fi
}
+# Tests that use the vsock interface will fail if vsock is not
+# supported.
+requires_vsock_support ()
+{
+ if ! grep -q ^AF_VSOCK /proc/net/protocols; then
+ echo "$0: test skipped because AF_VSOCK is not supported."
+ exit 77
+ fi
+}
+
# start_nbdkit -P pidfile args...
#
# Run nbdkit with args and wait for it to start up. If it fails to
diff --git a/tests/test-ip-filter-anyvsock.sh b/tests/test-ip-filter-anyvsock.sh
index 3160e982..016b1da9 100755
--- a/tests/test-ip-filter-anyvsock.sh
+++ b/tests/test-ip-filter-anyvsock.sh
@@ -47,6 +47,7 @@ requires nbdsh --version
requires nbdsh -c 'print(h.connect_vsock)'
requires_nbdsh_uri
requires_linux_kernel_version 5.6
+requires_vsock_support
# Not supported on Windows.
if is_windows; then
diff --git a/tests/test-nbd-vsock.sh b/tests/test-nbd-vsock.sh
index e3736898..f1f839a0 100755
--- a/tests/test-nbd-vsock.sh
+++ b/tests/test-nbd-vsock.sh
@@ -47,6 +47,7 @@ set -x
requires_nbdsh_uri
requires nbdsh -c 'print(h.connect_vsock)'
requires_linux_kernel_version 5.6
+requires_vsock_support
# Because vsock ports are 32 bits, we can basically pick one at random
# and be sure that it's not used. However we must pick one >= 1024
diff --git a/tests/test-vsock.sh b/tests/test-vsock.sh
index fc39cb7b..0bcfc4ba 100755
--- a/tests/test-vsock.sh
+++ b/tests/test-vsock.sh
@@ -47,6 +47,7 @@ requires nbdsh --version
requires nbdsh -c 'print(h.connect_vsock)'
requires_nbdsh_uri
requires_linux_kernel_version 5.6
+requires_vsock_support
# Because vsock ports are 32 bits, we can basically pick one at random
# and be sure that it's not used. However we must pick one >= 1024
--
2.31.1