Skip to contentSkip to conversation

qemu-iotests: place output in unique dir

PATCH In review Jeff Cody 5 participants 22 messages Aug 30, 2017 – Sep 5, 2017

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

v3 cover qemu-iotests: place output in unique dir

Differences v2 -> v3:

git-backport-diff -r qemu/master..devel-iotests -u github/devel-next Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/5:[----] [--] 'qemu-iotests: set TEST_DIR to a unique dir for each test'
^^^^^^
No patch diff, but fixed typo in commit message. [Thanks Eric]

002/5:[0006] [FC] 'qemu-iotests: remove file cleanup from bash tests'
^^^^^^
Picked up test 192 in the patch.

003/5:[down] 'qemu-iotests: add 'blind_remove' for python tests' 004/5:[down] 'qemu-iotests: make python tests attempt to leave intermediate files'
^^^^^^
Two new tests, to help address python intermediate files.

005/5:[0005] [FC] 'qemu-iotests: add option to save temp files on error'
^^^^^^
Added TODO regarding python tests. [Thanks Markus] Dropped Eric's r-b, in case he is not OK with the TODO wording

Rebased to v2.10.0.

This series does 2 things:

1.) Sets TEST_DIR to a unique subdirectory for each test 2.) Has './check' be responsible for removing temporary files 3.) Add option to './check' to retain temporary files in case of error

Jeff Cody (5):
qemu-iotests: set TEST_DIR to a unique dir for each test
qemu-iotests: remove file cleanup from bash tests
qemu-iotests: add 'blind_remove' for python tests
qemu-iotests: make python tests attempt to leave intermediate files
qemu-iotests: add option to save temp files on error

 tests/qemu-iotests/001        |  6 ----
 tests/qemu-iotests/002        |  6 ----
 tests/qemu-iotests/003        |  6 ----
 tests/qemu-iotests/004        |  6 ----
 tests/qemu-iotests/005        |  6 ----
 tests/qemu-iotests/007        |  7 -----
 tests/qemu-iotests/008        |  6 ----
 tests/qemu-iotests/009        |  6 ----
 tests/qemu-iotests/010        |  6 ----
 tests/qemu-iotests/011        |  6 ----
 tests/qemu-iotests/012        |  6 ----
 tests/qemu-iotests/013        |  6 ----
 tests/qemu-iotests/014        |  6 ----
 tests/qemu-iotests/015        |  7 -----
 tests/qemu-iotests/017        |  6 ----
 tests/qemu-iotests/018        |  6 ----
 tests/qemu-iotests/019        |  8 -----
 tests/qemu-iotests/020        |  8 -----
 tests/qemu-iotests/021        |  6 ----
 tests/qemu-iotests/022        |  6 ----
 tests/qemu-iotests/023        |  6 ----
 tests/qemu-iotests/024        |  8 -----
 tests/qemu-iotests/025        |  6 ----
 tests/qemu-iotests/026        |  7 -----
 tests/qemu-iotests/027        |  6 ----
 tests/qemu-iotests/028        |  8 -----
 tests/qemu-iotests/029        |  7 -----
 tests/qemu-iotests/030        |  8 ++---
 tests/qemu-iotests/031        |  6 ----
 tests/qemu-iotests/032        |  6 ----
 tests/qemu-iotests/033        |  6 ----
 tests/qemu-iotests/034        |  6 ----
 tests/qemu-iotests/035        |  6 ----
 tests/qemu-iotests/036        |  6 ----
 tests/qemu-iotests/037        |  6 ----
 tests/qemu-iotests/038        |  6 ----
 tests/qemu-iotests/039        |  6 ----
 tests/qemu-iotests/040        | 35 +++++++++-------------
 tests/qemu-iotests/041        | 70 ++++++++++++++++++-------------------------
 tests/qemu-iotests/042        |  6 ----
 tests/qemu-iotests/043        |  7 -----
 tests/qemu-iotests/044        |  8 ++---
 tests/qemu-iotests/045        | 14 ++++-----
 tests/qemu-iotests/046        |  6 ----
 tests/qemu-iotests/047        |  6 ----
 tests/qemu-iotests/048        |  8 -----
 tests/qemu-iotests/048.out    |  1 -
 tests/qemu-iotests/049        |  6 ----
 tests/qemu-iotests/050        |  8 -----
 tests/qemu-iotests/051        |  6 ----
 tests/qemu-iotests/052        |  6 ----
 tests/qemu-iotests/053        |  7 -----
 tests/qemu-iotests/054        |  6 ----
 tests/qemu-iotests/055        | 36 ++++++++--------------
 tests/qemu-iotests/056        | 13 ++++----
 tests/qemu-iotests/057        |  6 ++--
 tests/qemu-iotests/058        |  8 +----
 tests/qemu-iotests/059        |  7 -----
 tests/qemu-iotests/060        |  6 ----
 tests/qemu-iotests/061        |  6 ----
 tests/qemu-iotests/062        |  6 ----
 tests/qemu-iotests/063        |  7 -----
 tests/qemu-iotests/064        |  6 ----
 tests/qemu-iotests/065        |  6 ++--
 tests/qemu-iotests/066        |  6 ----
 tests/qemu-iotests/068        |  6 ----
 tests/qemu-iotests/069        |  6 ----
 tests/qemu-iotests/070        |  6 ----
 tests/qemu-iotests/071        |  6 ----
 tests/qemu-iotests/072        |  6 ----
 tests/qemu-iotests/073        |  6 ----
 tests/qemu-iotests/074        |  9 ------
 tests/qemu-iotests/074.out    |  1 -
 tests/qemu-iotests/075        |  6 ----
 tests/qemu-iotests/076        |  6 ----
 tests/qemu-iotests/077        |  6 ----
 tests/qemu-iotests/078        |  6 ----
 tests/qemu-iotests/079        |  6 ----
 tests/qemu-iotests/080        |  7 -----
 tests/qemu-iotests/081        |  8 -----
 tests/qemu-iotests/082        |  6 ----
 tests/qemu-iotests/084        |  6 ----
 tests/qemu-iotests/085        | 13 +-------
 tests/qemu-iotests/086        |  6 ----
 tests/qemu-iotests/088        |  7 -----
 tests/qemu-iotests/089        |  6 ----
 tests/qemu-iotests/090        |  6 ----
 tests/qemu-iotests/091        |  8 +----
 tests/qemu-iotests/092        |  7 -----
 tests/qemu-iotests/094        |  9 +-----
 tests/qemu-iotests/095        |  8 +----
 tests/qemu-iotests/096        |  5 ++--
 tests/qemu-iotests/097        |  7 -----
 tests/qemu-iotests/098        |  7 -----
 tests/qemu-iotests/099        |  6 ----
 tests/qemu-iotests/101        |  6 ----
 tests/qemu-iotests/102        |  7 +----
 tests/qemu-iotests/103        |  6 ----
 tests/qemu-iotests/104        |  2 --
 tests/qemu-iotests/105        |  6 ----
 tests/qemu-iotests/106        |  6 ----
 tests/qemu-iotests/107        |  6 ----
 tests/qemu-iotests/108        |  6 ----
 tests/qemu-iotests/109        |  8 +----
 tests/qemu-iotests/110        |  6 ----
 tests/qemu-iotests/111        |  6 ----
 tests/qemu-iotests/112        |  6 ----
 tests/qemu-iotests/113        |  6 ----
 tests/qemu-iotests/114        |  6 ----
 tests/qemu-iotests/115        |  6 ----
 tests/qemu-iotests/116        |  6 ----
 tests/qemu-iotests/117        |  7 +----
 tests/qemu-iotests/118        | 31 +++++++++----------
 tests/qemu-iotests/119        |  6 ----
 tests/qemu-iotests/120        |  6 ----
 tests/qemu-iotests/121        |  6 ----
 tests/qemu-iotests/122        |  7 -----
 tests/qemu-iotests/123        |  7 -----
 tests/qemu-iotests/124        | 21 +++++--------
 tests/qemu-iotests/125        |  6 ----
 tests/qemu-iotests/130        |  7 +----
 tests/qemu-iotests/131        |  6 ----
 tests/qemu-iotests/132        |  9 ++----
 tests/qemu-iotests/133        |  6 ----
 tests/qemu-iotests/134        |  6 ----
 tests/qemu-iotests/135        |  6 ----
 tests/qemu-iotests/136        |  3 +-
 tests/qemu-iotests/137        |  6 ----
 tests/qemu-iotests/138        |  6 ----
 tests/qemu-iotests/139        |  6 ++--
 tests/qemu-iotests/140        |  8 +----
 tests/qemu-iotests/141        |  8 +----
 tests/qemu-iotests/142        |  7 -----
 tests/qemu-iotests/143        |  7 +----
 tests/qemu-iotests/144        |  8 +----
 tests/qemu-iotests/145        |  7 -----
 tests/qemu-iotests/146        |  7 +----
 tests/qemu-iotests/147        | 16 ++++------
 tests/qemu-iotests/148        |  7 +++--
 tests/qemu-iotests/150        |  6 ----
 tests/qemu-iotests/152        |  9 ++----
 tests/qemu-iotests/153        | 12 --------
 tests/qemu-iotests/154        |  6 ----
 tests/qemu-iotests/155        | 15 ++++------
 tests/qemu-iotests/156        |  7 +----
 tests/qemu-iotests/157        |  6 ----
 tests/qemu-iotests/158        |  6 ----
 tests/qemu-iotests/159        |  7 -----
 tests/qemu-iotests/160        |  7 -----
 tests/qemu-iotests/162        |  7 -----
 tests/qemu-iotests/165        |  6 ++--
 tests/qemu-iotests/170        |  7 -----
 tests/qemu-iotests/171        |  6 ----
 tests/qemu-iotests/172        |  8 -----
 tests/qemu-iotests/173        |  8 +----
 tests/qemu-iotests/174        |  6 ----
 tests/qemu-iotests/175        |  6 ----
 tests/qemu-iotests/176        |  7 -----
 tests/qemu-iotests/177        |  6 ----
 tests/qemu-iotests/178        |  7 -----
 tests/qemu-iotests/179        |  7 -----
 tests/qemu-iotests/181        |  8 +----
 tests/qemu-iotests/182        |  6 ----
 tests/qemu-iotests/183        |  9 +-----
 tests/qemu-iotests/185        |  9 +-----
 tests/qemu-iotests/186        |  6 ----
 tests/qemu-iotests/187        |  8 -----
 tests/qemu-iotests/188        |  6 ----
 tests/qemu-iotests/189        |  6 ----
 tests/qemu-iotests/190        |  7 -----
 tests/qemu-iotests/192        |  6 ----
 tests/qemu-iotests/check      | 29 +++++++++++++++---
 tests/qemu-iotests/common     |  6 ++++
 tests/qemu-iotests/iotests.py |  7 +++++
 174 files changed, 187 insertions(+), 1163 deletions(-)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH v3 1/5 qemu-iotests: set TEST_DIR to a unique dir for each test

Right now, all qemu-iotests output data into the same scratch directory, and so each test needs to be responsible for cleaning up its own files.

Have each test use 'scratch/$seq' as its temp directory, so the check script can do simple cleanup of removing the whole temporary directory.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
tests/qemu-iotests/check +17 -4
index d504b6e..f6ca85d 100755
@@ -243,6 +243,7 @@ seq="check"
 
 for seq in $list
 do
+    TEST_DIR_SEQ=$TEST_DIR/$seq
     err=false
     printf %s "$seq"
     if [ -n "$TESTS_REMAINING_LOG" ] ; then
@@ -289,13 +290,23 @@ do
         fi
         export OUTPUT_DIR=$PWD
         if $debug; then
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"
+            cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command -d 2>&1 | tee $tmp.out)
+                    $run_command -d 2>&1 | tee $tmp.out
+            )
         else
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"
+             cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command >$tmp.out 2>&1)
+                    $run_command >$tmp.out 2>&1
+            )
         fi
         sts=$?
         $timestamp && _timestamp
@@ -359,6 +370,8 @@ do
             fi
         fi
 
+        rm -rf "$TEST_DIR_SEQ"
+
     fi
 
     # come here for each test, except when $showme is true
Signature · 1 line
2.9.5
Tested-by Reviewed-by on v3 1/5
#2 lore raw

Re: [Qemu-devel] [PATCH v3 1/5] qemu-iotests: set TEST_DIR to a unique dir for each test

Quoted 25 lines · Jeff Cody

Right now, all qemu-iotests output data into the same scratch directory, and so each test needs to be responsible for cleaning up its own files.

