Before this patch you could not run multiple tests concurrently as they
might clobber each other test files. This patch solves that by using
random temporary directory instead of `/tmp` (for writing output in the
individual tests and valgrind logs).

Furthermore, this patch stops removing everything in `/tmp/` matching a
certain pattern (`/tmp/*.{err,out,time}`). These might not be a property
of QEMU.

Running multiple concurrent tests in the same object directory is still
not supported though as the scratch directory and .bad and .notrun files
still interfere with each other. Also not touched is the situation that
/tmp/check.log and /tmp/check.sts are hard-coded (and thus unusable in
concurrent tests).

Signed-off-by: Peter Wu <pe...@lekensteyn.nl>
---
Hi,

This patch introduces a dependency on mktemp of coreutils. I could still not get
concurrent tests to work fully reliably (test 030 failed randomly with QED):

    FAIL: test_ignore (__main__.TestEIO)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "030", line 223, in test_ignore
        self.assert_qmp(result, 'return[0]/paused', False)
      File "/tmp/qemu/tests/qemu-iotests/iotests.py", line 233, in assert_qmp
        result = self.dictpath(d, path)
      File "/tmp/qemu/tests/qemu-iotests/iotests.py", line 221, in dictpath
        self.fail('invalid index "%s" in path "%s" in "%s"' % (idx, path, 
str(d)))
    AssertionError: invalid index "0" in path "return[0]/paused" in "[]"

I still think that the patches are valuable though, it reduces predictable file
names.

Kind regards,
Peter
---
 tests/qemu-iotests/001       | 2 +-
 tests/qemu-iotests/002       | 2 +-
 tests/qemu-iotests/003       | 2 +-
 tests/qemu-iotests/004       | 2 +-
 tests/qemu-iotests/005       | 2 +-
 tests/qemu-iotests/006       | 2 +-
 tests/qemu-iotests/007       | 2 +-
 tests/qemu-iotests/008       | 2 +-
 tests/qemu-iotests/009       | 2 +-
 tests/qemu-iotests/010       | 2 +-
 tests/qemu-iotests/011       | 2 +-
 tests/qemu-iotests/012       | 2 +-
 tests/qemu-iotests/013       | 2 +-
 tests/qemu-iotests/014       | 2 +-
 tests/qemu-iotests/015       | 2 +-
 tests/qemu-iotests/016       | 2 +-
 tests/qemu-iotests/017       | 2 +-
 tests/qemu-iotests/018       | 2 +-
 tests/qemu-iotests/019       | 2 +-
 tests/qemu-iotests/020       | 2 +-
 tests/qemu-iotests/021       | 2 +-
 tests/qemu-iotests/022       | 2 +-
 tests/qemu-iotests/023       | 2 +-
 tests/qemu-iotests/024       | 2 +-
 tests/qemu-iotests/025       | 2 +-
 tests/qemu-iotests/026       | 2 +-
 tests/qemu-iotests/027       | 2 +-
 tests/qemu-iotests/028       | 2 +-
 tests/qemu-iotests/029       | 2 +-
 tests/qemu-iotests/031       | 2 +-
 tests/qemu-iotests/032       | 2 +-
 tests/qemu-iotests/033       | 2 +-
 tests/qemu-iotests/034       | 2 +-
 tests/qemu-iotests/035       | 2 +-
 tests/qemu-iotests/036       | 2 +-
 tests/qemu-iotests/037       | 2 +-
 tests/qemu-iotests/038       | 2 +-
 tests/qemu-iotests/039       | 2 +-
 tests/qemu-iotests/042       | 2 +-
 tests/qemu-iotests/043       | 2 +-
 tests/qemu-iotests/046       | 2 +-
 tests/qemu-iotests/047       | 2 +-
 tests/qemu-iotests/049       | 2 +-
 tests/qemu-iotests/050       | 2 +-
 tests/qemu-iotests/051       | 2 +-
 tests/qemu-iotests/052       | 2 +-
 tests/qemu-iotests/053       | 2 +-
 tests/qemu-iotests/054       | 2 +-
 tests/qemu-iotests/058       | 2 +-
 tests/qemu-iotests/059       | 2 +-
 tests/qemu-iotests/060       | 2 +-
 tests/qemu-iotests/061       | 2 +-
 tests/qemu-iotests/062       | 2 +-
 tests/qemu-iotests/063       | 2 +-
 tests/qemu-iotests/064       | 2 +-
 tests/qemu-iotests/066       | 2 +-
 tests/qemu-iotests/067       | 2 +-
 tests/qemu-iotests/068       | 2 +-
 tests/qemu-iotests/069       | 2 +-
 tests/qemu-iotests/070       | 2 +-
 tests/qemu-iotests/071       | 2 +-
 tests/qemu-iotests/072       | 2 +-
 tests/qemu-iotests/073       | 2 +-
 tests/qemu-iotests/075       | 2 +-
 tests/qemu-iotests/076       | 2 +-
 tests/qemu-iotests/077       | 2 +-
 tests/qemu-iotests/078       | 2 +-
 tests/qemu-iotests/079       | 2 +-
 tests/qemu-iotests/080       | 2 +-
 tests/qemu-iotests/081       | 2 +-
 tests/qemu-iotests/082       | 2 +-
 tests/qemu-iotests/083       | 2 +-
 tests/qemu-iotests/084       | 2 +-
 tests/qemu-iotests/086       | 2 +-
 tests/qemu-iotests/087       | 2 +-
 tests/qemu-iotests/088       | 2 +-
 tests/qemu-iotests/089       | 2 +-
 tests/qemu-iotests/090       | 2 +-
 tests/qemu-iotests/092       | 2 +-
 tests/qemu-iotests/check     | 9 ++++++---
 tests/qemu-iotests/common.rc | 7 ++++---
 81 files changed, 89 insertions(+), 85 deletions(-)

