---
tests/functions.sh.in | 17 ++++++++++++++++-
tests/test-cache-max-size.sh | 18 +++---------------
tests/test-data-7E.sh | 8 ++------
tests/test-data-base64.sh | 12 ++++--------
tests/test-data-file.sh | 8 ++------
tests/test-data-raw.sh | 8 ++------
tests/test-eflags.sh | 13 +++++--------
tests/test-error0.sh | 6 +-----
tests/test-error10.sh | 6 +-----
tests/test-error100.sh | 6 +-----
tests/test-full.sh | 8 ++------
tests/test-ip.sh | 21 ++++++---------------
tests/test-memory-largest-for-qemu.sh | 8 ++------
tests/test-memory-largest.sh | 8 ++------
tests/test-offset2.sh | 8 ++------
tests/test-parallel-file.sh | 10 ++--------
tests/test-parallel-nbd.sh | 10 ++--------
tests/test-partition1.sh | 22 ++++------------------
tests/test-partition2.sh | 6 +-----
tests/test-partitioning1.sh | 8 ++------
tests/test-partitioning2.sh | 8 ++------
tests/test-partitioning4.sh | 6 +-----
tests/test-partitioning5.sh | 8 ++------
tests/test-partitioning6.sh | 6 +-----
tests/test-pattern-largest-for-qemu.sh | 8 ++------
tests/test-pattern-largest.sh | 8 ++------
tests/test-single.sh | 11 ++---------
tests/test-tls-psk.sh | 12 +++---------
tests/test-tls.sh | 12 +++---------
tests/test-truncate1.sh | 8 ++------
tests/test-truncate2.sh | 8 ++------
tests/test-truncate3.sh | 8 ++------
tests/test-zero.sh | 6 +-----
33 files changed, 87 insertions(+), 233 deletions(-)
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 35647f7..289584a 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -1,7 +1,7 @@
# nbdkit
# Common functions used by the tests.
# @configure_input@
-# Copyright (C) 2017-2018 Red Hat Inc.
+# Copyright (C) 2017-2019 Red Hat Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,21 @@ _run_cleanup_hooks ()
}
trap _run_cleanup_hooks INT QUIT TERM EXIT ERR
+# requires program [args]
+#
+# Check that ‘program [args]’ works. If not, skip the test.
+# For example to check that qemu-img is available, do:
+#
+# requires qemu-img --version
+requires ()
+{
+ ( "$@" ) </dev/null >/dev/null 2>&1 || {
+ echo "$0: ‘$*’ failed with error code $?"
+ echo "$0: test prerequisite is missing or not working"
+ exit 77
+ }
+}
+
# 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-cache-max-size.sh b/tests/test-cache-max-size.sh
index f7e743a..8cb5ad1 100755
--- a/tests/test-cache-max-size.sh
+++ b/tests/test-cache-max-size.sh
@@ -36,22 +36,10 @@ set -e
set -x
# Check that this is a Linux-like system supporting /proc/$pid/fd.
-if ! test -d /proc/self/fd; then
- echo "$0: not a Linux-like system supporting /proc/\$pid/fd"
- exit 77
-fi
-
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
+requires test -d /proc/self/fd
+requires qemu-io --version
# Need the stat command from coreutils.
-if ! stat --version >/dev/null; then
- echo "$0: missing or broken stat command"
- exit 77
-fi
+requires stat --version
d=cache-max-size.d
rm -rf $d
diff --git a/tests/test-data-7E.sh b/tests/test-data-7E.sh
index e27984f..2e48e1b 100755
--- a/tests/test-data-7E.sh
+++ b/tests/test-data-7E.sh
@@ -38,16 +38,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="data-7E.out data-7E.pid data-7E.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit.
start_nbdkit -P data-7E.pid -U data-7E.sock --export= \
--filter=partition \
diff --git a/tests/test-data-base64.sh b/tests/test-data-base64.sh
index cc53edf..b755557 100755
--- a/tests/test-data-base64.sh
+++ b/tests/test-data-base64.sh
@@ -37,9 +37,7 @@ source ./functions.sh
set -e
set -x
-files="data-base64.out data-base64.pid data-base64.sock"
-rm -f $files
-cleanup_fn rm -f $files
+requires qemu-io --version
# Test if the base64 parameter is supported in this build.
if ! nbdkit data --dump-plugin | grep -sq "data_base64=yes"; then
@@ -47,11 +45,9 @@ if ! nbdkit data --dump-plugin | grep -sq "data_base64=yes";
then
exit 77
fi
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
+files="data-base64.out data-base64.pid data-base64.sock"
+rm -f $files
+cleanup_fn rm -f $files
# Run nbdkit.
start_nbdkit -P data-base64.pid -U data-base64.sock \
diff --git a/tests/test-data-file.sh b/tests/test-data-file.sh
index ba7288c..c6792e7 100755
--- a/tests/test-data-file.sh
+++ b/tests/test-data-file.sh
@@ -37,16 +37,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="data-file.out data-file.pid data-file.sock data-hello.txt"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
rm -f data-hello.txt
for i in {0..1000}; do
echo -n "hello " >> data-hello.txt
diff --git a/tests/test-data-raw.sh b/tests/test-data-raw.sh
index 555b77c..c71afbf 100755
--- a/tests/test-data-raw.sh
+++ b/tests/test-data-raw.sh
@@ -37,16 +37,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="data-raw.out data-raw.pid data-raw.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit.
start_nbdkit -P data-raw.pid -U data-raw.sock --export "" \
data raw=123 size=512
diff --git a/tests/test-eflags.sh b/tests/test-eflags.sh
index 5ac5e9e..41793e8 100755
--- a/tests/test-eflags.sh
+++ b/tests/test-eflags.sh
@@ -45,16 +45,13 @@
source ./functions.sh
set -e
-if ! socat -h >/dev/null; then
- echo "$0: 'socat' command not available"
- exit 77
-fi
+requires socat -h
# Check 'od' command exists.
-if ! od </dev/null >/dev/null; then
- echo "$0: 'od' command not available"
- exit 77
-fi
+#
+# Note that requires redirects stdin/stdout to /dev/null which
+# prevents od from hanging in this test.
+requires od
files="eflags.out"
rm -f $files
diff --git a/tests/test-error0.sh b/tests/test-error0.sh
index 93170a9..96a221c 100755
--- a/tests/test-error0.sh
+++ b/tests/test-error0.sh
@@ -35,11 +35,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
+requires qemu-io --version
files="error0.sock error0.pid"
rm -f $files
diff --git a/tests/test-error10.sh b/tests/test-error10.sh
index 278bae4..d5ab1d4 100755
--- a/tests/test-error10.sh
+++ b/tests/test-error10.sh
@@ -35,11 +35,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
+requires qemu-io --version
files="error10.sock error10.pid"
rm -f $files
diff --git a/tests/test-error100.sh b/tests/test-error100.sh
index 997de9d..1979717 100755
--- a/tests/test-error100.sh
+++ b/tests/test-error100.sh
@@ -35,11 +35,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
+requires qemu-io --version
files="error100.sock error100.pid"
rm -f $files
diff --git a/tests/test-full.sh b/tests/test-full.sh
index 171d716..71d9c7c 100755
--- a/tests/test-full.sh
+++ b/tests/test-full.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --version
+
files="full.pid full.sock full.out"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with the full plugin.
start_nbdkit -P full.pid -U full.sock full size=1M
diff --git a/tests/test-ip.sh b/tests/test-ip.sh
index d7d5323..f5dcd87 100755
--- a/tests/test-ip.sh
+++ b/tests/test-ip.sh
@@ -37,26 +37,17 @@
source ./functions.sh
set -e
-rm -f ip.pid ipv4.out ipv6.out
-cleanup_fn rm -f ip.pid ipv4.out ipv6.out
+requires ss --version
+requires ip -V
+requires qemu-img --version
-# Don't fail if certain commands aren't available.
-if ! ss --version; then
- echo "$0: 'ss' command not available"
- exit 77
-fi
-if ! command -v qemu-img; then
- echo "$0: 'qemu-img' command not available"
- exit 77
-fi
if ! qemu-img --help | grep -- --image-opts; then
echo "$0: 'qemu-img' command does not have the --image-opts
option"
exit 77
fi
-if ! ip -V; then
- echo "$0: 'ip' command not available"
- exit 77
-fi
+
+rm -f ip.pid ipv4.out ipv6.out
+cleanup_fn rm -f ip.pid ipv4.out ipv6.out
# Find an unused port to listen on.
for port in {49152..65535}; do
diff --git a/tests/test-memory-largest-for-qemu.sh
b/tests/test-memory-largest-for-qemu.sh
index 2b56f30..a89fd0d 100755
--- a/tests/test-memory-largest-for-qemu.sh
+++ b/tests/test-memory-largest-for-qemu.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --version
+
files="memory-largest-for-qemu.out memory-largest-for-qemu.pid
memory-largest-for-qemu.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with memory plugin.
# size = (2^63-1) & ~511 which is the largest supported by qemu.
start_nbdkit -P memory-largest-for-qemu.pid -U memory-largest-for-qemu.sock \
diff --git a/tests/test-memory-largest.sh b/tests/test-memory-largest.sh
index a6c269e..154b331 100755
--- a/tests/test-memory-largest.sh
+++ b/tests/test-memory-largest.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --version
+
files="memory-largest.out memory-largest.pid memory-largest.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with memory plugin.
# size = 2^63-1
start_nbdkit -P memory-largest.pid -U memory-largest.sock \
diff --git a/tests/test-offset2.sh b/tests/test-offset2.sh
index 4e1ef2b..a958f62 100755
--- a/tests/test-offset2.sh
+++ b/tests/test-offset2.sh
@@ -37,16 +37,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="offset2.out offset2.pid offset2.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with pattern plugin and offset filter in front.
# 8070450532247927809 = 7E - 1023
start_nbdkit -P offset2.pid -U offset2.sock \
diff --git a/tests/test-parallel-file.sh b/tests/test-parallel-file.sh
index 1d27f93..0fabd4f 100755
--- a/tests/test-parallel-file.sh
+++ b/tests/test-parallel-file.sh
@@ -34,14 +34,8 @@
source ./functions.sh
# Check file-data was created by Makefile and qemu-io exists.
-if ! test -f file-data; then
- echo "$0: missing file-data"
- exit 77
-fi
-if ! qemu-io --version; then
- echo "$0: missing qemu-io"
- exit 77
-fi
+requires test -f file-data
+requires qemu-io --version
cleanup_fn rm -f test-parallel-file.data test-parallel-file.out
diff --git a/tests/test-parallel-nbd.sh b/tests/test-parallel-nbd.sh
index e4a2352..cb81ec9 100755
--- a/tests/test-parallel-nbd.sh
+++ b/tests/test-parallel-nbd.sh
@@ -34,14 +34,8 @@
source ./functions.sh
# Check file-data was created by Makefile and qemu-io exists.
-if ! test -f file-data; then
- echo "$0: missing file-data"
- exit 77
-fi
-if ! qemu-io --version; then
- echo "$0: missing qemu-io"
- exit 77
-fi
+requires test -f file-data
+requires qemu-io --version
# We require --exit-with-parent to work
( nbdkit --exit-with-parent --help ) >/dev/null 2>&1 ||
diff --git a/tests/test-partition1.sh b/tests/test-partition1.sh
index 1bb0240..50d4087 100755
--- a/tests/test-partition1.sh
+++ b/tests/test-partition1.sh
@@ -35,29 +35,15 @@ source ./functions.sh
set -e
set -x
+requires sfdisk --help
+requires test -r /dev/urandom
+requires qemu-img --version
+
d="partition1.d"
rm -rf $d
cleanup_fn rm -rf $d
mkdir $d
-# Test that sfdisk is available and working.
-if ! sfdisk --help >/dev/null; then
- echo "$0: missing or broken sfdisk"
- exit 77
-fi
-
-# Test that /dev/urandom exists and can be read.
-if ! test -r /dev/urandom; then
- echo "$0: mising or unreadable /dev/urandom"
- exit 77
-fi
-
-# Test that qemu-img is available and working.
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
-
test ()
{
label=$1
diff --git a/tests/test-partition2.sh b/tests/test-partition2.sh
index 71bac55..4678a5c 100755
--- a/tests/test-partition2.sh
+++ b/tests/test-partition2.sh
@@ -35,11 +35,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-img is available and working.
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
+requires qemu-img --version
files="partition2.log"
rm -f $files
diff --git a/tests/test-partitioning1.sh b/tests/test-partitioning1.sh
index f705dc8..f0c779d 100755
--- a/tests/test-partitioning1.sh
+++ b/tests/test-partitioning1.sh
@@ -39,16 +39,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-img --version
+
files="partitioning1.out partitioning1-p1 partitioning1-p2 partitioning1-p3
partitioning1-p4 partitioning1-p5 partitioning1-p6"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-img works
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
-
# Create some odd-sized partitions. These exist to test alignment and
# padding.
truncate -s 1 partitioning1-p1
diff --git a/tests/test-partitioning2.sh b/tests/test-partitioning2.sh
index 411f392..9f2df11 100755
--- a/tests/test-partitioning2.sh
+++ b/tests/test-partitioning2.sh
@@ -40,16 +40,12 @@ source ./functions.sh
set -e
set -x
+requires mke2fs -V
+
files="partitioning2.pid partitioning2.sock partitioning2.fs partitioning2.p1
partitioning2.p3"
rm -f $files
cleanup_fn rm -f $files
-# Test that mke2fs works
-if ! mke2fs -V; then
- echo "$0: missing or broken mke2fs"
- exit 77
-fi
-
# Create partitions before and after.
truncate -s 1 partitioning2.p1
truncate -s 10M partitioning2.p3
diff --git a/tests/test-partitioning4.sh b/tests/test-partitioning4.sh
index 8988a5c..8c9a93e 100755
--- a/tests/test-partitioning4.sh
+++ b/tests/test-partitioning4.sh
@@ -43,11 +43,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-img works
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
+requires qemu-img --version
d=partitioning4.d
rm -rf $d
diff --git a/tests/test-partitioning5.sh b/tests/test-partitioning5.sh
index b4cb6bf..feeb738 100755
--- a/tests/test-partitioning5.sh
+++ b/tests/test-partitioning5.sh
@@ -41,18 +41,14 @@ source ./functions.sh
set -e
set -x
+requires mke2fs -V
+
files="partitioning5.pid partitioning5.sock
partitioning5.fs
partitioning5.p1 partitioning5.p2 partitioning5.p3 partitioning5.p5
partitioning5.p6 partitioning5.p7 partitioning5.p8 partitioning5.p9 partitioning5.p10
partitioning5.p11 partitioning5.p13"
rm -f $files
cleanup_fn rm -f $files
-# Test that mke2fs works
-if ! mke2fs -V; then
- echo "$0: missing or broken mke2fs"
- exit 77
-fi
-
# Create partitions before and after.
truncate -s 1 partitioning5.p1
truncate -s 10M partitioning5.p2
diff --git a/tests/test-partitioning6.sh b/tests/test-partitioning6.sh
index 6dbb215..400bd8e 100755
--- a/tests/test-partitioning6.sh
+++ b/tests/test-partitioning6.sh
@@ -43,11 +43,7 @@ source ./functions.sh
set -e
set -x
-# Test that qemu-img works
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
+requires qemu-img --version
d=partitioning6.d
rm -rf $d
diff --git a/tests/test-pattern-largest-for-qemu.sh
b/tests/test-pattern-largest-for-qemu.sh
index 1883fe6..93cc1b7 100755
--- a/tests/test-pattern-largest-for-qemu.sh
+++ b/tests/test-pattern-largest-for-qemu.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --version
+
files="pattern-largest-for-qemu.out pattern-largest-for-qemu.pid
pattern-largest-for-qemu.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with pattern plugin.
# size = (2^63-1) & ~511 which is the largest supported by qemu.
start_nbdkit -P pattern-largest-for-qemu.pid -U pattern-largest-for-qemu.sock \
diff --git a/tests/test-pattern-largest.sh b/tests/test-pattern-largest.sh
index de5e1d7..0b6d272 100755
--- a/tests/test-pattern-largest.sh
+++ b/tests/test-pattern-largest.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --version
+
files="pattern-largest.out pattern-largest.pid pattern-largest.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with pattern plugin.
# size = 2^63-1
start_nbdkit -P pattern-largest.pid -U pattern-largest.sock \
diff --git a/tests/test-single.sh b/tests/test-single.sh
index 3739df2..3462d3d 100755
--- a/tests/test-single.sh
+++ b/tests/test-single.sh
@@ -35,15 +35,8 @@ source ./functions.sh
set -e
set -x
-if ! socat -h; then
- echo "$0: 'socat' command not available"
- exit 77
-fi
-
-if ! qemu-img --help >/dev/null; then
- echo "$0: 'qemu-img' command not available"
- exit 77
-fi
+requires socat -h
+requires qemu-img --version
files="single.sock single.disk"
rm -f $files
diff --git a/tests/test-tls-psk.sh b/tests/test-tls-psk.sh
index 819d63d..bc4140f 100755
--- a/tests/test-tls-psk.sh
+++ b/tests/test-tls-psk.sh
@@ -35,15 +35,9 @@ source ./functions.sh
set -e
set -x
-# Don't fail if certain commands aren't available.
-if ! ss --version; then
- echo "$0: 'ss' command not available"
- exit 77
-fi
-if ! command -v qemu-img > /dev/null; then
- echo "$0: 'qemu-img' command not available"
- exit 77
-fi
+requires ss --version
+requires qemu-img --version
+
if ! qemu-img --help | grep -- --object; then
echo "$0: 'qemu-img' command does not have the --object option"
exit 77
diff --git a/tests/test-tls.sh b/tests/test-tls.sh
index 114ea35..9f94ba1 100755
--- a/tests/test-tls.sh
+++ b/tests/test-tls.sh
@@ -35,15 +35,9 @@ source ./functions.sh
set -e
set -x
-# Don't fail if certain commands aren't available.
-if ! ss --version; then
- echo "$0: 'ss' command not available"
- exit 77
-fi
-if ! command -v qemu-img > /dev/null; then
- echo "$0: 'qemu-img' command not available"
- exit 77
-fi
+requires ss --version
+requires qemu-img --version
+
if ! qemu-img --help | grep -- --object; then
echo "$0: 'qemu-img' command does not have the --object option"
exit 77
diff --git a/tests/test-truncate1.sh b/tests/test-truncate1.sh
index eb02a69..e09415a 100755
--- a/tests/test-truncate1.sh
+++ b/tests/test-truncate1.sh
@@ -37,16 +37,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="truncate1.out truncate1.pid truncate1.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with pattern plugin and truncate filter in front.
start_nbdkit -P truncate1.pid -U truncate1.sock \
--filter=truncate \
diff --git a/tests/test-truncate2.sh b/tests/test-truncate2.sh
index 4a3a89e..f290f29 100755
--- a/tests/test-truncate2.sh
+++ b/tests/test-truncate2.sh
@@ -37,16 +37,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="truncate2.out truncate2.pid truncate2.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with pattern plugin and truncate filter in front.
start_nbdkit -P truncate2.pid -U truncate2.sock \
--filter=truncate \
diff --git a/tests/test-truncate3.sh b/tests/test-truncate3.sh
index 0ff1cbe..de44a17 100755
--- a/tests/test-truncate3.sh
+++ b/tests/test-truncate3.sh
@@ -38,16 +38,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-img --version
+
files="truncate3.out truncate3.pid truncate3.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-img works
-if ! qemu-img --help >/dev/null; then
- echo "$0: missing or broken qemu-img"
- exit 77
-fi
-
# Run nbdkit with pattern plugin and truncate filter in front.
start_nbdkit -P truncate3.pid -U truncate3.sock \
--filter=truncate \
diff --git a/tests/test-zero.sh b/tests/test-zero.sh
index 3c3a0ca..2bd4a48 100755
--- a/tests/test-zero.sh
+++ b/tests/test-zero.sh
@@ -35,11 +35,7 @@ source ./functions.sh
set -x
set -e
-# Check qemu-img exists.
-if ! qemu-img --version; then
- echo "$0: missing qemu-img"
- exit 77
-fi
+requires qemu-img --version
files="test-zero.out"
rm -f $files
--
2.20.1