tests: Use unique or temporary names for temporary files.

Review every test(!) to ensure that it:

 - Doesn't use a generic name (eg. "test1.img", "test.out") for any
   temporary file it needs.

 - Does instead use a unique name or a temporary name (eg. a name like
   "name-of-the-test.img", or a scratch disk).

 - Does not use 'rm -f' to clean up its temporary files (so we can
   detect errors if the wrong temporary file is created or removed).

This allows tests to be run in parallel, so they don't stomp on each
other's temporary files.
This commit is contained in:
Richard W.M. Jones
2013-07-19 19:36:49 +01:00
parent ccd069f859
commit 4180abcc1f
64 changed files with 421 additions and 432 deletions

View File

@@ -18,14 +18,14 @@
import os
import guestfs
f = open ("test.img", "w")
f = open ("rhbz811650.img", "w")
f.truncate (500 * 1024 * 1024)
f.close ()
g = guestfs.GuestFS (python_return_dict=True)
# Deliberate error: the disk format is supposed to be raw.
g.add_drive ("test.img", format="qcow2");
g.add_drive ("rhbz811650.img", format="qcow2");
# Because error() wasn't being called, guestfs_last_error would return
# NULL, causing a segfault in the Python bindings (RHBZ#811650).
@@ -34,4 +34,4 @@ try:
except:
pass
os.unlink ("test.img")
os.unlink ("rhbz811650.img")