[Qemu-devel] [PATCH v5 09/10] qemu-iotests: add option to save temp files on error

Jeff Cody posted 10 patches 8 years, 3 months ago
[Qemu-devel] [PATCH v5 09/10] qemu-iotests: add option to save temp files on error
Posted by Jeff Cody 8 years, 3 months ago
Now that ./check takes care of cleaning up after each tests, it
can also selectively not clean up.  Add option to leave all output from
tests intact if that test encountered an error.

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

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 057ea39..a66f7b0 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -125,6 +125,7 @@ sortme=false
 expunge=true
 have_test_arg=false
 cachemode=false
+save_on_err=false
 
 tmp="${TEST_DIR}"/$$
 rm -f $tmp.list $tmp.tmp $tmp.sed
@@ -263,6 +264,8 @@ other options
     -o options          -o options to pass to qemu-img create/convert
     -T                  output timestamps
     -c mode             cache mode
+    -s                  save test scratch directory on test failure
+
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -435,6 +438,10 @@ testlist options
             xgroup=true
             xpand=false
             ;;
+        -s)
+            save_on_err=true
+            xpand=false
+            ;;
         '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
             echo "No tests?"
             status=1
@@ -853,7 +860,11 @@ do
         _cleanup_protocols
         _cleanup_qemu
         )
-        rm -rf "$TEST_DIR_SEQ"
+
+        if [ "$save_on_err" != "true" ] || [ "$err" != "true" ]
+        then
+            rm -rf "$TEST_DIR_SEQ"
+        fi
 
     fi
 
-- 
2.9.5


Re: [Qemu-devel] [PATCH v5 09/10] qemu-iotests: add option to save temp files on error
Posted by Eric Blake 8 years, 3 months ago
On 10/17/2017 11:31 AM, Jeff Cody wrote:
> Now that ./check takes care of cleaning up after each tests, it
> can also selectively not clean up.  Add option to leave all output from
> tests intact if that test encountered an error.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  tests/qemu-iotests/check | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index 057ea39..a66f7b0 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -125,6 +125,7 @@ sortme=false
>  expunge=true
>  have_test_arg=false
>  cachemode=false
> +save_on_err=false
>  
>  tmp="${TEST_DIR}"/$$
>  rm -f $tmp.list $tmp.tmp $tmp.sed
> @@ -263,6 +264,8 @@ other options
>      -o options          -o options to pass to qemu-img create/convert
>      -T                  output timestamps
>      -c mode             cache mode
> +    -s                  save test scratch directory on test failure

Is there an easy way to force all tests to fail (and thus preserve the
scratch directory for inspection, even though the test normally would
succeed)?  It might serve as a useful double-check that you got
everything in this series, maybe even worth documenting in the commit
messages.

> +
> +        if [ "$save_on_err" != "true" ] || [ "$err" != "true" ]
> +        then
> +            rm -rf "$TEST_DIR_SEQ"
> +        fi

I suppose the easiest way is to hack this 'if'.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org