[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 69/69] qemu-iotests: iotests: fail hard if not run vi
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 69/69] qemu-iotests: iotests: fail hard if not run via "check" |
Date: |
Thu, 12 May 2016 16:35:49 +0200 |
From: Sascha Silbe <address@hidden>
Running an iotests-based Python test directly might appear to work,
but may fail in subtle ways and is insecure:
- It creates files with predictable file names in a world-writable
location (/var/tmp).
- Tests expect the environment to be set up by check. E.g. 041 and 055
may take the wrong code paths if QEMU_DEFAULT_MACHINE is not
set. This can lead to false negatives.
Instead fail hard and tell the user we want to be run via "check".
The actual environment expected by the tests is currently only defined
by the implementation of "check". We use two of the environment
variables set by "check" as indication of whether we're being run via
"check". Anyone writing their own test runner (replacing "check") will
need to replicate the full environment (in a broader sense, not just
environment variables) provided by "check" anyway, including setting
the two environment variables we check. Whereas a regular developer
just trying to invoke the tests usually won't have both of these
defined in their environment so we can catch their mistake and give
out useful advice.
Signed-off-by: Sascha Silbe <address@hidden>
Reviewed-by: Bo Tu <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/iotests.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 56f988a..1687c33 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -47,7 +47,7 @@ if os.environ.get('QEMU_OPTIONS'):
imgfmt = os.environ.get('IMGFMT', 'raw')
imgproto = os.environ.get('IMGPROTO', 'file')
-test_dir = os.environ.get('TEST_DIR', '/var/tmp')
+test_dir = os.environ.get('TEST_DIR')
output_dir = os.environ.get('OUTPUT_DIR', '.')
cachemode = os.environ.get('CACHEMODE')
qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
@@ -461,6 +461,14 @@ def verify_quorum():
def main(supported_fmts=[], supported_oses=['linux']):
'''Run tests'''
+ # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
+ # indicate that we're not being run via "check". There may be
+ # other things set up by "check" that individual test cases rely
+ # on.
+ if test_dir is None or qemu_default_machine is None:
+ sys.stderr.write('Please run this test via the "check" script\n')
+ sys.exit(os.EX_USAGE)
+
debug = '-d' in sys.argv
verbosity = 1
verify_image_format(supported_fmts)
--
1.8.3.1
- [Qemu-devel] [PULL 48/69] qcow2: improve qcow2_co_write_zeroes(), (continued)
- [Qemu-devel] [PULL 48/69] qcow2: improve qcow2_co_write_zeroes(), Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 50/69] block: Honor BDRV_REQ_FUA during write_zeroes, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 33/69] ide: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 49/69] block: Make supported_write_flags a per-bds property, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 35/69] virtio: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 38/69] nand: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 40/69] pflash: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 59/69] qmp: add monitor command to add/remove a child, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 36/69] xen_disk: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 42/69] m25p80: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 69/69] qemu-iotests: iotests: fail hard if not run via "check",
Kevin Wolf <=
- [Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 45/69] qemu-img: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 52/69] block: Invalidate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 55/69] iotests: fix the redirection order in 083, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 64/69] qemu-io: Add 'write -f' to test FUA flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 67/69] block: add support for encryption secrets in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 41/69] sd: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 56/69] qemu-img: check block status of backing file when converting., Kevin Wolf, 2016/05/12