[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 05/33] iotests: ask QEMU for supported formats
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 05/33] iotests: ask QEMU for supported formats |
Date: |
Fri, 8 Mar 2019 13:57:55 +0100 |
From: Andrey Shinkevich <address@hidden>
Supported formats listed by 'qemu' may differ from those listed by
'qemu-img' due to whitelists. Some test cases require specific formats
that may be used with qemu. They can be inquired directly by running
'qemu -drive format=help'. The response takes whitelists into account.
The method supported_formats() serves for that. The method decorator
skip_if_unsupported() checks if all requested formats are whitelisted.
If not, the test case will be skipped. That has been implemented in
the 'check' file in the way similar to the 'test notrun' mechanism.
Suggested-by: Roman Kagan <address@hidden>
Suggested-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Suggested-by: Kevin Wolf <address@hidden>
Signed-off-by: Andrey Shinkevich <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/check | 13 ++++++++++-
tests/qemu-iotests/iotests.py | 43 +++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 895e1e3dcb..1016887438 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -25,6 +25,7 @@ try=0
n_bad=0
bad=""
notrun=""
+casenotrun=""
interrupt=true
# by default don't output timestamps
@@ -664,6 +665,11 @@ END { if (NR > 0) {
echo "Not run:$notrun"
echo "Not run:$notrun" >>check.log
fi
+ if [ ! -z "$casenotrun" ]
+ then
+ echo "Some cases not run in:$casenotrun"
+ echo "Some cases not run in:$casenotrun" >>check.log
+ fi
if [ ! -z "$n_bad" -a $n_bad != 0 ]
then
echo "Failures:$bad"
@@ -743,6 +749,7 @@ do
printf " " # prettier output with timestamps.
fi
rm -f core $seq.notrun
+ rm -f $seq.casenotrun
start=$(_wallclock)
$timestamp && printf %s " [$(date "+%T")]"
@@ -823,7 +830,11 @@ do
fi
fi
fi
-
+ if [ -f $seq.casenotrun ]
+ then
+ cat $seq.casenotrun
+ casenotrun="$casenotrun $seq"
+ fi
fi
# come here for each test, except when $showme is true
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 46fad4ce81..997dc910cb 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -716,6 +716,14 @@ def notrun(reason):
print('%s not run: %s' % (seq, reason))
sys.exit(0)
+def case_notrun(reason):
+ '''Skip this test case'''
+ # Each test in qemu-iotests has a number ("seq")
+ seq = os.path.basename(sys.argv[0])
+
+ open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
+ ' [case not run] ' + reason + '\n')
+
def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
assert not (supported_fmts and unsupported_fmts)
@@ -756,6 +764,41 @@ def verify_quorum():
if not supports_quorum():
notrun('quorum support missing')
+def qemu_pipe(*args):
+ '''Run qemu with an option to print something and exit (e.g. a help
option),
+ and return its output'''
+ args = [qemu_prog] + qemu_opts + list(args)
+ subp = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
+ exitcode = subp.wait()
+ if exitcode < 0:
+ sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode,
+ ' '.join(args)))
+ return subp.communicate()[0]
+
+def supported_formats(read_only=False):
+ '''Set 'read_only' to True to check ro-whitelist
+ Otherwise, rw-whitelist is checked'''
+ format_message = qemu_pipe("-drive", "format=help")
+ line = 1 if read_only else 0
+ return format_message.splitlines()[line].split(":")[1].split()
+
+def skip_if_unsupported(required_formats=[], read_only=False):
+ '''Skip Test Decorator
+ Runs the test if all the required formats are whitelisted'''
+ def skip_test_decorator(func):
+ def func_wrapper(*args, **kwargs):
+ usf_list = list(set(required_formats) -
+ set(supported_formats(read_only)))
+ if usf_list:
+ case_notrun('{}: formats {} are not whitelisted'.format(
+ args[0], usf_list))
+ else:
+ return func(*args, **kwargs)
+ return func_wrapper
+ return skip_test_decorator
+
def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
unsupported_fmts=[]):
'''Run tests'''
--
2.20.1
- [Qemu-block] [PULL 00/33] Block layer patches, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 01/33] iotests: use iotests.VM in 238, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 02/33] qcow2: Default to 4KB for the qcow2 cache entry size, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 03/33] iotests: open notrun files in text mode, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 05/33] iotests: ask QEMU for supported formats,
Kevin Wolf <=
- [Qemu-block] [PULL 04/33] block: iterate_format with account of whitelisting, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 07/33] tests/multiboot: Improve portability by searching bash in the $PATH, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 06/33] iotests: check whitelisted formats, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 13/33] qcow2: Extend spec for external data files, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 08/33] tests/bios-tables: Improve portability by searching bash in the $PATH, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 11/33] qemu-iotests: Test qcow2 preallocation modes, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 10/33] qemu-iotests: Ensure GNU sed is used, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 12/33] qcow2: Simplify preallocation code, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 09/33] qemu-iotests: Improve portability by searching bash in the $PATH, Kevin Wolf, 2019/03/08
- [Qemu-block] [PULL 14/33] qcow2: Basic definitions for external data files, Kevin Wolf, 2019/03/08