[Libguestfs] [PATCH nbdkit] tests/test-exportname.sh: Fix test.

Richard W.M. Jones rjones at redhat.com
Mon Oct 5 19:52:01 UTC 2020


When “nbdkit ... --run 'nbdinfo ...' > out” is expected to fail, we
cannot be sure of the content of the "out" file.  In particular
nbdinfo produces its output incrementally, so in JSON mode there's
usually a stray "{" in the output, and in non-JSON mode it usually
prints the "protocol: " line.

Thus it's not correct to test for the output file being non-empty.

Remove these lines which caused the test to fail.  However I replaced
them with "cat" for diagnostic purposes.

Fixes: commit 7623b2cc45078cca88fdd2d96c70c7f82a0db49d
---
 tests/test-exportname.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test-exportname.sh b/tests/test-exportname.sh
index 2ec45023..54e04f86 100755
--- a/tests/test-exportname.sh
+++ b/tests/test-exportname.sh
@@ -172,12 +172,12 @@ test "$(jq -c "$query" exportname.out)" = '[["c","cc",3]]'
 # Test strict mode
 nbdkit -U - --filter=exportname sh exportname.sh exportname-strict=true \
        --run 'nbdinfo --no-content --json "$uri"' > exportname.out && fail=1
-test ! -s exportname.out
+cat exportname.out
 
 nbdkit -U - --filter=exportname sh exportname.sh exportname-strict=true \
        exportname=a exportname=b exportname=c \
        --run 'nbdinfo --no-content --json "$uri"' > exportname.out && fail=1
-test ! -s exportname.out
+cat exportname.out
 
 nbdkit -U - --filter=exportname sh exportname.sh exportname-strict=true \
        exportname=a exportname=b exportname= default-export=a\
-- 
2.27.0




More information about the Libguestfs mailing list