mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user