Have each test use 'scratch/$seq' as its temp directory, so the check script can do simple cleanup of removing the whole temporary directory.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
tests/qemu-iotests/check +1 -0
index d504b6e..f6ca85d 100755
@@ -243,6 +243,7 @@ seq="check"
 
 for seq in $list
 do
+    TEST_DIR_SEQ=$TEST_DIR/$seq
     err=false
     printf %s "$seq"
     if [ -n "$TESTS_REMAINING_LOG" ] ; then

tests/qemu-iotests/check do · line 296

Quoted 8 lines
tests/qemu-iotests/check +4 -1
@@ -289,13 +290,23 @@ do
         fi
         export OUTPUT_DIR=$PWD
         if $debug; then
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"

What purpose do these serve?

Quoted 21 lines
tests/qemu-iotests/check +10 -3
+            cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command -d 2>&1 | tee $tmp.out)
+                    $run_command -d 2>&1 | tee $tmp.out
+            )
         else
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"
+             cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command >$tmp.out 2>&1)
+                    $run_command >$tmp.out 2>&1
+            )
         fi
         sts=$?
         $timestamp && _timestamp

tests/qemu-iotests/check do · line 377

Quoted 8 lines
tests/qemu-iotests/check +2 -0
@@ -359,6 +370,8 @@ do
             fi
         fi
 
+        rm -rf "$TEST_DIR_SEQ"
+
     fi
 
     # come here for each test, except when $showme is true

Seems OK to me, though I am not able to answer all doubts about exactly how this may effect the strange pipe/subshell arrangements that occur deeper in the bowels of the included files for launching QEMU and so on.. I suppose that might be related to the inclusion of those common.XYZ files?

author
#3 lore raw

Re: [Qemu-devel] [PATCH v3 1/5] qemu-iotests: set TEST_DIR to a unique dir for each test

Quoted 30 lines · John Snow
Quoted 27 lines · Jeff Cody

Right now, all qemu-iotests output data into the same scratch directory, and so each test needs to be responsible for cleaning up its own files.

Have each test use 'scratch/$seq' as its temp directory, so the check script can do simple cleanup of removing the whole temporary directory.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
tests/qemu-iotests/check +1 -0
index d504b6e..f6ca85d 100755
@@ -243,6 +243,7 @@ seq="check"
 
 for seq in $list
 do
+    TEST_DIR_SEQ=$TEST_DIR/$seq
     err=false
     printf %s "$seq"
     if [ -n "$TESTS_REMAINING_LOG" ] ; then
@@ -289,13 +290,23 @@ do
         fi
         export OUTPUT_DIR=$PWD
Quoted 9 lines

tests/qemu-iotests/check do · line 296

Quoted 6 lines
tests/qemu-iotests/check +4 -1
         if $debug; then
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"

What purpose do these serve?

This is setting $TEST_DIR according to the $seq number (test # being run) in the bash subshell that the tests are being run from. So that all the other variables that are based on the $TEST_DIR are set appropriately, this also sources them in the subshell prior to running the test. That way their environment is with $TEST_DIR_SEQ rather than the original base $TEST_DIR.

Quoted 38 lines
Quoted 21 lines
tests/qemu-iotests/check +10 -3
+            cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command -d 2>&1 | tee $tmp.out)
+                    $run_command -d 2>&1 | tee $tmp.out
+            )
         else
-            (cd "$source_iotests";
+            (
+            export TEST_DIR=$TEST_DIR_SEQ
+            . "$source_iotests/common.config"
+            . "$source_iotests/common.rc"
+             cd "$source_iotests" &&
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command >$tmp.out 2>&1)
+                    $run_command >$tmp.out 2>&1
+            )
         fi
         sts=$?
         $timestamp && _timestamp

tests/qemu-iotests/check do · line 377

Quoted 8 lines
tests/qemu-iotests/check +2 -0
@@ -359,6 +370,8 @@ do
             fi
         fi
 
+        rm -rf "$TEST_DIR_SEQ"
+
     fi
 
     # come here for each test, except when $showme is true

Seems OK to me, though I am not able to answer all doubts about exactly how this may effect the strange pipe/subshell arrangements that occur deeper in the bowels of the included files for launching QEMU and so on.. I suppose that might be related to the inclusion of those common.XYZ files?

author
#4 lore raw

PATCH v3 2/5 qemu-iotests: remove file cleanup from bash tests

In reply to Jeff Cody

All files for a given test are now self-contained in a subdirectory, and therefore the "./check" script can do all file-related cleanup without any help.

This removes file cleanups from the bash tests. The only cleanup left is whatever is needed to kill any spawned processes; e.g. _cleanup_qemu.

---
 tests/qemu-iotests/001     |  6 ------
 tests/qemu-iotests/002     |  6 ------
 tests/qemu-iotests/003     |  6 ------
 tests/qemu-iotests/004     |  6 ------
 tests/qemu-iotests/005     |  6 ------
 tests/qemu-iotests/007     |  7 -------
 tests/qemu-iotests/008     |  6 ------
 tests/qemu-iotests/009     |  6 ------
 tests/qemu-iotests/010     |  6 ------
 tests/qemu-iotests/011     |  6 ------
 tests/qemu-iotests/012     |  6 ------
 tests/qemu-iotests/013     |  6 ------
 tests/qemu-iotests/014     |  6 ------
 tests/qemu-iotests/015     |  7 -------
 tests/qemu-iotests/017     |  6 ------
 tests/qemu-iotests/018     |  6 ------
 tests/qemu-iotests/019     |  8 --------
 tests/qemu-iotests/020     |  8 --------
 tests/qemu-iotests/021     |  6 ------
 tests/qemu-iotests/022     |  6 ------
 tests/qemu-iotests/023     |  6 ------
 tests/qemu-iotests/024     |  8 --------
 tests/qemu-iotests/025     |  6 ------
 tests/qemu-iotests/026     |  7 -------
 tests/qemu-iotests/027     |  6 ------
 tests/qemu-iotests/028     |  8 --------
 tests/qemu-iotests/029     |  7 -------
 tests/qemu-iotests/031     |  6 ------
 tests/qemu-iotests/032     |  6 ------
 tests/qemu-iotests/033     |  6 ------
 tests/qemu-iotests/034     |  6 ------
 tests/qemu-iotests/035     |  6 ------
 tests/qemu-iotests/036     |  6 ------
 tests/qemu-iotests/037     |  6 ------
 tests/qemu-iotests/038     |  6 ------
 tests/qemu-iotests/039     |  6 ------
 tests/qemu-iotests/042     |  6 ------
 tests/qemu-iotests/043     |  7 -------
 tests/qemu-iotests/046     |  6 ------
 tests/qemu-iotests/047     |  6 ------
 tests/qemu-iotests/048     |  8 --------
 tests/qemu-iotests/048.out |  1 -
 tests/qemu-iotests/049     |  6 ------
 tests/qemu-iotests/050     |  8 --------
 tests/qemu-iotests/051     |  6 ------
 tests/qemu-iotests/052     |  6 ------
 tests/qemu-iotests/053     |  7 -------
 tests/qemu-iotests/054     |  6 ------
 tests/qemu-iotests/058     |  8 +-------
 tests/qemu-iotests/059     |  7 -------
 tests/qemu-iotests/060     |  6 ------
 tests/qemu-iotests/061     |  6 ------
 tests/qemu-iotests/062     |  6 ------
 tests/qemu-iotests/063     |  7 -------
 tests/qemu-iotests/064     |  6 ------
 tests/qemu-iotests/066     |  6 ------
 tests/qemu-iotests/068     |  6 ------
 tests/qemu-iotests/069     |  6 ------
 tests/qemu-iotests/070     |  6 ------
 tests/qemu-iotests/071     |  6 ------
 tests/qemu-iotests/072     |  6 ------
 tests/qemu-iotests/073     |  6 ------
 tests/qemu-iotests/074     |  9 ---------
 tests/qemu-iotests/074.out |  1 -
 tests/qemu-iotests/075     |  6 ------
 tests/qemu-iotests/076     |  6 ------
 tests/qemu-iotests/077     |  6 ------
 tests/qemu-iotests/078     |  6 ------
 tests/qemu-iotests/079     |  6 ------
 tests/qemu-iotests/080     |  7 -------
 tests/qemu-iotests/081     |  8 --------
 tests/qemu-iotests/082     |  6 ------
 tests/qemu-iotests/084     |  6 ------
 tests/qemu-iotests/085     | 13 +------------
 tests/qemu-iotests/086     |  6 ------
 tests/qemu-iotests/088     |  7 -------
 tests/qemu-iotests/089     |  6 ------
 tests/qemu-iotests/090     |  6 ------
 tests/qemu-iotests/091     |  8 +-------
 tests/qemu-iotests/092     |  7 -------
 tests/qemu-iotests/094     |  9 +--------
 tests/qemu-iotests/095     |  8 +-------
 tests/qemu-iotests/097     |  7 -------
 tests/qemu-iotests/098     |  7 -------
 tests/qemu-iotests/099     |  6 ------
 tests/qemu-iotests/101     |  6 ------
 tests/qemu-iotests/102     |  7 +------
 tests/qemu-iotests/103     |  6 ------
 tests/qemu-iotests/104     |  2 --
 tests/qemu-iotests/105     |  6 ------
 tests/qemu-iotests/106     |  6 ------
 tests/qemu-iotests/107     |  6 ------
 tests/qemu-iotests/108     |  6 ------
 tests/qemu-iotests/109     |  8 +-------
 tests/qemu-iotests/110     |  6 ------
 tests/qemu-iotests/111     |  6 ------
 tests/qemu-iotests/112     |  6 ------
 tests/qemu-iotests/113     |  6 ------
 tests/qemu-iotests/114     |  6 ------
 tests/qemu-iotests/115     |  6 ------
 tests/qemu-iotests/116     |  6 ------
 tests/qemu-iotests/117     |  7 +------
 tests/qemu-iotests/119     |  6 ------
 tests/qemu-iotests/120     |  6 ------
 tests/qemu-iotests/121     |  6 ------
 tests/qemu-iotests/122     |  7 -------
 tests/qemu-iotests/123     |  7 -------
 tests/qemu-iotests/125     |  6 ------
 tests/qemu-iotests/130     |  7 +------
 tests/qemu-iotests/131     |  6 ------
 tests/qemu-iotests/133     |  6 ------
 tests/qemu-iotests/134     |  6 ------
 tests/qemu-iotests/135     |  6 ------
 tests/qemu-iotests/137     |  6 ------
 tests/qemu-iotests/138     |  6 ------
 tests/qemu-iotests/140     |  8 +-------
 tests/qemu-iotests/141     |  8 +-------
 tests/qemu-iotests/142     |  7 -------
 tests/qemu-iotests/143     |  7 +------
 tests/qemu-iotests/144     |  8 +-------
 tests/qemu-iotests/145     |  7 -------
 tests/qemu-iotests/146     |  7 +------
 tests/qemu-iotests/150     |  6 ------
 tests/qemu-iotests/153     | 12 ------------
 tests/qemu-iotests/154     |  6 ------
 tests/qemu-iotests/156     |  7 +------
 tests/qemu-iotests/157     |  6 ------
 tests/qemu-iotests/158     |  6 ------
 tests/qemu-iotests/159     |  7 -------
 tests/qemu-iotests/160     |  7 -------
 tests/qemu-iotests/162     |  7 -------
 tests/qemu-iotests/170     |  7 -------
 tests/qemu-iotests/171     |  6 ------
 tests/qemu-iotests/172     |  8 --------
 tests/qemu-iotests/173     |  8 +-------
 tests/qemu-iotests/174     |  6 ------
 tests/qemu-iotests/175     |  6 ------
 tests/qemu-iotests/176     |  7 -------
 tests/qemu-iotests/177     |  6 ------
 tests/qemu-iotests/178     |  7 -------
 tests/qemu-iotests/179     |  7 -------
 tests/qemu-iotests/181     |  8 +-------
 tests/qemu-iotests/182     |  6 ------
 tests/qemu-iotests/183     |  9 +--------
 tests/qemu-iotests/185     |  9 +--------
 tests/qemu-iotests/186     |  6 ------
 tests/qemu-iotests/187     |  8 --------
 tests/qemu-iotests/188     |  6 ------
 tests/qemu-iotests/189     |  6 ------
 tests/qemu-iotests/190     |  7 -------
 tests/qemu-iotests/192     |  6 ------
 151 files changed, 19 insertions(+), 965 deletions(-)