diff --git a/tests/qemu-iotests/001 b/tests/qemu-iotests/001
index 4e16469..6472c67 100755
--- a/tests/qemu-iotests/001
+++ b/tests/qemu-iotests/001
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
index 6a865aa..112280a 100755
--- a/tests/qemu-iotests/002
+++ b/tests/qemu-iotests/002
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
index 98638d4..f60b6d7 100755
--- a/tests/qemu-iotests/003
+++ b/tests/qemu-iotests/003
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/004 b/tests/qemu-iotests/004
index 651072e..d878351 100755
--- a/tests/qemu-iotests/004
+++ b/tests/qemu-iotests/004
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
index ba1236d..e18d1c5 100755
--- a/tests/qemu-iotests/005
+++ b/tests/qemu-iotests/005
@@ -28,7 +28,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/006 b/tests/qemu-iotests/006
index 0c0cf5d..84589b7 100755
--- a/tests/qemu-iotests/006
+++ b/tests/qemu-iotests/006
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/007 b/tests/qemu-iotests/007
index fe1a743..bbbe0fc 100755
--- a/tests/qemu-iotests/007
+++ b/tests/qemu-iotests/007
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/008 b/tests/qemu-iotests/008
index 2d28efd..c0e6774 100755
--- a/tests/qemu-iotests/008
+++ b/tests/qemu-iotests/008
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
index 57a43f5..2cf52f7 100755
--- a/tests/qemu-iotests/009
+++ b/tests/qemu-iotests/009
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
index 896a005..e9c32e1 100755
--- a/tests/qemu-iotests/010
+++ b/tests/qemu-iotests/010
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
index 1c5158a..da7fc70 100755
--- a/tests/qemu-iotests/011
+++ b/tests/qemu-iotests/011
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/012 b/tests/qemu-iotests/012
index 7c5b689..d1d59b1 100755
--- a/tests/qemu-iotests/012
+++ b/tests/qemu-iotests/012
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013
index ea3cab9..6943933 100755
--- a/tests/qemu-iotests/013
+++ b/tests/qemu-iotests/013
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014
index b23c2db..2398864 100755
--- a/tests/qemu-iotests/014
+++ b/tests/qemu-iotests/014
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/015 b/tests/qemu-iotests/015
index 099d757..ea96464 100755
--- a/tests/qemu-iotests/015
+++ b/tests/qemu-iotests/015
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/016 b/tests/qemu-iotests/016
index 7ea9e94..f1864b7 100755
--- a/tests/qemu-iotests/016
+++ b/tests/qemu-iotests/016
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
index 3af3cdf..4f46bb7 100755
--- a/tests/qemu-iotests/017
+++ b/tests/qemu-iotests/017
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
index d8a7d43..8da2304 100755
--- a/tests/qemu-iotests/018
+++ b/tests/qemu-iotests/018
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
index f5ecbf5..537912f 100755
--- a/tests/qemu-iotests/019
+++ b/tests/qemu-iotests/019
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
index 2f258dc..e190043 100755
--- a/tests/qemu-iotests/020
+++ b/tests/qemu-iotests/020
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/021 b/tests/qemu-iotests/021
index 1c69024..66089d7 100755
--- a/tests/qemu-iotests/021
+++ b/tests/qemu-iotests/021
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/022 b/tests/qemu-iotests/022
index d35b816..df6c537 100755
--- a/tests/qemu-iotests/022
+++ b/tests/qemu-iotests/022
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/023 b/tests/qemu-iotests/023
index 9ad06b9..76692ef 100755
--- a/tests/qemu-iotests/023
+++ b/tests/qemu-iotests/023
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
index 9bf99e1..b75dcf2 100755
--- a/tests/qemu-iotests/024
+++ b/tests/qemu-iotests/024
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025
index a5f45b4..528d822 100755
--- a/tests/qemu-iotests/025
+++ b/tests/qemu-iotests/025
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index df2884b..8be5d42 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
index 3fa81b8..5feba32 100755
--- a/tests/qemu-iotests/027
+++ b/tests/qemu-iotests/027
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
index a1f4423..ee1272d 100755
--- a/tests/qemu-iotests/028
+++ b/tests/qemu-iotests/028
@@ -28,7 +28,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
index fa46ace..2de8ec5 100755
--- a/tests/qemu-iotests/029
+++ b/tests/qemu-iotests/029
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031
index 2a77ba8..4ce2be3 100755
--- a/tests/qemu-iotests/031
+++ b/tests/qemu-iotests/031
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
index b1ba5c3..60523b8 100755
--- a/tests/qemu-iotests/032
+++ b/tests/qemu-iotests/032
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
index ea3351c..00ee111 100755
--- a/tests/qemu-iotests/033
+++ b/tests/qemu-iotests/033
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
index 69c7858..539d0c7 100755
--- a/tests/qemu-iotests/034
+++ b/tests/qemu-iotests/034
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/035 b/tests/qemu-iotests/035
index ebe9b8c..6778c70 100755
--- a/tests/qemu-iotests/035
+++ b/tests/qemu-iotests/035
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036
index 392f1ef..65c6b66 100755
--- a/tests/qemu-iotests/036
+++ b/tests/qemu-iotests/036
@@ -28,7 +28,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
index 9171d8c..aa5f8f3 100755
--- a/tests/qemu-iotests/037
+++ b/tests/qemu-iotests/037
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/038 b/tests/qemu-iotests/038
index cfaf00a..817ea4e 100755
--- a/tests/qemu-iotests/038
+++ b/tests/qemu-iotests/038
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index 84c9167..d34968b 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -28,7 +28,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/042 b/tests/qemu-iotests/042
index 94ce3a9..674e529 100755
--- a/tests/qemu-iotests/042
+++ b/tests/qemu-iotests/042
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043
index b316b97..dcceaf6 100755
--- a/tests/qemu-iotests/043
+++ b/tests/qemu-iotests/043
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046
index e0be46c..740ed48 100755
--- a/tests/qemu-iotests/046
+++ b/tests/qemu-iotests/046
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/047 b/tests/qemu-iotests/047
index c35cd09..6bc0b78 100755
--- a/tests/qemu-iotests/047
+++ b/tests/qemu-iotests/047
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049
index 93aa0ea..e8880a9 100755
--- a/tests/qemu-iotests/049
+++ b/tests/qemu-iotests/049
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050
index 07802bc..5ed97cf 100755
--- a/tests/qemu-iotests/050
+++ b/tests/qemu-iotests/050
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
index a41334e..3d67f90 100755
--- a/tests/qemu-iotests/051
+++ b/tests/qemu-iotests/051
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
index 6bdae92..b849f1b 100755
--- a/tests/qemu-iotests/052
+++ b/tests/qemu-iotests/052
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053
index e589e5f..9fb1e93 100755
--- a/tests/qemu-iotests/053
+++ b/tests/qemu-iotests/053
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/054 b/tests/qemu-iotests/054
index bd94153..316b8a2 100755
--- a/tests/qemu-iotests/054
+++ b/tests/qemu-iotests/054
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058
index 14584cd..5602bff 100755
--- a/tests/qemu-iotests/058
+++ b/tests/qemu-iotests/058
@@ -27,7 +27,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 nbd_unix_socket=$TEST_DIR/test_qemu_nbd_socket
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
index 3c053c2..82d94d3 100755
--- a/tests/qemu-iotests/059
+++ b/tests/qemu-iotests/059
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
index 830386f..b79578f 100755
--- a/tests/qemu-iotests/060
+++ b/tests/qemu-iotests/060
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
index ab98def..49c08ef 100755
--- a/tests/qemu-iotests/061
+++ b/tests/qemu-iotests/061
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062
index 0511246..06bcfe5 100755
--- a/tests/qemu-iotests/062
+++ b/tests/qemu-iotests/062
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
index a47493a..43d37d6 100755
--- a/tests/qemu-iotests/063
+++ b/tests/qemu-iotests/063
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/064 b/tests/qemu-iotests/064
index 1c74c31..be791c7 100755
--- a/tests/qemu-iotests/064
+++ b/tests/qemu-iotests/064
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066
index 1c2452b..e079845 100755
--- a/tests/qemu-iotests/066
+++ b/tests/qemu-iotests/066
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
index d025192..d3ac7d7 100755
--- a/tests/qemu-iotests/067
+++ b/tests/qemu-iotests/067
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 # get standard environment, filters and checks
diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068
index b72e555..9fa5ef2 100755
--- a/tests/qemu-iotests/068
+++ b/tests/qemu-iotests/068
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069
index e661598..c41312a 100755
--- a/tests/qemu-iotests/069
+++ b/tests/qemu-iotests/069
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070
index ea0dae7..ef1b28f 100755
--- a/tests/qemu-iotests/070
+++ b/tests/qemu-iotests/070
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
index 3924e51..a6fd2a2 100755
--- a/tests/qemu-iotests/071
+++ b/tests/qemu-iotests/071
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
index 58faa8b..61ad7f4 100755
--- a/tests/qemu-iotests/072
+++ b/tests/qemu-iotests/072
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
index 392db54..d8b61a6 100755
--- a/tests/qemu-iotests/073
+++ b/tests/qemu-iotests/073
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/075 b/tests/qemu-iotests/075
index 40032c5..c835a02 100755
--- a/tests/qemu-iotests/075
+++ b/tests/qemu-iotests/075
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/076 b/tests/qemu-iotests/076
index b614a7d..3950e5a 100755
--- a/tests/qemu-iotests/076
+++ b/tests/qemu-iotests/076
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/077 b/tests/qemu-iotests/077
index 4dd1bdd..d6e5dcb 100755
--- a/tests/qemu-iotests/077
+++ b/tests/qemu-iotests/077
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/078 b/tests/qemu-iotests/078
index d4d6da7..88cc7d4 100755
--- a/tests/qemu-iotests/078
+++ b/tests/qemu-iotests/078
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079
index 2142bbb..df546ed 100755
--- a/tests/qemu-iotests/079
+++ b/tests/qemu-iotests/079
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080
index 6b3a3e7..d470d8a 100755
--- a/tests/qemu-iotests/080
+++ b/tests/qemu-iotests/080
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
index 7ae4be2..5f688a3 100755
--- a/tests/qemu-iotests/081
+++ b/tests/qemu-iotests/081
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082
index f6eb75f..eeab7f7 100755
--- a/tests/qemu-iotests/082
+++ b/tests/qemu-iotests/082
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
index 991a9d9..4d81160 100755
--- a/tests/qemu-iotests/083
+++ b/tests/qemu-iotests/083
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 # get standard environment, filters and checks
diff --git a/tests/qemu-iotests/084 b/tests/qemu-iotests/084
index ae33c2c..bbd06b1 100755
--- a/tests/qemu-iotests/084
+++ b/tests/qemu-iotests/084
@@ -26,7 +26,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/086 b/tests/qemu-iotests/086
index d9a80cf..763fc67 100755
--- a/tests/qemu-iotests/086
+++ b/tests/qemu-iotests/086
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
index 82c56b1..b5e8d7c 100755
--- a/tests/qemu-iotests/087
+++ b/tests/qemu-iotests/087
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 # get standard environment, filters and checks
diff --git a/tests/qemu-iotests/088 b/tests/qemu-iotests/088
index c09adf8..5b05f3e 100755
--- a/tests/qemu-iotests/088
+++ b/tests/qemu-iotests/088
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089
index dffc977..0e2dd91 100755
--- a/tests/qemu-iotests/089
+++ b/tests/qemu-iotests/089
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/090 b/tests/qemu-iotests/090
index 8d032f8..2cffc46 100755
--- a/tests/qemu-iotests/090
+++ b/tests/qemu-iotests/090
@@ -25,7 +25,7 @@ seq="$(basename $0)"
 echo "QA output created by $seq"
 
 here="$PWD"
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/092 b/tests/qemu-iotests/092
index a8c0c9c..7f55083 100755
--- a/tests/qemu-iotests/092
+++ b/tests/qemu-iotests/092
@@ -25,7 +25,7 @@ seq=`basename $0`
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=/tmp/$$
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
 status=1       # failure is the default!
 
 _cleanup()
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 8ca4011..8e1061e 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -19,7 +19,6 @@
 # Control script for QA
 #
 
