---
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.33.0