[Libguestfs] [libnbd PATCH 06/20] tests: Enhance fuse probing

Martin Kletzander
Tue, 08 Jun 2021 07:53:47 -0000

tests/functions.sh.in         | 10 ++++++++++
 fuse/test-errors.sh           |  2 +-
 fuse/test-file-mode.sh        |  3 +--
 fuse/test-nbdkit-command.sh   |  2 +-
 fuse/test-nbdkit-file-null.sh |  2 +-
 fuse/test-nbdkit.sh           |  3 +--
 fuse/test-parallel.sh         |  2 +-
 fuse/test-pattern.sh          |  2 +-
 fuse/test-qcow2.sh            |  3 +--
 fuse/test-trim.sh             |  2 +-
 fuse/test-unix.sh             |  2 +-
 fuse/test-zero.sh             |  2 +-
 12 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 271d8b357685..6f18f06238d5 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -118,6 +118,16 @@ requires_linux_kernel_version ()
     requires test "$(printf "$kver\n$min" | sort -V | head -n
1)" = "$min"
 }

+# requires_fuse
+#
+# Check for fusermount3 and accessibility of /dev/fuse.  That is not the best
+# way to check that it is going to work, but so far it is enough.
+requires_fuse ()
+{
+    requires test -r /dev/fuse
+    requires fusermount3 --version
+}
+
 # Tests that run under check-root should use this.
 requires_root ()
 {
diff --git a/fuse/test-errors.sh b/fuse/test-errors.sh
index 2a08eec50971..4827a4756fd5 100755
--- a/fuse/test-errors.sh
+++ b/fuse/test-errors.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires dd --version
 requires dd iflag=count_bytes,skip_bytes </dev/null
 requires nbdkit --version
diff --git a/fuse/test-file-mode.sh b/fuse/test-file-mode.sh
index 7c684805eeff..19ce030faf4f 100755
--- a/fuse/test-file-mode.sh
+++ b/fuse/test-file-mode.sh
@@ -23,11 +23,10 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires nbdkit --exit-with-parent --version
 requires cmp --version
 requires dd --version
-requires test -r /dev/fuse

 if ! test -r /dev/urandom; then
     echo "$0: test skipped: /dev/urandom not readable"
diff --git a/fuse/test-nbdkit-command.sh b/fuse/test-nbdkit-command.sh
index 3fdabb740837..a743d60b5989 100755
--- a/fuse/test-nbdkit-command.sh
+++ b/fuse/test-nbdkit-command.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires nbdkit --exit-with-parent --version
 requires cmp --version
 requires dd --version
diff --git a/fuse/test-nbdkit-file-null.sh b/fuse/test-nbdkit-file-null.sh
index f7b8ed29b0f6..6454b1e0c687 100755
--- a/fuse/test-nbdkit-file-null.sh
+++ b/fuse/test-nbdkit-file-null.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires nbdkit --exit-with-parent --version

 pidfile=test-nbdkit-file-null.pid
diff --git a/fuse/test-nbdkit.sh b/fuse/test-nbdkit.sh
index fd0c9ce72356..047835ae7ec9 100755
--- a/fuse/test-nbdkit.sh
+++ b/fuse/test-nbdkit.sh
@@ -23,11 +23,10 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires nbdkit --exit-with-parent --version
 requires cmp --version
 requires dd --version
-requires test -r /dev/fuse

 if ! test -r /dev/urandom; then
     echo "$0: test skipped: /dev/urandom not readable"
diff --git a/fuse/test-parallel.sh b/fuse/test-parallel.sh
index 076c9a2b8482..55bb7c8e8e7d 100755
--- a/fuse/test-parallel.sh
+++ b/fuse/test-parallel.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires dd --version
 requires nbdkit --version
 requires nbdkit memory --version
diff --git a/fuse/test-pattern.sh b/fuse/test-pattern.sh
index f32f9d093285..1ff06e3eb095 100755
--- a/fuse/test-pattern.sh
+++ b/fuse/test-pattern.sh
@@ -24,7 +24,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires dd --version
 requires dd iflag=count_bytes,skip_bytes </dev/null
 requires hexdump -C /dev/null
diff --git a/fuse/test-qcow2.sh b/fuse/test-qcow2.sh
index 0c5836ad24f1..0545d1d8a933 100755
--- a/fuse/test-qcow2.sh
+++ b/fuse/test-qcow2.sh
@@ -24,12 +24,11 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires qemu-nbd --version
 requires qemu-img --version
 requires cmp --version
 requires dd --version
-requires test -r /dev/fuse

 if ! test -r /dev/urandom; then
     echo "$0: test skipped: /dev/urandom not readable"
diff --git a/fuse/test-trim.sh b/fuse/test-trim.sh
index 824dad79d16f..c845ba900881 100755
--- a/fuse/test-trim.sh
+++ b/fuse/test-trim.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires fallocate --version
 requires dd --version
 requires nbdkit --version
diff --git a/fuse/test-unix.sh b/fuse/test-unix.sh
index 20179bd17694..0a962f1da1f1 100755
--- a/fuse/test-unix.sh
+++ b/fuse/test-unix.sh
@@ -23,7 +23,7 @@
 set -e
 set -x

-requires fusermount3 --version
+requires_fuse
 requires nbdkit --exit-with-parent --version

 # Difficult to arrange for this test to be run this test under
diff --git a/fuse/test-zero.sh b/fuse/test-zero.sh
index e5de270d9a8c..bf9d1320a930 100755
--- a/fuse/test-zero.sh
+++ b/fuse/test-zero.sh
@@ -28,7 +28,7 @@ set -x
 #
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/log/?h=for-next
 requires_linux_kernel_version 5.14

-requires fusermount3 --version
+requires_fuse
 requires fallocate --version
 requires dd --version
 requires nbdkit --version
--
2.31.1