[Libguestfs] [PATCH nbdkit] tests: Remove QEMU_IO / HAVE_QEMU_IO.

Richard W.M. Jones rjones at redhat.com
Sat Jan 27 11:41:49 UTC 2018


This is for consistency with qemu-img, socat, ss, etc where we test
for these binaries at run time.
---
 configure.ac                |  4 ----
 tests/Makefile.am           |  8 +++-----
 tests/test-parallel-file.sh | 21 +++++++++++++--------
 tests/test-parallel-nbd.sh  | 21 +++++++++++++--------
 4 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6025ce0..30e4c43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -407,10 +407,6 @@ dnl Check for guestfish (only needed for some of the tests).
 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
 
-dnl Check for qemu-io (only needed for some of the tests).
-AC_CHECK_PROG([QEMU_IO], [qemu-io], [qemu-io], [no])
-AM_CONDITIONAL([HAVE_QEMU_IO], [test "x$QEMU_IO" != "xno"])
-
 dnl See plugins/vddk/README.VDDK.
 AC_CHECK_SIZEOF([size_t])
 AS_IF([test "x$ac_cv_sizeof_size_t" = "x4"],[bits=32],[bits=64])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ec33109..9be57e6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -178,11 +178,9 @@ file-data:
 
 # While most tests need libguestfs, testing parallel I/O is easier when
 # using qemu-io to kick off asynchronous requests.
-if HAVE_QEMU_IO
-TESTS_ENVIRONMENT += QEMU_IO=$(QEMU_IO)
-TESTS += test-parallel-file.sh
-TESTS += test-parallel-nbd.sh
-endif HAVE_QEMU_IO
+TESTS += \
+	test-parallel-file.sh \
+	test-parallel-nbd.sh
 
 # Most in-depth tests need libguestfs, since that is a convenient way to
 # drive qemu.
diff --git a/tests/test-parallel-file.sh b/tests/test-parallel-file.sh
index ed1f99c..695c53b 100755
--- a/tests/test-parallel-file.sh
+++ b/tests/test-parallel-file.sh
@@ -31,14 +31,19 @@
 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 
-# Makefile sets $QEMU_IO and builds file-data, but it's also nice if the
-# script runs again standalone afterwards for diagnosing any failures
-test -f file-data || { echo "Missing file-data"; exit 77; }
-: ${QEMU_IO=qemu-io}
+# 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
 
 # Sanity check that qemu-io can issue parallel requests
-$QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush \
-  file-data || { echo "'$QEMU_IO' can't drive parallel requests"; exit 77; }
+qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush \
+  file-data || { echo "'qemu-io' can't drive parallel requests"; exit 77; }
 
 # Set up the file plugin to delay both reads and writes (for a good chance
 # that parallel requests are in flight), and with writes longer than reads
@@ -50,7 +55,7 @@ trap 'rm -f test-parallel-file.out' 0 1 2 3 15
 
 # With --threads=1, the write should complete first because it was issued first
 nbdkit -v -t 1 -U - --filter=delay file file=file-data wdelay=2 rdelay=1 --run '
-  $QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
+  qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
 ' | tee test-parallel-file.out
 if test "$(grep '1/1' test-parallel-file.out)" != \
 "wrote 1/1 bytes at offset 1
@@ -60,7 +65,7 @@ fi
 
 # With default --threads, the faster read should complete first
 nbdkit -v -U - --filter=delay file file=file-data wdelay=2 rdelay=1 --run '
-  $QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
+  qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
 ' | tee test-parallel-file.out
 if test "$(grep '1/1' test-parallel-file.out)" != \
 "read 1/1 bytes at offset 0
diff --git a/tests/test-parallel-nbd.sh b/tests/test-parallel-nbd.sh
index 244faf6..eda45df 100755
--- a/tests/test-parallel-nbd.sh
+++ b/tests/test-parallel-nbd.sh
@@ -31,14 +31,19 @@
 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 
-# Makefile sets $QEMU_IO and builds file-data, but it's also nice if the
-# script runs again standalone afterwards for diagnosing any failures
-test -f file-data || { echo "Missing file-data"; exit 77; }
-: ${QEMU_IO=qemu-io}
+# 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
 
 # Sanity check that qemu-io can issue parallel requests
-$QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush \
-  file-data || { echo "'$QEMU_IO' can't drive parallel requests"; exit 77; }
+qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush \
+  file-data || { echo "'qemu-io' can't drive parallel requests"; exit 77; }
 
 # We require --exit-with-parent to work
 ( nbdkit --exit-with-parent --help ) >/dev/null 2>&1 ||
@@ -59,7 +64,7 @@ nbdkit --exit-with-parent -v -U test-parallel-nbd.sock \
 
 # With --threads=1, the write should complete first because it was issued first
 nbdkit -v -t 1 -U - nbd socket=test-parallel-nbd.sock --run '
-  $QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
+  qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
 ' | tee test-parallel-nbd.out
 if test "$(grep '1/1' test-parallel-nbd.out)" != \
 "wrote 1/1 bytes at offset 1
@@ -69,7 +74,7 @@ fi
 
 # With default --threads, the faster read should complete first
 nbdkit -v -U - nbd socket=test-parallel-nbd.sock --run '
-  $QEMU_IO -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
+  qemu-io -f raw -c "aio_write -P 2 1 1" -c "aio_read -P 1 0 1" -c aio_flush $nbd
 ' | tee test-parallel-nbd.out
 if test "$(grep '1/1' test-parallel-nbd.out)" != \
 "read 1/1 bytes at offset 0
-- 
2.13.2




More information about the Libguestfs mailing list