Patchwork [4/7] block: qemu-iotests, add quotes to $TEST_IMG usage in 019

login
register
mail settings
Submitter Jeff Cody
Date Oct. 31, 2013, 3:57 p.m.
Message ID <f63a770d20a201cdbaa6c38d827a8eb74048f2eb.1383231037.git.jcody@redhat.com>
Download mbox | patch
Permalink /patch/287565/
State New
Headers show

Comments

Jeff Cody - Oct. 31, 2013, 3:57 p.m.
There were still instances of $TEST_IMG not being properly quoted.
This was in the usage of a string built up for a 'for' loop; modify
the loop so we can quote $TEST_IMG properly.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 tests/qemu-iotests/019 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Eric Blake - Oct. 31, 2013, 5 p.m.
On 10/31/2013 09:57 AM, Jeff Cody wrote:
> There were still instances of $TEST_IMG not being properly quoted.
> This was in the usage of a string built up for a 'for' loop; modify
> the loop so we can quote $TEST_IMG properly.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  tests/qemu-iotests/019 | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

> 
> diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
> index cd3582c..5bb18d0 100755
> --- a/tests/qemu-iotests/019
> +++ b/tests/qemu-iotests/019
> @@ -90,12 +90,12 @@ mv "$TEST_IMG" "$TEST_IMG.orig"
>  # Test the conversion twice: One test with the old-style -B option and another
>  # one with -o backing_file
>  
> -for backing_option in "-B $TEST_IMG.base" "-o backing_file=$TEST_IMG.base"; do
> +for backing_option in "-B " "-o backing_file="; do
>  
>      echo
> -    echo Testing conversion with $backing_option | _filter_testdir | _filter_imgfmt
> +    echo Testing conversion with $backing_option$TEST_IMG.base | _filter_testdir | _filter_imgfmt

If $TEST_IMG has 2 consecutive spaces [*], this echo produces spurious
output (flattening to only 1 space).  To be completely robust, you must
quote here in the same manner...

>      echo
> -    $QEMU_IMG convert -O $IMGFMT $backing_option "$TEST_IMG.orig" "$TEST_IMG"
> +    $QEMU_IMG convert -O $IMGFMT $backing_option"$TEST_IMG.base" "$TEST_IMG.orig" "$TEST_IMG"

...as what you execute.  But as that corner case of misquoting doesn't
fail the test, your patch is a strict improvement, so I'm okay whether
you post a v2, or whether you keep this as-is and add:

Reviewed-by: Eric Blake <eblake@redhat.com>

[*] My favorite test for quoting bugs is renaming a directory to use
'two  spaces', because some quoting bugs are missed when you only test
'one space'.

Patch

diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
index cd3582c..5bb18d0 100755
--- a/tests/qemu-iotests/019
+++ b/tests/qemu-iotests/019
@@ -90,12 +90,12 @@  mv "$TEST_IMG" "$TEST_IMG.orig"
 # Test the conversion twice: One test with the old-style -B option and another
 # one with -o backing_file
 
-for backing_option in "-B $TEST_IMG.base" "-o backing_file=$TEST_IMG.base"; do
+for backing_option in "-B " "-o backing_file="; do
 
     echo
-    echo Testing conversion with $backing_option | _filter_testdir | _filter_imgfmt
+    echo Testing conversion with $backing_option$TEST_IMG.base | _filter_testdir | _filter_imgfmt
     echo
-    $QEMU_IMG convert -O $IMGFMT $backing_option "$TEST_IMG.orig" "$TEST_IMG"
+    $QEMU_IMG convert -O $IMGFMT $backing_option"$TEST_IMG.base" "$TEST_IMG.orig" "$TEST_IMG"
 
     echo "Checking if backing clusters are allocated when they shouldn't"
     echo