On 1/23/19 5:17 AM, Richard W.M. Jones wrote:
---
tests/functions.sh.in | 17 ++++++++++++++++-
tests/test-memory-largest.sh | 8 ++------
tests/test-partition1.sh | 22 ++++------------------
tests/test-partition2.sh | 6 +-----
tests/test-pattern-largest.sh | 8 ++------
5 files changed, 25 insertions(+), 36 deletions(-)
+# 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 --help
+requires ()
+{
+ "$@" || {
I'd consider running:
( "$@" ) </dev/null >/dev/null 2>&1 || {
just to ensure that a missing executable doesn't leak a shell error
message or unrelated verbose program output, and so that the program
under test is less likely to hang waiting for input if it found some
other program by the same name but with different usage conventions.
+++ b/tests/test-memory-largest.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --help
+
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
For example, if you don't make require() silence stdout, this change
becomes more verbose in the logs, for no real benefit.
Otherwise, the idea makes total sense, so I'm looking forward to v2.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org