[Libguestfs] [PATCH nbdkit] tests/tls: fix qemu-img check

Pino Toscano ptoscano at redhat.com
Mon Oct 9 07:27:44 UTC 2017


Old qemu-img versions return 1 instead of 0 for --help, failing the
presence check: hence, which to `command` for checking the presence of
qemu-img.

Also, check that qemu-img actually has the --object option, since the
test uses it.
---
 tests/test-tls.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/test-tls.sh b/tests/test-tls.sh
index 73d44fa..7a6c949 100755
--- a/tests/test-tls.sh
+++ b/tests/test-tls.sh
@@ -40,10 +40,14 @@ if ! ss --version; then
     echo "$0: 'ss' command not available"
     exit 77
 fi
-if ! qemu-img --help; then
+if ! command -v qemu-img > /dev/null; then
     echo "$0: 'qemu-img' command not available"
     exit 77
 fi
+if ! qemu-img --help | grep -- --object; then
+    echo "$0: 'qemu-img' command does not have the --object option"
+    exit 77
+fi
 
 # Does the nbdkit binary support TLS?
 if ! nbdkit --dump-config | grep -sq tls=yes; then
-- 
2.13.6




More information about the Libguestfs mailing list