tests/qemu-iotests/001 +0 -6
index ffd14e2..6f71879 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/002 +0 -6
index d4f8e91..4c9ff23 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/003 +0 -6
index 19889b9..2648d03 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/004 +0 -6
index 6f2aa3d..99743b4 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/005 +0 -6
index 4447377..23a77e0 100755
@@ -30,12 +30,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/007 +0 -7
index fa543ee..c8068e5 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-	true
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/008 +0 -6
index 8e89d74..7f7f8ae 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/009 +0 -6
index 16e4475..e03412a 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/010 +0 -6
index 151dac2..8608848 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/011 +0 -6
index f8d044e..0c0d15f 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/012 +0 -6
index 01a770d..aa9cfb4 100755
@@ -29,12 +29,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/013 +0 -6
index d013f87..0ff9c4d 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/014 +0 -6
index 2ea79e8..3dee9f7 100755
@@ -29,12 +29,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/015 +0 -7
index aaf9c3f..d29a778 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-	true
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/017 +0 -6
index 4f9302d..994ea0e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/018 +0 -6
index 1d39d35..11ad2b1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/019 +0 -8
index 24a789a..3728193 100755
@@ -29,14 +29,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm -f "$TEST_IMG.base"
-    rm -f "$TEST_IMG.orig"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/020 +0 -8
index 7a11110..37cd5d1 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm -f "$TEST_IMG.base"
-    rm -f "$TEST_IMG.orig"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/021 +0 -6
index 11e8ed7..5ab2acb 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/022 +0 -6
index 2452a9f..4870b17 100755
@@ -29,12 +29,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/023 +0 -6
index 497ae1e..5a2bf4e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/024 +0 -8
index e0d77ce..3e638d9 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-	rm -f "$TEST_DIR/t.$IMGFMT.base_old"
-	rm -f "$TEST_DIR/t.$IMGFMT.base_new"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/025 +0 -6
index f5e672e..93634c1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/026 +0 -7
index 7fadfba..dc4ff9f 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm "$TEST_DIR/blkdebug.conf"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/027 +0 -6
index 08593da..c3f9146 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/028 +0 -8
index 97a8869..3176789 100755
@@ -30,14 +30,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm -f "${TEST_IMG}.copy"
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/029 +0 -7
index 30bab24..981a864 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f $TEST_IMG.snap
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/031 +0 -6
index 1e08abc..6805c2c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/032 +0 -6
index 24bcb52..dafcfb8 100755
@@ -29,12 +29,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/033 +0 -6
index 2cdfd13..bf3c59c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/034 +0 -6
index 1b28bda..830b0db 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/035 +0 -6
index efc38e4..a79a4fd 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/036 +0 -6
index ce638d6..841f347 100755
@@ -30,12 +30,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/037 +0 -6
index c476b82..756fc2c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/038 +0 -6
index d99a150..cf730ae 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/039 +0 -6
index 1f48339..dd483c4 100755
@@ -30,12 +30,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/042 +0 -6
index a53e7cb..0efeec6 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/043 +0 -7
index 1c6c22d..48b71fe 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG".[123].base
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/046 +0 -6
index f2ebecf..362ed94 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/047 +0 -6
index 1b8f3d4..1850035 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/048 +0 -8
index 9ed04a0..c95bd2f 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 
 status=1        # failure is the default!
 
