diff mbox

[v5,01/10] qemu-iotests: refuse to run if TEST_DIR contains spaces

Message ID 399631b6632f0a605339391ff76c90468ebd54ee.1508257445.git.jcody@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Cody Oct. 17, 2017, 4:31 p.m. UTC
Currently, not all qemu-iotests work if TEST_DIR has spaces, and they
also might not be safe.  Refuse to run if TEST_DIR in this case, at
least until all tests are fixed sometime in the future.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 tests/qemu-iotests/check | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Eric Blake Oct. 18, 2017, 1:03 a.m. UTC | #1
On 10/17/2017 11:31 AM, Jeff Cody wrote:
> Currently, not all qemu-iotests work if TEST_DIR has spaces, and they
> also might not be safe.  Refuse to run if TEST_DIR in this case, at
> least until all tests are fixed sometime in the future.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  tests/qemu-iotests/check | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index e6b6ff7..e2163cc 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -102,6 +102,14 @@ if [ -z "$TEST_DIR" ]; then
>          TEST_DIR=`pwd`/scratch
>  fi
>  
> +case $TEST_DIR in
> +    *[[:blank:]]*)
> +        echo "The TEST_DIR pathname '$TEST_DIR' contains whitespace. "

Echoes a trailing space. Do we care?

> +        echo "This is currently unsupported by qemu-iotests"

Is it just whitespace, or should we also be wary of other shell
metacharacters (such as quotes or glob characters)?  In test 197, I did
an alternative check for anything that is not alphanumeric, -, or _ (and
allowing / between names).

> +        exit 1
> +        ;;
> +esac
> +
>  if [ ! -e "$TEST_DIR" ]; then
>          mkdir "$TEST_DIR"
>  fi
>
Jeff Cody Oct. 18, 2017, 3:05 a.m. UTC | #2
On Tue, Oct 17, 2017 at 08:03:56PM -0500, Eric Blake wrote:
> On 10/17/2017 11:31 AM, Jeff Cody wrote:
> > Currently, not all qemu-iotests work if TEST_DIR has spaces, and they
> > also might not be safe.  Refuse to run if TEST_DIR in this case, at
> > least until all tests are fixed sometime in the future.
> > 
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > ---
> >  tests/qemu-iotests/check | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> > index e6b6ff7..e2163cc 100755
> > --- a/tests/qemu-iotests/check
> > +++ b/tests/qemu-iotests/check
> > @@ -102,6 +102,14 @@ if [ -z "$TEST_DIR" ]; then
> >          TEST_DIR=`pwd`/scratch
> >  fi
> >  
> > +case $TEST_DIR in
> > +    *[[:blank:]]*)
> > +        echo "The TEST_DIR pathname '$TEST_DIR' contains whitespace. "
> 
> Echoes a trailing space. Do we care?
> 

Heh, spurious whitespcae, a bit ironic, I suppose...

Might as well take care of it with a v6, along with expanding the tests as
you hint at below.

> > +        echo "This is currently unsupported by qemu-iotests"
> 
> Is it just whitespace, or should we also be wary of other shell
> metacharacters (such as quotes or glob characters)?  In test 197, I did
> an alternative check for anything that is not alphanumeric, -, or _ (and
> allowing / between names).

I know that '-' works, because for years my work directory has been called
"qemu-kvm".  I'm not sure about globbing characters like *, or quotes, but
probably not a bad idea to exclude them as well (although, someone that
uses '*' in their directory names is probably no stranger to data
catastrophe!).

> 
> > +        exit 1
> > +        ;;
> > +esac
> > +
> >  if [ ! -e "$TEST_DIR" ]; then
> >          mkdir "$TEST_DIR"
> >  fi
> > 
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
>
diff mbox

Patch

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index e6b6ff7..e2163cc 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -102,6 +102,14 @@  if [ -z "$TEST_DIR" ]; then
         TEST_DIR=`pwd`/scratch
 fi
 
+case $TEST_DIR in
+    *[[:blank:]]*)
+        echo "The TEST_DIR pathname '$TEST_DIR' contains whitespace. "
+        echo "This is currently unsupported by qemu-iotests"
+        exit 1
+        ;;
+esac
+
 if [ ! -e "$TEST_DIR" ]; then
         mkdir "$TEST_DIR"
 fi