-tmp=/tmp/$$
 status=0
 needwrap=true
 try=0
@@ -121,6 +120,10 @@ then
     _init_error "failed to source common.rc"
 fi
 
+# Temporary directory to store test results, will be removed by _wrapup
+QEMU_IOTESTS_TMPDIR=$(mktemp -d --tmpdir qemu-iotests.XXXXXXXX)
+tmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$
+
 # we need common
 . "$source_iotests/common"
 
@@ -197,9 +200,8 @@ END        { if (NR > 0) {
         needwrap=false
     fi
 
-    rm -f /tmp/*.out /tmp/*.err /tmp/*.time
     rm -f /tmp/check.pid /tmp/check.sts
-    rm -f $tmp.*
+    rm -rf "$QEMU_IOTESTS_TMPDIR"
 }
 
 trap "_wrapup; exit \$status" 0 1 2 3 15
@@ -349,6 +351,7 @@ do
                 fi
             fi
         fi
+        rm -f "$tmp.out"
 
     fi
 
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 9c49deb..51762c2 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -72,11 +72,12 @@ fi
 
 function valgrind_qemu_io()
 {
-    valgrind --log-file=/tmp/$$.valgrind --error-exitcode=99 $REAL_QEMU_IO "$@"
+    local vgtmp=${QEMU_IOTESTS_TMPDIR:-/tmp}/$$.valgrind
+    valgrind --log-file="$vgtmp" --error-exitcode=99 $REAL_QEMU_IO "$@"
     if [ $? != 0 ]; then
-        cat /tmp/$$.valgrind
+        cat "$vgtmp"
     fi
-    rm -f /tmp/$$.valgrind
+    rm -f "$vgtmp"
 }
 
 
-- 
2.1.0


Reply via email to