-_cleanup()
-{
-    echo "Cleanup"
-    _cleanup_test_img
-    rm "${TEST_IMG_FILE2}"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 _compare()
 {
     $QEMU_IMG compare $QEMU_IMG_EXTRA_ARGS "$@" "$TEST_IMG" "${TEST_IMG2}"
tests/qemu-iotests/048.out +0 -1
index 0bcf663..3318eed 100644
@@ -39,4 +39,3 @@ wrote 512/512 bytes at offset 512
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 Content mismatch at offset 512!
 1
-Cleanup
tests/qemu-iotests/049 +0 -6
index df35b6d..00733a6 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/050 +0 -8
index 03b4a5d..e3b6d8c 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.old"
-    rm -f "$TEST_IMG.new"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/051 +0 -6
index c8cfc76..7060c3e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/052 +0 -6
index 842eace..fc23fad 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/053 +0 -7
index 2a04f5f..e8b9037 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	rm -f "$TEST_IMG.orig"
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/054 +0 -6
index bf47ef9..e2de997 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/058 +1 -7
index 2253c6a..a842fe4 100755
@@ -75,13 +75,7 @@ _export_nbd_snapshot1()
     _wait_for_nbd
 }
 
-_cleanup()
-{
-    _cleanup_nbd
-    _cleanup_test_img
-    rm -f "$converted_image"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_nbd; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/059 +0 -7
index a1c34ee..6ccd250 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.qcow2"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/060 +0 -6
index 8e95c45..6532837 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/061 +0 -6
index f5678b1..1346dd9 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/062 +0 -6
index 051fb9f..3a1df0d 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/063 +0 -7
index e4f6ea9..4a9fc44 100755
@@ -28,13 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-	rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/064 +0 -6
index 5792fbb..211c541 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/066 +0 -6
index 8638217..e811f48 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/068 +0 -6
index cfa0f2a..dd98227 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/069 +0 -6
index 96e55ef..03d5a3c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/070 +0 -6
index 8d08d74..1220cc1 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/071 +0 -6
index 48b4955..1a8d6e7 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/072 +0 -6
index aa027c7..8aaf3fd 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/073 +0 -6
index 40f85b1..c19ad0d 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/074 +0 -9
index b17866b..d7888ab 100755
@@ -27,15 +27,6 @@ echo "QA output created by $seq"
 
 status=1        # failure is the default!
 
-_cleanup()
-{
-    echo "Cleanup"
-    _cleanup_test_img
-    rm "${TEST_IMG2}"
-    rm -f "$TEST_DIR/blkdebug.conf"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 _compare()
 {
     $QEMU_IMG compare "$@" "$TEST_IMG" "${TEST_IMG2}"
tests/qemu-iotests/074.out +0 -1
index 8fba5ae..fb93965 100644
@@ -15,4 +15,3 @@ qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_D
 qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error
 Warning: Image size mismatch!
 4
-Cleanup
tests/qemu-iotests/075 +0 -6
index 770d51c..c2509d1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/076 +0 -6
index ef9e6a4..69bccad 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/077 +0 -6
index d2d2a2d..4a458e1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/078 +0 -6
index f333e9a..22d078e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/079 +0 -6
index b2e3f74..fba6ec6 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/080 +0 -7
index 55044c7..be548a9 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f $TEST_IMG.snap
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/081 +0 -8
index da3fb09..2dadc16 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -rf $TEST_DIR/1.raw
-    rm -rf $TEST_DIR/2.raw
-    rm -rf $TEST_DIR/3.raw
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/082 +0 -6
index d5c83d4..aa585db 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/084 +0 -6
index 04f2aa9..b0d42a0 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/085 +1 -12
index 5c7668c..7b69f86 100755
@@ -37,18 +37,7 @@ snapshot_virt1="snapshot-v1.qcow2"
 
 SNAPSHOTS=10
 
-_cleanup()
-{
-    _cleanup_qemu
-    for i in $(seq 1 ${SNAPSHOTS})
-    do
-        rm -f "${TEST_DIR}/${i}-${snapshot_virt0}"
-        rm -f "${TEST_DIR}/${i}-${snapshot_virt1}"
-    done
-    rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base"
-
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/086 +0 -6
index cd4494a..4d5f7db 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/088 +0 -7
index b8076f2..72e7c68 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f $TEST_IMG.snap
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/089 +0 -6
index 9bfe230..75151f1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/090 +0 -6
index 7380503..c3be13c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/091 +1 -7
index 10ac4a8..c4df2fb 100755
@@ -31,13 +31,7 @@ status=1    # failure is the default!
 
 MIG_FIFO="${TEST_DIR}/migrate"
 
-_cleanup()
-{
-    rm -f "${MIG_FIFO}"
-    _cleanup_qemu
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/092 +0 -7
index 5bbdd07..3b8cf8f 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f $TEST_IMG.snap
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/094 +1 -8
index 9aa01e3..35e882c 100755
@@ -27,14 +27,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-    rm -f "$TEST_DIR/source.$IMGFMT"
-}
-
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/095 +1 -7
index 030adb2..75d60c4 100755
@@ -30,13 +30,7 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm  -f "${TEST_IMG}.base" "${TEST_IMG}.snp1"
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/097 +0 -7
index e22670c..81e6729 100755
@@ -28,13 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    _rm_test_img "$TEST_IMG.itmd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/098 +0 -7
index b002e96..24d8510 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_DIR/blkdebug.conf"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/099 +0 -6
index caaf58e..d811b34 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/101 +0 -6
index ea53f8b..62faf99 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/102 +1 -6
index 87db1bb..084d2cf 100755
@@ -27,12 +27,7 @@ echo "QA output created by $seq"
 here=$PWD
 status=1    # failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and qemu instance handling
 . ./common.rc
tests/qemu-iotests/103 +0 -6
index ecbd8eb..df86d4f 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=$PWD
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/104 +0 -2
index 726d467..f10d311 100755
@@ -27,8 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-trap "exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/105 +0 -6
index 3db4ce3..b469b1b 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/106 +0 -6
index 3264957..b571971 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=$PWD
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment and filters
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/107 +0 -6
index d7222dc..d513120 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/108 +0 -6
index 2355d98..8371db4 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/109 +1 -7
index d70b574..d4fca99 100755
@@ -27,13 +27,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm -f $TEST_IMG.src
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/110 +0 -6
index 9de7369..93dd09f 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/111 +0 -6
index a1c152d..f590d82 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/112 +0 -6
index 28eb9aa..ee3679e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/113 +0 -6
index 19b68b2..07437ea 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/114 +0 -6
index 5b7dc54..5bfd473 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/115 +0 -6
index 665c2ea..0c9aaad 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/116 +0 -6
index df0172f..e687601 100755
@@ -30,12 +30,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/117 +1 -6
index 6c83461..579cecb 100755
@@ -27,12 +27,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/119 +0 -6
index 4f34fb4..8cdb404 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/120 +0 -6
index f40b97d..bb0e2dd 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/121 +0 -6
index 1307b4e..d75fce1 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/122 +0 -7
index 45b359c..3942604 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f "$TEST_IMG".[123]
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/123 +0 -7
index b18e3fc..98fd3ce 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$SRC_IMG"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/125 +0 -6
index 9424313..bca5fb5 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=$PWD
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 get_image_size_on_host()
 {
     $QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep "disk size" \
tests/qemu-iotests/130 +1 -6
index e7e43de..4aad4ea 100755
@@ -29,12 +29,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/131 +0 -6
index 94a9ae7..52588ef 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/133 +0 -6
index 9d35a6a..2d0aae9 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/134 +0 -6
index 9914415..147ea2c 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/135 +0 -6
index ce60831..75c160d 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/137 +0 -6
index eb91e51..6068a13 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/138 +0 -6
index 21650d8..9682560 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/140 +1 -7
index f89d0d6..c5e1a5b 100755
@@ -31,13 +31,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-    rm -f "$TEST_DIR/nbd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/141 +1 -7
index 2f9d7b9..cff2319 100755
@@ -27,13 +27,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-    rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/142 +0 -7
index 1639c83..65775be 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f $TEST_IMG.snap
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/143 +1 -6
index 5ff1944..b4736aa 100755
@@ -27,12 +27,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm -f "$TEST_DIR/nbd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/144 +1 -7
index 00de3c3..b47c561 100755
@@ -32,13 +32,7 @@ status=1	# failure is the default!
 TMP_SNAP1=${TEST_DIR}/tmp.qcow2
 TMP_SNAP2=${TEST_DIR}/tmp2.qcow2
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"
-}
-
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/145 +0 -7
index c371b3c..930628e 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-	true
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/146 +1 -6
index 043711b..99b1e81 100755
@@ -27,12 +27,7 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1    # failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/150 +0 -6
index ee8f637..120920e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/153 +0 -12
index fa25eb2..42882eb 100755
@@ -28,18 +28,6 @@ here="$PWD"
 tmp=/tmp/$$
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "${TEST_IMG}.base"
-    rm -f "${TEST_IMG}.convert"
-    rm -f "${TEST_IMG}.a"
-    rm -f "${TEST_IMG}.b"
-    rm -f "${TEST_IMG}.c"
-    rm -f "${TEST_IMG}.lnk"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/154 +0 -6
index fde03b0..90e7e65 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/156 +1 -6
index e75dc4d..9dbc6d7 100755
@@ -35,12 +35,7 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm -f "$TEST_IMG"{,.target}{,.backing,.overlay}
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/157 +0 -6
index 2bf02be..bda53c8 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/158 +0 -6
index 24ac600..a07708e 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/159 +0 -7
index 9b0e1ec..7fcccde 100755
@@ -26,13 +26,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.out"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 . ./common.rc
 . ./common.filter
 . ./common.pattern
tests/qemu-iotests/160 +0 -7
index 5c910e5..48dd25d 100755
@@ -26,13 +26,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 . ./common.rc
 . ./common.filter
 . ./common.pattern
tests/qemu-iotests/162 +0 -7
index 477a806..cad2bd7 100755
@@ -28,13 +28,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    rm -f "${TEST_DIR}/qemu-nbd.pid"
-    rm -f 42
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/170 +0 -7
index b79359f..5288a2d 100755
@@ -26,13 +26,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.out"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 . ./common.rc
 . ./common.filter
 . ./common.pattern
tests/qemu-iotests/171 +0 -6
index bcfaaf1..2798d2f 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/172 +0 -8
index 826d6fe..125c1d9 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm -f "$TEST_IMG.2"
-    rm -f "$TEST_IMG.3"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/173 +1 -7
index bdaa092..0c2fde4 100755
@@ -27,13 +27,7 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1    # failure is the default!
 
-_cleanup()
-{
-    _cleanup_qemu
-    rm  -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1"
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/174 +0 -6
index 552879d..67cd785 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/175 +0 -6
index ca56e82..1407597 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/176 +0 -7
index 950b287..56cd490 100755
@@ -31,13 +31,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    _rm_test_img "$TEST_IMG.itmd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/177 +0 -6
index f8ed8fb..ed2e8b2 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/178 +0 -7
index 6af52c6..fd583d1 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1    # failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.converted"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/179 +0 -7
index 115944a..f7cf129 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here="$PWD"
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm -f "$TEST_DIR/blkdebug.conf"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/181 +1 -7
index 0333dda..8abc61a 100755
@@ -29,13 +29,7 @@ status=1	# failure is the default!
 
 MIG_SOCKET="${TEST_DIR}/migrate"
 
-_cleanup()
-{
-    rm -f "${MIG_SOCKET}"
-	_cleanup_test_img
-    _cleanup_qemu
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/182 +0 -6
index 7ecbb22..a4cbb03 100755
@@ -28,12 +28,6 @@ here="$PWD"
 tmp=/tmp/$$
 status=1	# failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/183 +1 -8
index 20268ff..2e09679 100755
@@ -29,14 +29,7 @@ status=1 # failure is the default!
 
 MIG_SOCKET="${TEST_DIR}/migrate"
 
-_cleanup()
-{
-    rm -f "${MIG_SOCKET}"
-    rm -f "${TEST_IMG}.dest"
-    _cleanup_test_img
-    _cleanup_qemu
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/185 +1 -8
index f5b47e4..7269d5e 100755
@@ -29,14 +29,7 @@ status=1 # failure is the default!
 
 MIG_SOCKET="${TEST_DIR}/migrate"
 
-_cleanup()
-{
-    rm -f "${TEST_IMG}.mid"
-    rm -f "${TEST_IMG}.copy"
-    _cleanup_test_img
-    _cleanup_qemu
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
+trap "_cleanup_qemu; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common.rc
tests/qemu-iotests/186 +0 -6
index 2b9f618..e301871 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/187 +0 -8
index 7bb7833..8b29df3 100755
@@ -27,14 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-    rm -f "$TEST_IMG.2"
-    rm -f "$TEST_IMG.3"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/188 +0 -6
index 83ed03e..48f855d 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/189 +0 -6
index e695475..c5d516d 100755
@@ -27,12 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/190 +0 -7
index 8f808fe..84d20c6 100755
@@ -27,13 +27,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1    # failure is the default!
 
-_cleanup()
-{
-    _cleanup_test_img
-    rm -f "$TEST_IMG.converted"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
tests/qemu-iotests/192 +0 -6
index b50a2c0..6a95b81 100755
@@ -28,12 +28,6 @@ echo "QA output created by $seq"
 here=`pwd`
 status=1	# failure is the default!
 
-_cleanup()
-{
-	_cleanup_test_img
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
Signature · 1 line
2.9.5
Reviewed-by on v3 2/5
#5 lore raw

Re: [Qemu-devel] [PATCH v3 2/5] qemu-iotests: remove file cleanup from bash tests

Quoted 154 lines · Jeff Cody

All files for a given test are now self-contained in a subdirectory, and therefore the "./check" script can do all file-related cleanup without any help.

This removes file cleanups from the bash tests. The only cleanup left is whatever is needed to kill any spawned processes; e.g. _cleanup_qemu.

---
 tests/qemu-iotests/001     |  6 ------
 tests/qemu-iotests/002     |  6 ------
 tests/qemu-iotests/003     |  6 ------
 tests/qemu-iotests/004     |  6 ------
 tests/qemu-iotests/005     |  6 ------
 tests/qemu-iotests/007     |  7 -------
 tests/qemu-iotests/008     |  6 ------
 tests/qemu-iotests/009     |  6 ------
 tests/qemu-iotests/010     |  6 ------
 tests/qemu-iotests/011     |  6 ------
 tests/qemu-iotests/012     |  6 ------
 tests/qemu-iotests/013     |  6 ------
 tests/qemu-iotests/014     |  6 ------
 tests/qemu-iotests/015     |  7 -------
 tests/qemu-iotests/017     |  6 ------
 tests/qemu-iotests/018     |  6 ------
 tests/qemu-iotests/019     |  8 --------
 tests/qemu-iotests/020     |  8 --------
 tests/qemu-iotests/021     |  6 ------
 tests/qemu-iotests/022     |  6 ------
 tests/qemu-iotests/023     |  6 ------
 tests/qemu-iotests/024     |  8 --------
 tests/qemu-iotests/025     |  6 ------
 tests/qemu-iotests/026     |  7 -------
 tests/qemu-iotests/027     |  6 ------
 tests/qemu-iotests/028     |  8 --------
 tests/qemu-iotests/029     |  7 -------
 tests/qemu-iotests/031     |  6 ------
 tests/qemu-iotests/032     |  6 ------
 tests/qemu-iotests/033     |  6 ------
 tests/qemu-iotests/034     |  6 ------
 tests/qemu-iotests/035     |  6 ------
 tests/qemu-iotests/036     |  6 ------
 tests/qemu-iotests/037     |  6 ------
 tests/qemu-iotests/038     |  6 ------
 tests/qemu-iotests/039     |  6 ------
 tests/qemu-iotests/042     |  6 ------
 tests/qemu-iotests/043     |  7 -------
 tests/qemu-iotests/046     |  6 ------
 tests/qemu-iotests/047     |  6 ------
 tests/qemu-iotests/048     |  8 --------
 tests/qemu-iotests/048.out |  1 -
 tests/qemu-iotests/049     |  6 ------
 tests/qemu-iotests/050     |  8 --------
 tests/qemu-iotests/051     |  6 ------
 tests/qemu-iotests/052     |  6 ------
 tests/qemu-iotests/053     |  7 -------
 tests/qemu-iotests/054     |  6 ------
 tests/qemu-iotests/058     |  8 +-------
 tests/qemu-iotests/059     |  7 -------
 tests/qemu-iotests/060     |  6 ------
 tests/qemu-iotests/061     |  6 ------
 tests/qemu-iotests/062     |  6 ------
 tests/qemu-iotests/063     |  7 -------
 tests/qemu-iotests/064     |  6 ------
 tests/qemu-iotests/066     |  6 ------
 tests/qemu-iotests/068     |  6 ------
 tests/qemu-iotests/069     |  6 ------
 tests/qemu-iotests/070     |  6 ------
 tests/qemu-iotests/071     |  6 ------
 tests/qemu-iotests/072     |  6 ------
 tests/qemu-iotests/073     |  6 ------
 tests/qemu-iotests/074     |  9 ---------
 tests/qemu-iotests/074.out |  1 -
 tests/qemu-iotests/075     |  6 ------
 tests/qemu-iotests/076     |  6 ------
 tests/qemu-iotests/077     |  6 ------
 tests/qemu-iotests/078     |  6 ------
 tests/qemu-iotests/079     |  6 ------
 tests/qemu-iotests/080     |  7 -------
 tests/qemu-iotests/081     |  8 --------
 tests/qemu-iotests/082     |  6 ------
 tests/qemu-iotests/084     |  6 ------
 tests/qemu-iotests/085     | 13 +------------
 tests/qemu-iotests/086     |  6 ------
 tests/qemu-iotests/088     |  7 -------
 tests/qemu-iotests/089     |  6 ------
 tests/qemu-iotests/090     |  6 ------
 tests/qemu-iotests/091     |  8 +-------
 tests/qemu-iotests/092     |  7 -------
 tests/qemu-iotests/094     |  9 +--------
 tests/qemu-iotests/095     |  8 +-------
 tests/qemu-iotests/097     |  7 -------
 tests/qemu-iotests/098     |  7 -------
 tests/qemu-iotests/099     |  6 ------
 tests/qemu-iotests/101     |  6 ------
 tests/qemu-iotests/102     |  7 +------
 tests/qemu-iotests/103     |  6 ------
 tests/qemu-iotests/104     |  2 --
 tests/qemu-iotests/105     |  6 ------
 tests/qemu-iotests/106     |  6 ------
 tests/qemu-iotests/107     |  6 ------
 tests/qemu-iotests/108     |  6 ------
 tests/qemu-iotests/109     |  8 +-------
 tests/qemu-iotests/110     |  6 ------
 tests/qemu-iotests/111     |  6 ------
 tests/qemu-iotests/112     |  6 ------
 tests/qemu-iotests/113     |  6 ------
 tests/qemu-iotests/114     |  6 ------
 tests/qemu-iotests/115     |  6 ------
 tests/qemu-iotests/116     |  6 ------
 tests/qemu-iotests/117     |  7 +------
 tests/qemu-iotests/119     |  6 ------
 tests/qemu-iotests/120     |  6 ------
 tests/qemu-iotests/121     |  6 ------
 tests/qemu-iotests/122     |  7 -------
 tests/qemu-iotests/123     |  7 -------
 tests/qemu-iotests/125     |  6 ------
 tests/qemu-iotests/130     |  7 +------
 tests/qemu-iotests/131     |  6 ------
 tests/qemu-iotests/133     |  6 ------
 tests/qemu-iotests/134     |  6 ------
 tests/qemu-iotests/135     |  6 ------
 tests/qemu-iotests/137     |  6 ------
 tests/qemu-iotests/138     |  6 ------
 tests/qemu-iotests/140     |  8 +-------
 tests/qemu-iotests/141     |  8 +-------
 tests/qemu-iotests/142     |  7 -------
 tests/qemu-iotests/143     |  7 +------
 tests/qemu-iotests/144     |  8 +-------
 tests/qemu-iotests/145     |  7 -------
 tests/qemu-iotests/146     |  7 +------
 tests/qemu-iotests/150     |  6 ------
 tests/qemu-iotests/153     | 12 ------------
 tests/qemu-iotests/154     |  6 ------
 tests/qemu-iotests/156     |  7 +------
 tests/qemu-iotests/157     |  6 ------
 tests/qemu-iotests/158     |  6 ------
 tests/qemu-iotests/159     |  7 -------
 tests/qemu-iotests/160     |  7 -------
 tests/qemu-iotests/162     |  7 -------
 tests/qemu-iotests/170     |  7 -------
 tests/qemu-iotests/171     |  6 ------
 tests/qemu-iotests/172     |  8 --------
 tests/qemu-iotests/173     |  8 +-------
 tests/qemu-iotests/174     |  6 ------
 tests/qemu-iotests/175     |  6 ------
 tests/qemu-iotests/176     |  7 -------
 tests/qemu-iotests/177     |  6 ------
 tests/qemu-iotests/178     |  7 -------
 tests/qemu-iotests/179     |  7 -------
 tests/qemu-iotests/181     |  8 +-------
 tests/qemu-iotests/182     |  6 ------
 tests/qemu-iotests/183     |  9 +--------
Quoted 8 lines
 tests/qemu-iotests/185     |  9 +--------
 tests/qemu-iotests/186     |  6 ------
 tests/qemu-iotests/187     |  8 --------
 tests/qemu-iotests/188     |  6 ------
 tests/qemu-iotests/189     |  6 ------
 tests/qemu-iotests/190     |  7 -------
 tests/qemu-iotests/192     |  6 ------
 151 files changed, 19 insertions(+), 965 deletions(-)

wild diffstat.

#6 lore raw

Re: [Qemu-devel] [PATCH v3 2/5] qemu-iotests: remove file cleanup from bash tests

In reply to Jeff Cody

Am 30.08.2017 um 18:52 hat Jeff Cody geschrieben:

Quoted 9 lines

All files for a given test are now self-contained in a subdirectory, and therefore the "./check" script can do all file-related cleanup without any help.

This removes file cleanups from the bash tests. The only cleanup left is whatever is needed to kill any spawned processes; e.g. _cleanup_qemu.

What about non-file protocols? _cleanup_test_img() does more than just a few 'rm' commands. For NBD and vxhs it also kills the server process and for sheepdog and rbd it uses their specific tools to delete the image from the cluster because it's not simply a local file.

Kevin

author
#7 lore raw

PATCH v3 3/5 qemu-iotests: add 'blind_remove' for python tests

In reply to Jeff Cody

Add a function to attempt to 'blindly' remove a file, without throwing an error if the file doesn't exist.

---
 tests/qemu-iotests/iotests.py | 7 +++++++
 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +7 -0
index 7233983..a2088c7 100644
@@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
 socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
 debug = False
 
+def blind_remove(filename):
+    try:
+        os.remove(filename)
+    except OSError, error:
+        if error.errno != errno.ENOENT:
+            raise
+
 def qemu_img(*args):
     '''Run qemu-img and return the exit code'''
     devnull = open('/dev/null', 'r+')
Signature · 1 line
2.9.5
Reviewed-by on v3 3/5
#8 lore raw

Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove' for python tests

Quoted 13 lines · Jeff Cody

Add a function to attempt to 'blindly' remove a file, without throwing an error if the file doesn't exist.

---
 tests/qemu-iotests/iotests.py | 7 +++++++
 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +0 -0
index 7233983..a2088c7 100644

tests/qemu-iotests/iotests.py qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') · line 63

Quoted 7 lines
tests/qemu-iotests/iotests.py +4 -0
@@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
 socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
 debug = False
 
+def blind_remove(filename):
+    try:
+        os.remove(filename)
+    except OSError, error:

I'm assuming this works for both python 2 and 3?

tests/qemu-iotests/iotests.py qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') · line 66

Quoted 3 lines
tests/qemu-iotests/iotests.py +3 -0
+        if error.errno != errno.ENOENT:
+            raise
+

Weak, since I'm not the strongest at python, but you can add:

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#9 lore raw

Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove' for python tests

Quoted 17 lines · Eric Blake
Quoted 16 lines · Jeff Cody

Add a function to attempt to 'blindly' remove a file, without throwing an error if the file doesn't exist.

---
 tests/qemu-iotests/iotests.py | 7 +++++++
 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +0 -0
index 7233983..a2088c7 100644
@@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
 socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
 debug = False
 
Quoted 7 lines

tests/qemu-iotests/iotests.py qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') · line 63

Quoted 4 lines
tests/qemu-iotests/iotests.py +4 -0
+def blind_remove(filename):
+    try:
+        os.remove(filename)
+    except OSError, error:

I'm assuming this works for both python 2 and 3?

Appears to be python2 specific syntax, actually. using "as error" appears to work in both 2.7 and 3.whatever, and according to
http://python3porting.com/differences.html will work in 2.6 too.

Quoted 7 lines

tests/qemu-iotests/iotests.py qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') · line 66

Quoted 3 lines
tests/qemu-iotests/iotests.py +3 -0
+        if error.errno != errno.ENOENT:
+            raise
+

Weak, since I'm not the strongest at python, but you can add:

author
#10 lore raw

PATCH v3 4/5 qemu-iotests: make python tests attempt to leave intermediate files

In reply to Jeff Cody

Now that 'check' will clean up after tests, try and make python tests leave intermediate files so that they might be inspectable on failure.

This isn't perfect; the python unittest framework runs multiple tests, even if previous tests failed. So we need to make sure that each test still begins with a "clean" slate, to prevent false positives or tainted test runs.

Rather than delete images in the unittest tearDown, invert this and delete images to be used in that test at the beginning of the setUp. This is to make sure that the test run is not inadvertently using file droppings from previous runs. We must use 'blind_remove' then for these, as the files might not exist yet, but we don't want to throw an error for that.

---
 tests/qemu-iotests/030 |  8 +++---
 tests/qemu-iotests/040 | 35 ++++++++++---------------
 tests/qemu-iotests/041 | 70 +++++++++++++++++++++-----------------------------
 tests/qemu-iotests/044 |  8 ++----
 tests/qemu-iotests/045 | 14 +++++-----
 tests/qemu-iotests/055 | 36 +++++++++-----------------
 tests/qemu-iotests/056 | 13 ++++------
 tests/qemu-iotests/057 |  6 ++---
 tests/qemu-iotests/065 |  6 ++---
 tests/qemu-iotests/096 |  5 ++--
 tests/qemu-iotests/118 | 31 ++++++++++------------
 tests/qemu-iotests/124 | 21 +++++----------
 tests/qemu-iotests/132 |  9 +++----
 tests/qemu-iotests/136 |  3 ++-
 tests/qemu-iotests/139 |  6 ++---
 tests/qemu-iotests/147 | 16 ++++--------
 tests/qemu-iotests/148 |  7 ++---
 tests/qemu-iotests/152 |  9 +++----
 tests/qemu-iotests/155 | 15 +++++------
 tests/qemu-iotests/165 |  6 ++---
 20 files changed, 130 insertions(+), 194 deletions(-)
tests/qemu-iotests/030 +4 -4
index d745cb4..051fb0c 100755
@@ -21,7 +21,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 backing_img = os.path.join(iotests.test_dir, 'backing.img')
 mid_img = os.path.join(iotests.test_dir, 'mid.img')
@@ -31,6 +31,9 @@ class TestSingleDrive(iotests.QMPTestCase):
     image_len = 1 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(mid_img)
+        blind_remove(backing_img)
         iotests.create_image(backing_img, TestSingleDrive.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
@@ -41,9 +44,6 @@ class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(mid_img)
-        os.remove(backing_img)
 
     def test_stream(self):
         self.assert_no_active_block_jobs()
tests/qemu-iotests/040 +14 -21
index 95b7510..736afa7 100755
@@ -24,7 +24,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 import struct
 import errno
 
@@ -76,6 +76,9 @@ class TestSingleDrive(ImageCommitTestCase):
     test_len = 1 * 1024 * 256
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(mid_img)
+        blind_remove(backing_img)
         iotests.create_image(backing_img, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
@@ -88,9 +91,6 @@ class TestSingleDrive(ImageCommitTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(mid_img)
-        os.remove(backing_img)
 
     def test_commit(self):
         self.run_commit_test(mid_img, backing_img)
@@ -214,6 +214,9 @@ class TestRelativePaths(ImageCommitTestCase):
         except OSError as exception:
             if exception.errno != errno.EEXIST:
                 raise
+        blind_remove(self.test_img)
+        blind_remove(self.mid_img_abs)
+        blind_remove(self.backing_img_abs)
         iotests.create_image(self.backing_img_abs, TestRelativePaths.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.backing_img_abs, self.mid_img_abs)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.mid_img_abs, self.test_img)
@@ -226,16 +229,6 @@ class TestRelativePaths(ImageCommitTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(self.test_img)
-        os.remove(self.mid_img_abs)
-        os.remove(self.backing_img_abs)
-        try:
-            os.rmdir(os.path.join(iotests.test_dir, self.dir1))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir3))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir2))
-        except OSError as exception:
-            if exception.errno != errno.EEXIST and exception.errno != errno.ENOTEMPTY:
-                raise
 
     def test_commit(self):
         self.run_commit_test(self.mid_img, self.backing_img)
@@ -280,6 +273,9 @@ class TestSetSpeed(ImageCommitTestCase):
     image_len = 80 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(mid_img)
+        blind_remove(backing_img)
         qemu_img('create', backing_img, str(TestSetSpeed.image_len))
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
@@ -290,9 +286,6 @@ class TestSetSpeed(ImageCommitTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(mid_img)
-        os.remove(backing_img)
 
     def test_set_speed(self):
         self.assert_no_active_block_jobs()
@@ -319,6 +312,10 @@ class TestReopenOverlay(ImageCommitTestCase):
     img3 = os.path.join(iotests.test_dir, '3.img')
 
     def setUp(self):
+        blind_remove(self.img0)
+        blind_remove(self.img1)
+        blind_remove(self.img2)
+        blind_remove(self.img3)
         iotests.create_image(self.img0, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.img0, self.img1)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % self.img1, self.img2)
@@ -329,10 +326,6 @@ class TestReopenOverlay(ImageCommitTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(self.img0)
-        os.remove(self.img1)
-        os.remove(self.img2)
-        os.remove(self.img3)
 
     # This tests what happens when the overlay image of the 'top' node
     # needs to be reopened in read-write mode in order to update the
tests/qemu-iotests/041 +29 -41

184 lines not on this page · raw message

tests/qemu-iotests/044 +2 -6
index 11ea0f4..6b1a897 100755
@@ -23,7 +23,7 @@ import os
 import qcow2
 from qcow2 import QcowHeader
 import iotests
-from iotests import qemu_img, qemu_img_verbose, qemu_io
+from iotests import qemu_img, qemu_img_verbose, qemu_io, blind_remove
 import struct
 import subprocess
 
@@ -99,15 +99,11 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
 
 
     def setUp(self):
+        blind_remove(test_img)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'cluster_size=512', test_img, '16G')
         self.preallocate(test_img)
         pass
 
-
-    def tearDown(self):
-        os.remove(test_img)
-        pass
-
     def test_grow_refcount_table(self):
         qemu_io('-c', 'write 3800M 1M', test_img)
         qemu_img_verbose('check' , test_img)
tests/qemu-iotests/045 +7 -7
index 6be8fc4..2edb84a 100755
@@ -20,7 +20,7 @@
 
 import os
 import iotests
-from iotests import qemu_img
+from iotests import qemu_img, blind_remove
 
 image0 = os.path.join(iotests.test_dir, 'image0')
 image1 = os.path.join(iotests.test_dir, 'image1')
@@ -31,6 +31,11 @@ image4 = os.path.join(iotests.test_dir, 'image4')
 class TestFdSets(iotests.QMPTestCase):
 
     def setUp(self):
+        blind_remove(image0)
+        blind_remove(image1)
+        blind_remove(image2)
+        blind_remove(image3)
+        blind_remove(image4)
         self.vm = iotests.VM()
         qemu_img('create', '-f', iotests.imgfmt, image0, '128K')
         qemu_img('create', '-f', iotests.imgfmt, image1, '128K')
@@ -57,11 +62,6 @@ class TestFdSets(iotests.QMPTestCase):
         self.file2.close()
         self.file3.close()
         self.file4.close()
-        os.remove(image0)
-        os.remove(image1)
-        os.remove(image2)
-        os.remove(image3)
-        os.remove(image4)
 
     def test_query_fdset(self):
         result = self.vm.qmp('query-fdsets')
@@ -128,6 +128,7 @@ class TestFdSets(iotests.QMPTestCase):
 # Add fd at runtime, there are two ways: monitor related or fdset related
 class TestSCMFd(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(image0)
         self.vm = iotests.VM()
         qemu_img('create', '-f', iotests.imgfmt, image0, '128K')
         # Add an unused monitor, to verify it works fine when two monitor
@@ -137,7 +138,6 @@ class TestSCMFd(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(image0)
 
     def _send_fd_by_SCM(self):
         ret = self.vm.send_fd_scm(image0)
tests/qemu-iotests/055 +12 -24
index e1206ca..50588f8 100755
@@ -23,7 +23,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
 target_img = os.path.join(iotests.test_dir, 'target.img')
@@ -32,6 +32,7 @@ blockdev_target_img = os.path.join(iotests.test_dir, 'blockdev-target.img')
 image_len = 64 * 1024 * 1024 # MB
 
 def setUpModule():
+    blind_remove(test_img)
     qemu_img('create', '-f', iotests.imgfmt, test_img, str(image_len))
     qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x11 0 64k', test_img)
     qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x00 64k 128k', test_img)
@@ -40,12 +41,11 @@ def setUpModule():
     qemu_io('-f', iotests.imgfmt, '-c', 'write -P0xdc 32M 124k', test_img)
     qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x33 67043328 64k', test_img)
 
-def tearDownModule():
-    os.remove(test_img)
-
 
 class TestSingleDrive(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(blockdev_target_img)
+        blind_remove(target_img)
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(image_len))
 
         self.vm = iotests.VM().add_drive(test_img)
@@ -56,11 +56,6 @@ class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(blockdev_target_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def do_test_cancel(self, cmd, target):
         self.assert_no_active_block_jobs()
@@ -164,6 +159,8 @@ class TestSingleDrive(iotests.QMPTestCase):
 
 class TestSetSpeed(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(blockdev_target_img)
+        blind_remove(target_img)
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(image_len))
 
         self.vm = iotests.VM().add_drive(test_img)
@@ -172,11 +169,6 @@ class TestSetSpeed(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(blockdev_target_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def do_test_set_speed(self, cmd, target):
         self.assert_no_active_block_jobs()
@@ -248,6 +240,8 @@ class TestSetSpeed(iotests.QMPTestCase):
 
 class TestSingleTransaction(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(blockdev_target_img)
+        blind_remove(target_img)
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(image_len))
 
         self.vm = iotests.VM().add_drive(test_img)
@@ -258,11 +252,6 @@ class TestSingleTransaction(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(blockdev_target_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def do_test_cancel(self, cmd, target):
         self.assert_no_active_block_jobs()
@@ -452,13 +441,12 @@ class TestDriveCompression(iotests.QMPTestCase):
     fmt_supports_compression = [{'type': 'qcow2', 'args': ()},
                                 {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}]
 
+    def setUp(self):
+        blind_remove(blockdev_target_img)
+        blind_remove(target_img)
+
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(blockdev_target_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def do_prepare_drives(self, fmt, args, attach_target):
         self.vm = iotests.VM().add_drive(test_img)
tests/qemu-iotests/056 +5 -8
index 04f2c3c..3aefb93 100755
@@ -23,7 +23,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io, create_image
+from iotests import qemu_img, qemu_io, create_image, blind_remove
 
 backing_img = os.path.join(iotests.test_dir, 'backing.img')
 test_img = os.path.join(iotests.test_dir, 'test.img')
@@ -33,6 +33,9 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
     image_len = 64 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(backing_img)
+        blind_remove(target_img)
         create_image(backing_img, TestSyncModesNoneAndTop.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         qemu_io('-c', 'write -P0x41 0 512', test_img)
@@ -44,12 +47,6 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(backing_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def test_complete_top(self):
         self.assert_no_active_block_jobs()
@@ -84,12 +81,12 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
 
 class TestBeforeWriteNotifier(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(target_img)
         self.vm = iotests.VM().add_drive_raw("file=blkdebug::null-co://,id=drive0,align=65536,driver=blkdebug")
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(target_img)
 
     def test_before_write_notifier(self):
         self.vm.pause_drive("drive0")
tests/qemu-iotests/057 +3 -3
index 9f0a5a3..0d99959 100755
@@ -23,7 +23,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 test_drv_base_name = 'drive'
 
@@ -36,6 +36,8 @@ class ImageSnapshotTestCase(iotests.QMPTestCase):
 
     def _setUp(self, test_img_base_name, image_num):
         self.vm = iotests.VM()
+        for dev_expect in self.expect:
+            blind_remove(dev_expect['image'])
         for i in range(0, image_num):
             filename = '%s%d' % (test_img_base_name, i)
             img = os.path.join(iotests.test_dir, filename)
@@ -49,8 +51,6 @@ class ImageSnapshotTestCase(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        for dev_expect in self.expect:
-            os.remove(dev_expect['image'])
 
     def createSnapshotInTransaction(self, snapshot_num, abort = False):
         actions = []
tests/qemu-iotests/065 +2 -4
index 72aa970..b63ee13 100755
@@ -23,7 +23,7 @@ import os
 import re
 import json
 import iotests
-from iotests import qemu_img, qemu_img_pipe
+from iotests import qemu_img, qemu_img_pipe, blind_remove
 import unittest
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
@@ -32,14 +32,12 @@ class TestImageInfoSpecific(iotests.QMPTestCase):
     '''Abstract base class for ImageInfoSpecific tests'''
 
     def setUp(self):
+        blind_remove(test_img)
         if self.img_options is None:
             self.skipTest('Skipping abstract test class')
         qemu_img('create', '-f', iotests.imgfmt, '-o', self.img_options,
                  test_img, '128K')
 
-    def tearDown(self):
-        os.remove(test_img)
-
 class TestQemuImgInfo(TestImageInfoSpecific):
     '''Abstract base class for qemu-img info tests'''
 
tests/qemu-iotests/096 +3 -2
index aeeb375..d1c4902 100644
@@ -21,6 +21,7 @@
 
 import iotests
 import os
+from iotests import blind_remove
 
 class TestLiveSnapshot(iotests.QMPTestCase):
     base_img = os.path.join(iotests.test_dir, 'base.img')
@@ -30,6 +31,8 @@ class TestLiveSnapshot(iotests.QMPTestCase):
     iops_size = 1024
 
     def setUp(self):
+        blind_remove(self.base_img)
+        blind_remove(self.target_img)
         opts = []
         opts.append('node-name=base')
         opts.append('throttling.group=%s' % self.group)
@@ -41,8 +44,6 @@ class TestLiveSnapshot(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(self.base_img)
-        os.remove(self.target_img)
 
     def checkConfig(self, active_layer):
         result = self.vm.qmp('query-block')
tests/qemu-iotests/118 +14 -17
index 8a9e838..d90ea98 100755
@@ -23,7 +23,7 @@ import os
 import stat
 import time
 import iotests
-from iotests import qemu_img
+from iotests import qemu_img, blind_remove
 
 old_img = os.path.join(iotests.test_dir, 'test0.img')
 new_img = os.path.join(iotests.test_dir, 'test1.img')
@@ -323,6 +323,8 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass):
     was_empty = False
 
     def setUp(self, media, interface):
+        blind_remove(old_img)
+        blind_remove(new_img)
         qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
         qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
         self.vm = iotests.VM()
@@ -336,8 +338,6 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(old_img)
-        os.remove(new_img)
 
     def test_insert_on_filled(self):
         result = self.vm.qmp('blockdev-add',
@@ -360,13 +360,13 @@ class TestInitiallyEmpty(GeneralChangeTestsBaseClass):
     was_empty = True
 
     def setUp(self, media, interface):
+        blind_remove(new_img)
         qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
         self.vm = iotests.VM().add_drive(None, 'media=%s' % media, interface)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(new_img)
 
     def test_remove_on_empty(self):
         result = self.vm.qmp('blockdev-open-tray', device='drive0')
@@ -411,16 +411,16 @@ class TestFloppyInitiallyEmpty(TestInitiallyEmpty):
 
 class TestChangeReadOnly(ChangeBaseClass):
     def setUp(self):
-        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
-        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
-        self.vm = iotests.VM()
-
-    def tearDown(self):
-        self.vm.shutdown()
         os.chmod(old_img, 0666)
         os.chmod(new_img, 0666)
-        os.remove(old_img)
-        os.remove(new_img)
+        blind_remove(old_img)
+        blind_remove(new_img)
+        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
+        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
+        self.vm = iotests.VM()
+
+    def tearDown(self):
+        self.vm.shutdown()
 
     def test_ro_ro_retain(self):
         os.chmod(old_img, 0444)
@@ -645,6 +645,8 @@ TestInitiallyEmpty = None
 
 class TestBlockJobsAfterCycle(ChangeBaseClass):
     def setUp(self):
+        blind_remove(old_img)
+        blind_remove(new_img)
         qemu_img('create', '-f', iotests.imgfmt, old_img, '1M')
 
         self.vm = iotests.VM()
@@ -678,11 +680,6 @@ class TestBlockJobsAfterCycle(ChangeBaseClass):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(old_img)
-        try:
-            os.remove(new_img)
-        except OSError:
-            pass
 
     def test_snapshot_and_commit(self):
         # We need backing file support
tests/qemu-iotests/124 +7 -14
index 8e76e62..1aabe64 100644
@@ -22,20 +22,13 @@
 
 import os
 import iotests
+from iotests import blind_remove
 
 
 def io_write_patterns(img, patterns):
     for pattern in patterns:
         iotests.qemu_io('-c', 'write -P%s %s %s' % pattern, img)
 
-
-def try_remove(img):
-    try:
-        os.remove(img)
-    except OSError:
-        pass
-
-
 def transaction_action(action, **kwargs):
     return {
         'type': action,
@@ -82,13 +75,13 @@ class Bitmap:
 
     def del_target(self):
         for image in self.backups.pop():
-            try_remove(image)
+            blind_remove(image)
         self.num -= 1
 
     def cleanup(self):
         for backup in self.backups:
             for image in backup:
-                try_remove(image)
+                blind_remove(image)
 
 
 class TestIncrementalBackupBase(iotests.QMPTestCase):
@@ -102,6 +95,10 @@ class TestIncrementalBackupBase(iotests.QMPTestCase):
 
 
     def setUp(self):
+        for filename in self.files:
+            blind_remove(filename)
+        for bitmap in self.bitmaps:
+            bitmap.cleanup()
         # Create a base image with a distinctive patterning
         drive0 = self.add_node('drive0')
         self.img_create(drive0['file'], drive0['fmt'])
@@ -273,10 +270,6 @@ class TestIncrementalBackupBase(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        for bitmap in self.bitmaps:
-            bitmap.cleanup()
-        for filename in self.files:
-            try_remove(filename)
 
 
 
tests/qemu-iotests/132 +3 -6
index f53ef6e..375d9ed 100644
@@ -21,7 +21,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
 target_img = os.path.join(iotests.test_dir, 'target.img')
@@ -30,6 +30,8 @@ class TestSingleDrive(iotests.QMPTestCase):
     image_len = 2 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(target_img)
         # Write data to the image so we can compare later
         qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestSingleDrive.image_len))
         qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 0 2M', test_img)
@@ -39,11 +41,6 @@ class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def test_mirror_discard(self):
         result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
tests/qemu-iotests/136 +2 -1
index 4b99489..7209cfc 100644
@@ -21,6 +21,7 @@
 
 import iotests
 import os
+from iotests import blind_remove
 
 interval_length = 10
 nsec_per_sec = 1000000000
@@ -68,6 +69,7 @@ sector = "%d"
         file.close()
 
     def setUp(self):
+        blind_remove(blkdebug_file)
         drive_args = []
         drive_args.append("stats-intervals.0=%d" % interval_length)
         drive_args.append("stats-account-invalid=%s" %
@@ -84,7 +86,6 @@ sector = "%d"
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(blkdebug_file)
 
     def accounted_ops(self, read = False, write = False, flush = False):
         ops = 0
tests/qemu-iotests/139 +3 -3
index 50cf40f..7d05bfb 100644
@@ -22,6 +22,7 @@
 import os
 import iotests
 import time
+from iotests import blind_remove
 
 base_img = os.path.join(iotests.test_dir, 'base.img')
 new_img = os.path.join(iotests.test_dir, 'new.img')
@@ -29,6 +30,8 @@ new_img = os.path.join(iotests.test_dir, 'new.img')
 class TestBlockdevDel(iotests.QMPTestCase):
 
     def setUp(self):
+        blind_remove(base_img)
+        blind_remove(new_img)
         iotests.qemu_img('create', '-f', iotests.imgfmt, base_img, '1M')
         self.vm = iotests.VM()
         self.vm.add_device("virtio-scsi-pci,id=virtio-scsi")
@@ -36,9 +39,6 @@ class TestBlockdevDel(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(base_img)
-        if os.path.isfile(new_img):
-            os.remove(new_img)
 
     # Check whether a BlockDriverState exists
     def checkBlockDriverState(self, node, must_exist = True):
tests/qemu-iotests/147 +5 -11
index db34838..baf72d0 100755
@@ -23,7 +23,7 @@ import socket
 import stat
 import time
 import iotests
-from iotests import cachemode, imgfmt, qemu_img, qemu_nbd
+from iotests import cachemode, imgfmt, qemu_img, qemu_nbd, blind_remove
 
 NBD_PORT = 10811
 
@@ -70,17 +70,14 @@ class NBDBlockdevAddBase(iotests.QMPTestCase):
 
 class QemuNBD(NBDBlockdevAddBase):
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(unix_socket)
         qemu_img('create', '-f', iotests.imgfmt, test_img, '64k')
         self.vm = iotests.VM()
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        try:
-            os.remove(unix_socket)
-        except OSError:
-            pass
 
     def _server_up(self, *args):
         self.assertEqual(qemu_nbd('-f', imgfmt, test_img, *args), 0)
@@ -105,6 +102,8 @@ class QemuNBD(NBDBlockdevAddBase):
 
 class BuiltinNBD(NBDBlockdevAddBase):
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(unix_socket)
         qemu_img('create', '-f', iotests.imgfmt, test_img, '64k')
         self.vm = iotests.VM()
         self.vm.launch()
@@ -118,11 +117,6 @@ class BuiltinNBD(NBDBlockdevAddBase):
     def tearDown(self):
         self.vm.shutdown()
         self.server.shutdown()
-        os.remove(test_img)
-        try:
-            os.remove(unix_socket)
-        except OSError:
-            pass
 
     def _server_up(self, address):
         result = self.server.qmp('nbd-server-start', addr=address)
tests/qemu-iotests/148 +4 -3
index e01b061..562df85 100644
@@ -21,6 +21,7 @@
 
 import os
 import iotests
+from iotests import blind_remove
 
 imgs = (os.path.join(iotests.test_dir, 'quorum0.img'),
         os.path.join(iotests.test_dir, 'quorum1.img'),
@@ -48,6 +49,9 @@ sector = "%d"
         file.close()
 
     def setUp(self):
+        for i in range(len(imgs)):
+            blind_remove(imgs[i])
+            blind_remove(img_conf[i])
         driveopts = ['driver=quorum', 'vote-threshold=2']
         driveopts.append('read-pattern=%s' % self.read_pattern)
         for i in range(len(imgs)):
@@ -64,9 +68,6 @@ sector = "%d"
 
     def tearDown(self):
         self.vm.shutdown()
-        for i in range(len(imgs)):
-            os.remove(imgs[i])
-            os.remove(img_conf[i])
 
     def do_check_event(self, node, sector = 0):
         if node == None:
tests/qemu-iotests/152 +3 -6
index fec546d..b2a92db 100644
@@ -20,24 +20,21 @@
 
 import os
 import iotests
-from iotests import qemu_img
+from iotests import qemu_img, blind_remove
 
 test_img = os.path.join(iotests.test_dir, 'test.img')
 target_img = os.path.join(iotests.test_dir, 'target.img')
 
 class TestUnaligned(iotests.QMPTestCase):
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(target_img)
         qemu_img('create', '-f', iotests.imgfmt, test_img, '512')
         self.vm = iotests.VM().add_drive(test_img)
         self.vm.launch()
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def test_unaligned(self):
         result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
tests/qemu-iotests/155 +6 -9
index 0b86ea4..4c0aa2e 100755
@@ -23,7 +23,7 @@
 
 import os
 import iotests
-from iotests import qemu_img
+from iotests import qemu_img, blind_remove
 
 back0_img = os.path.join(iotests.test_dir, 'back0.' + iotests.imgfmt)
 back1_img = os.path.join(iotests.test_dir, 'back1.' + iotests.imgfmt)
@@ -51,6 +51,11 @@ class BaseClass(iotests.QMPTestCase):
     target_real_backing = None
 
     def setUp(self):
+        blind_remove(source_img)
+        blind_remove(back2_img)
+        blind_remove(back1_img)
+        blind_remove(back0_img)
+        blind_remove(target_img)
         qemu_img('create', '-f', iotests.imgfmt, back0_img, '1M')
         qemu_img('create', '-f', iotests.imgfmt, '-b', back0_img, back1_img)
         qemu_img('create', '-f', iotests.imgfmt, '-b', back1_img, back2_img)
@@ -95,14 +100,6 @@ class BaseClass(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(source_img)
-        os.remove(back2_img)
-        os.remove(back1_img)
-        os.remove(back0_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass
 
     def findBlockNode(self, node_name, id=None):
         if id:
tests/qemu-iotests/165 +2 -4
index 74d7b79..cd6fff7 100755
@@ -21,7 +21,7 @@
 import os
 import re
 import iotests
-from iotests import qemu_img
+from iotests import qemu_img, blind_remove
 
 disk = os.path.join(iotests.test_dir, 'disk')
 disk_size = 0x40000000 # 1G
@@ -36,11 +36,9 @@ regions2 = ((0x10000000, 0x20000),
 class TestPersistentDirtyBitmap(iotests.QMPTestCase):
 
     def setUp(self):
+        blind_remove(disk)
         qemu_img('create', '-f', iotests.imgfmt, disk, str(disk_size))
 
-    def tearDown(self):
-        os.remove(disk)
-
     def mkVm(self):
         return iotests.VM().add_drive(disk)
 
Signature · 1 line
2.9.5
Reviewed-by on v3 4/5
#11 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 30 lines · Jeff Cody

Now that 'check' will clean up after tests, try and make python tests leave intermediate files so that they might be inspectable on failure.

This isn't perfect; the python unittest framework runs multiple tests, even if previous tests failed. So we need to make sure that each test still begins with a "clean" slate, to prevent false positives or tainted test runs.

Rather than delete images in the unittest tearDown, invert this and delete images to be used in that test at the beginning of the setUp. This is to make sure that the test run is not inadvertently using file droppings from previous runs. We must use 'blind_remove' then for these, as the files might not exist yet, but we don't want to throw an error for that.

---

+++ b/tests/qemu-iotests/030

tests/qemu-iotests/030 +1 -1
@@ -21,7 +21,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 backing_img = os.path.join(iotests.test_dir, 'backing.img')
 mid_img = os.path.join(iotests.test_dir, 'mid.img')

tests/qemu-iotests/030 class TestSingleDrive(iotests.QMPTestCase): · line 36

Quoted 6 lines
tests/qemu-iotests/030 +3 -0
@@ -31,6 +31,9 @@ class TestSingleDrive(iotests.QMPTestCase):
     image_len = 1 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(mid_img)
+        blind_remove(backing_img)

Would it be any more pythonic to have support for:

blind_remove(test_img, mid_img, backing_img)

built into the previous patch?

tests/qemu-iotests/040 class TestRelativePaths(ImageCommitTestCase): · line 238

Quoted 12 lines
tests/qemu-iotests/040 +0 -10
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(self.test_img)
-        os.remove(self.mid_img_abs)
-        os.remove(self.backing_img_abs)
-        try:
-            os.rmdir(os.path.join(iotests.test_dir, self.dir1))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir3))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir2))
-        except OSError as exception:
-            if exception.errno != errno.EEXIST and exception.errno != errno.ENOTEMPTY:
-                raise

The code removed here is using a syntax that differs from what you used in 3/5 when defining blind_remove; does that matter for 3/5?

Quoted 7 lines

+++ b/tests/qemu-iotests/041

tests/qemu-iotests/041 +1 -0
+        blind_remove(target_img)
         iotests.create_image(backing_img, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=base")

tests/qemu-iotests/041 class TestSingleDrive(iotests.QMPTestCase): · line 57

Quoted 9 lines
tests/qemu-iotests/041 +0 -6
@@ -49,12 +52,6 @@ class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(backing_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass

You're changing failures other than ENOENT from ignored to explicit - nice little bug-fix along the way :) I notice this pattern in multiple tests; is it worth mentioning in the commit message as intentional?

tests/qemu-iotests/041 class TestRepairQuorum(iotests.QMPTestCase): · line 792

Quoted 6 lines
tests/qemu-iotests/041 +2 -0
@@ -797,6 +788,9 @@ class TestRepairQuorum(iotests.QMPTestCase):
     IMAGES = [ quorum_img1, quorum_img2, quorum_img3 ]
 
     def setUp(self):
+        for i in self.IMAGES + [ quorum_repair_img, quorum_snapshot_file ]:
+            blind_remove(i)

Again, would it be more pythonic if blind_remove() could take a list and automatically work on each element of the list, rather than having to make the caller iterate?

Quoted 11 lines
tests/qemu-iotests/057 +2 -1
+++ b/tests/qemu-iotests/057
@@ -23,7 +23,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 test_drv_base_name = 'drive'
 

tests/qemu-iotests/057 class ImageSnapshotTestCase(iotests.QMPTestCase): · line 40

Quoted 5 lines
tests/qemu-iotests/057 +2 -0
@@ -36,6 +36,8 @@ class ImageSnapshotTestCase(iotests.QMPTestCase):
 
     def _setUp(self, test_img_base_name, image_num):
         self.vm = iotests.VM()
+        for dev_expect in self.expect:
+            blind_remove(dev_expect['image'])

Another place where python magic could make the caller nicer?

Quoted 14 lines
tests/qemu-iotests/118 +1 -6
+++ b/tests/qemu-iotests/118
 
@@ -411,16 +411,16 @@ class TestFloppyInitiallyEmpty(TestInitiallyEmpty):
 
 class TestChangeReadOnly(ChangeBaseClass):
     def setUp(self):
-        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
-        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
-        self.vm = iotests.VM()
-
-    def tearDown(self):
-        self.vm.shutdown()
         os.chmod(old_img, 0666)
         os.chmod(new_img, 0666)

tests/qemu-iotests/118 class TestFloppyInitiallyEmpty(TestInitiallyEmpty): · line 423

Quoted 10 lines
tests/qemu-iotests/118 +8 -2
-        os.remove(old_img)
-        os.remove(new_img)
+        blind_remove(old_img)
+        blind_remove(new_img)
+        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
+        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
+        self.vm = iotests.VM()
+
+    def tearDown(self):
+        self.vm.shutdown()

The script framework doesn't have any problem removing left-over read-only files, correct? (If it does, then earlier in the series you may need to add 'chmod -R u+rwx scratch/$seq' prior to its removal?)

But overall, I didn't see any problems, so I'm okay with:

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#12 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 40 lines · Eric Blake
Quoted 30 lines · Jeff Cody

Now that 'check' will clean up after tests, try and make python tests leave intermediate files so that they might be inspectable on failure.

This isn't perfect; the python unittest framework runs multiple tests, even if previous tests failed. So we need to make sure that each test still begins with a "clean" slate, to prevent false positives or tainted test runs.

Rather than delete images in the unittest tearDown, invert this and delete images to be used in that test at the beginning of the setUp. This is to make sure that the test run is not inadvertently using file droppings from previous runs. We must use 'blind_remove' then for these, as the files might not exist yet, but we don't want to throw an error for that.

---

+++ b/tests/qemu-iotests/030

tests/qemu-iotests/030 +1 -1
@@ -21,7 +21,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 backing_img = os.path.join(iotests.test_dir, 'backing.img')
 mid_img = os.path.join(iotests.test_dir, 'mid.img')

tests/qemu-iotests/030 class TestSingleDrive(iotests.QMPTestCase): · line 36

Quoted 6 lines
tests/qemu-iotests/030 +3 -0
@@ -31,6 +31,9 @@ class TestSingleDrive(iotests.QMPTestCase):
     image_len = 1 * 1024 * 1024 # MB
 
     def setUp(self):
+        blind_remove(test_img)
+        blind_remove(mid_img)
+        blind_remove(backing_img)

Would it be any more pythonic to have support for:

Quoted 4 lines

blind_remove(test_img, mid_img, backing_img)

built into the previous patch?

It should probably either take an iterable, or an arbitrary number of arguments, or both, I dunno. I'm not a python.

Quoted 96 lines

tests/qemu-iotests/040 class TestRelativePaths(ImageCommitTestCase): · line 238

Quoted 12 lines
tests/qemu-iotests/040 +0 -10
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(self.test_img)
-        os.remove(self.mid_img_abs)
-        os.remove(self.backing_img_abs)
-        try:
-            os.rmdir(os.path.join(iotests.test_dir, self.dir1))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir3))
-            os.rmdir(os.path.join(iotests.test_dir, self.dir2))
-        except OSError as exception:
-            if exception.errno != errno.EEXIST and exception.errno != errno.ENOTEMPTY:
-                raise

The code removed here is using a syntax that differs from what you used in 3/5 when defining blind_remove; does that matter for 3/5?

Quoted 7 lines

+++ b/tests/qemu-iotests/041

tests/qemu-iotests/041 +1 -0
+        blind_remove(target_img)
         iotests.create_image(backing_img, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=base")

tests/qemu-iotests/041 class TestSingleDrive(iotests.QMPTestCase): · line 57

Quoted 9 lines
tests/qemu-iotests/041 +0 -6
@@ -49,12 +52,6 @@ class TestSingleDrive(iotests.QMPTestCase):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.remove(test_img)
-        os.remove(backing_img)
-        try:
-            os.remove(target_img)
-        except OSError:
-            pass

You're changing failures other than ENOENT from ignored to explicit - nice little bug-fix along the way :) I notice this pattern in multiple tests; is it worth mentioning in the commit message as intentional?

tests/qemu-iotests/041 class TestRepairQuorum(iotests.QMPTestCase): · line 792

Quoted 6 lines
tests/qemu-iotests/041 +2 -0
@@ -797,6 +788,9 @@ class TestRepairQuorum(iotests.QMPTestCase):
     IMAGES = [ quorum_img1, quorum_img2, quorum_img3 ]
 
     def setUp(self):
+        for i in self.IMAGES + [ quorum_repair_img, quorum_snapshot_file ]:
+            blind_remove(i)

Again, would it be more pythonic if blind_remove() could take a list and automatically work on each element of the list, rather than having to make the caller iterate?

Quoted 11 lines
tests/qemu-iotests/057 +2 -1
+++ b/tests/qemu-iotests/057
@@ -23,7 +23,7 @@
 import time
 import os
 import iotests
-from iotests import qemu_img, qemu_io
+from iotests import qemu_img, qemu_io, blind_remove
 
 test_drv_base_name = 'drive'
 

tests/qemu-iotests/057 class ImageSnapshotTestCase(iotests.QMPTestCase): · line 40

Quoted 5 lines
tests/qemu-iotests/057 +2 -0
@@ -36,6 +36,8 @@ class ImageSnapshotTestCase(iotests.QMPTestCase):
 
     def _setUp(self, test_img_base_name, image_num):
         self.vm = iotests.VM()
+        for dev_expect in self.expect:
+            blind_remove(dev_expect['image'])

Another place where python magic could make the caller nicer?

Quoted 14 lines
tests/qemu-iotests/118 +1 -6
+++ b/tests/qemu-iotests/118
 
@@ -411,16 +411,16 @@ class TestFloppyInitiallyEmpty(TestInitiallyEmpty):
 
 class TestChangeReadOnly(ChangeBaseClass):
     def setUp(self):
-        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
-        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
-        self.vm = iotests.VM()
-
-    def tearDown(self):
-        self.vm.shutdown()
         os.chmod(old_img, 0666)
         os.chmod(new_img, 0666)

tests/qemu-iotests/118 class TestFloppyInitiallyEmpty(TestInitiallyEmpty): · line 423

Quoted 10 lines
tests/qemu-iotests/118 +8 -2
-        os.remove(old_img)
-        os.remove(new_img)
+        blind_remove(old_img)
+        blind_remove(new_img)
+        qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k')
+        qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k')
+        self.vm = iotests.VM()
+
+    def tearDown(self):
+        self.vm.shutdown()

The script framework doesn't have any problem removing left-over read-only files, correct? (If it does, then earlier in the series you may need to add 'chmod -R u+rwx scratch/$seq' prior to its removal?)

Quoted 3 lines

But overall, I didn't see any problems, so I'm okay with:

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

--js

#13 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 11 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#14 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 10 lines · Eric Blake
Quoted 8 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

Quoted 8 lines
Quoted 3 lines

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

subtext was to have per-subtest files.

Quoted 8 lines

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

I guess where I am unsure is really if this is better than what we currently do, which is to (try) to clean up after each test as best as we can. I don't see it as too different from trying to clean up before each test.

It does give us the ability to leave behind a little detritus after a failed run, but it's so imperfect that I wonder if it's worth shifting this code around to change not much.

I won't die on this hill, it just strikes me a slightly less intuitive use of the python unittest framework.

--js

#15 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 33 lines · John Snow
Quoted 10 lines · Eric Blake
Quoted 8 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

Quoted 8 lines
Quoted 3 lines

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

subtext was to have per-subtest files.

Quoted 8 lines

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

Quoted 8 lines

I guess where I am unsure is really if this is better than what we currently do, which is to (try) to clean up after each test as best as we can. I don't see it as too different from trying to clean up before each test.

It does give us the ability to leave behind a little detritus after a failed run, but it's so imperfect that I wonder if it's worth shifting this code around to change not much.

An alternative is to define iotests.QMPTestCase.setUp() so it clears out iotests.test_dir. Unfortunately this still requires touching up all setUp() methods so that they call super(TheClass, self).setUp().

At least there would be no need to delete specific files by name (e.g. blind_remove(my_img)).

Stefan

author
#16 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 43 lines · Stefan Hajnoczi
Quoted 33 lines · John Snow
Quoted 10 lines · Eric Blake
Quoted 8 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

Quoted 8 lines
Quoted 3 lines

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

subtext was to have per-subtest files.

Quoted 8 lines

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

Quoted 8 lines

I guess where I am unsure is really if this is better than what we currently do, which is to (try) to clean up after each test as best as we can. I don't see it as too different from trying to clean up before each test.

It does give us the ability to leave behind a little detritus after a failed run, but it's so imperfect that I wonder if it's worth shifting this code around to change not much.

Quoted 7 lines

An alternative is to define iotests.QMPTestCase.setUp() so it clears out iotests.test_dir. Unfortunately this still requires touching up all setUp() methods so that they call super(TheClass, self).setUp().

At least there would be no need to delete specific files by name (e.g. blind_remove(my_img)).

One reason to only remove specific files used in the test, is that it increases the chance that intermediate files will be left behind in case of test failure of a different test case.

I think the real long-term solution is to run each unittest test case in its own subdirectory, so that no intermediate file removal is necessary, and each test case is self-contained.

-Jeff

#17 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 52 lines · Jeff Cody
Quoted 43 lines · Stefan Hajnoczi
Quoted 33 lines · John Snow
Quoted 10 lines · Eric Blake
Quoted 8 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

Quoted 8 lines
Quoted 3 lines

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

subtext was to have per-subtest files.

Quoted 8 lines

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

Quoted 8 lines

I guess where I am unsure is really if this is better than what we currently do, which is to (try) to clean up after each test as best as we can. I don't see it as too different from trying to clean up before each test.

It does give us the ability to leave behind a little detritus after a failed run, but it's so imperfect that I wonder if it's worth shifting this code around to change not much.

Quoted 7 lines

An alternative is to define iotests.QMPTestCase.setUp() so it clears out iotests.test_dir. Unfortunately this still requires touching up all setUp() methods so that they call super(TheClass, self).setUp().

At least there would be no need to delete specific files by name (e.g. blind_remove(my_img)).

Quoted 7 lines

One reason to only remove specific files used in the test, is that it increases the chance that intermediate files will be left behind in case of test failure of a different test case.

I think the real long-term solution is to run each unittest test case in its own subdirectory, so that no intermediate file removal is necessary, and each test case is self-contained.

That could be achieved in the same way:

Modify iotests.QMPTestCase.setUp() to create a new directory and chdir() into it. This still requires touching up all existing setUp() methods to call their superclass.

Stefan

author
#18 lore raw

Re: [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files

Quoted 61 lines · Stefan Hajnoczi
Quoted 52 lines · Jeff Cody
Quoted 43 lines · Stefan Hajnoczi
Quoted 33 lines · John Snow
Quoted 10 lines · Eric Blake
Quoted 8 lines · John Snow

I'm a little iffy on this patch; I know that ./check can take care of our temp files for us now, but because each python test is itself a little mini-harness, I'm a little leery of moving the teardown to setup and trying to pre-clean the confetti before the test begins.

What's the benefit? We still have to clean up these files per-test, but now it's slightly more error-prone and in a weird place.

Quoted 8 lines
Quoted 3 lines

If we want to try to preserve the most-recent-failure-files, perhaps we can define a setting in the python test-runner that allows us to globally skip file cleanup.

On the other hand, since each test is a mini-harness, globally skipping cleanup will make a two-part test fail on the second because of garbage left behind by the first.

subtext was to have per-subtest files.

Quoted 8 lines

Patch 5 adds a comment with another possible solution: teach the python mini-harness to either clean all files in the directory, or to relocate the directory according to test name, so that each mini-test starts with a fresh location, and cleanup is then handled by the harness rather than spaghetti pre-cleanup. But any solution is better than our current situation of nothing, so that's why I'm still okay with this patch as-is as offering more (even if not perfect) than before.

Quoted 8 lines

I guess where I am unsure is really if this is better than what we currently do, which is to (try) to clean up after each test as best as we can. I don't see it as too different from trying to clean up before each test.

It does give us the ability to leave behind a little detritus after a failed run, but it's so imperfect that I wonder if it's worth shifting this code around to change not much.

Quoted 7 lines

An alternative is to define iotests.QMPTestCase.setUp() so it clears out iotests.test_dir. Unfortunately this still requires touching up all setUp() methods so that they call super(TheClass, self).setUp().

At least there would be no need to delete specific files by name (e.g. blind_remove(my_img)).

Quoted 7 lines

One reason to only remove specific files used in the test, is that it increases the chance that intermediate files will be left behind in case of test failure of a different test case.

I think the real long-term solution is to run each unittest test case in its own subdirectory, so that no intermediate file removal is necessary, and each test case is self-contained.

Quoted 6 lines

That could be achieved in the same way:

Modify iotests.QMPTestCase.setUp() to create a new directory and chdir() into it. This still requires touching up all existing setUp() methods to call their superclass.

Good idea! I'll send out a v4 to just implement it this way; if I am going to touch all the python tests anyway, might as well go all the way.

Thanks,
Jeff

author
#19 lore raw

PATCH v3 5/5 qemu-iotests: add option to save temp files on error

In reply to Jeff Cody

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.

Note: this currently only works for bash tests, as the python tests still clean up after themselves manually.

---
 tests/qemu-iotests/check  | 10 +++++++++-
 tests/qemu-iotests/common |  6 ++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +9 -1
index f6ca85d..8a5fc0d 100755
@@ -370,7 +370,15 @@ do
             fi
         fi
 
-        rm -rf "$TEST_DIR_SEQ"
+        #TODO: There is some intial work to save intermediate files
+        #      in python tests, but it is imperfect.  Having each
+        #      test record its test name, and the tearDown function
+        #      just move intermediate images to a subdirectory with
+        #      the test name may prove more useful.
+        if [ "$save_on_err" != "true" ] || [ "$err" != "true" ]
+        then
+            rm -rf "$TEST_DIR_SEQ"
+        fi
 
     fi
 
tests/qemu-iotests/common +6 -0
index d34c11c..d08b233 100644
@@ -42,6 +42,7 @@ expunge=true
 have_test_arg=false
 randomize=false
 cachemode=false
+save_on_err=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 export IMGFMT=raw
@@ -172,6 +173,7 @@ other options
     -T                  output timestamps
     -r                  randomize test order
     -c mode             cache mode
+    -s                  save test scratch directory on test failure
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -349,6 +351,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
Signature · 1 line
2.9.5
Reviewed-by on v3 5/5
#20 lore raw

Re: [Qemu-devel] [PATCH v3 5/5] qemu-iotests: add option to save temp files on error

Quoted 18 lines · Jeff Cody

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.

Note: this currently only works for bash tests, as the python tests still clean up after themselves manually.

---
 tests/qemu-iotests/check  | 10 +++++++++-
 tests/qemu-iotests/common |  6 ++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +0 -0
index f6ca85d..8a5fc0d 100755

tests/qemu-iotests/check do · line 373

Quoted 5 lines
tests/qemu-iotests/check +1 -1
@@ -370,7 +370,15 @@ do
             fi
         fi
 
-        rm -rf "$TEST_DIR_SEQ"
+        #TODO: There is some intial work to save intermediate files

s/intial/initial/

tests/qemu-iotests/check do · line 377

Quoted 4 lines
tests/qemu-iotests/check +4 -0
+        #      in python tests, but it is imperfect.  Having each
+        #      test record its test name, and the tearDown function
+        #      just move intermediate images to a subdirectory with
+        #      the test name may prove more useful.

Comment works for me, and I'm fine with the idea you present here being in a followup patch. So with the typo fixed,

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Tested-by Reviewed-by on v3 5/5
#21 lore raw

Re: [Qemu-devel] [PATCH v3 5/5] qemu-iotests: add option to save temp files on error

In reply to Jeff Cody
Quoted 56 lines · Jeff Cody

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.

Note: this currently only works for bash tests, as the python tests still clean up after themselves manually.

---
 tests/qemu-iotests/check  | 10 +++++++++-
 tests/qemu-iotests/common |  6 ++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
tests/qemu-iotests/check +9 -1
index f6ca85d..8a5fc0d 100755
@@ -370,7 +370,15 @@ do
             fi
         fi
 
-        rm -rf "$TEST_DIR_SEQ"
+        #TODO: There is some intial work to save intermediate files
+        #      in python tests, but it is imperfect.  Having each
+        #      test record its test name, and the tearDown function
+        #      just move intermediate images to a subdirectory with
+        #      the test name may prove more useful.
+        if [ "$save_on_err" != "true" ] || [ "$err" != "true" ]
+        then
+            rm -rf "$TEST_DIR_SEQ"
+        fi
 
     fi
 
tests/qemu-iotests/common +2 -0
index d34c11c..d08b233 100644
@@ -42,6 +42,7 @@ expunge=true
 have_test_arg=false
 randomize=false
 cachemode=false
+save_on_err=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 export IMGFMT=raw
@@ -172,6 +173,7 @@ other options
     -T                  output timestamps
     -r                  randomize test order
     -c mode             cache mode
+    -s                  save test scratch directory on test failure
 
 testlist options
     -g group[,group...]        include tests from these groups

tests/qemu-iotests/common testlist options · line 360

Quoted 10 lines
tests/qemu-iotests/common +4 -0
@@ -349,6 +351,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

This, however, is definitely awesome.