Richard W.M. Jones
2020-Oct-05 19:52 UTC
[Libguestfs] [PATCH nbdkit] tests/test-exportname.sh: Fix test.
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
Eric Blake
2020-Oct-05 19:58 UTC
Re: [Libguestfs] [PATCH nbdkit] tests/test-exportname.sh: Fix test.
On 10/5/20 2:52 PM, Richard W.M. Jones wrote:> 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(-)Looks good to me. Maybe we should try harder in nbdinfo to produce no output on stdout except on success, but we'll need this workaround for released versions regardless of whether we make that effort in libnbd. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org