[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 03/17] iotests: ask qemu for supported formats
From: |
Roman Kagan |
Subject: |
[Qemu-block] [PATCH 03/17] iotests: ask qemu for supported formats |
Date: |
Thu, 26 Apr 2018 19:19:44 +0300 |
Add helper functions to query the block drivers actually supported by
QEMU using "-drive format=?". This allows to skip certain tests that
require drivers not built in or whitelisted in QEMU.
Signed-off-by: Roman Kagan <address@hidden>
---
tests/qemu-iotests/common.rc | 19 +++++++++++++++++++
tests/qemu-iotests/iotests.py | 30 +++++++++++++++++++++++++++---
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 9a65a11026..fe5a4d1cfd 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -493,5 +493,24 @@ _require_command()
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
}
+# this test requires support for specific formats
+#
+_require_format()
+{
+ supported_formats=$($QEMU_PROG $QEMU_OPTIONS -drive format=\? 2>&1 | \
+ head -1 | cut -d : -f 2)
+ for f; do
+ found=false
+ for sf in $supported_formats; do
+ if [ "$f" = "$sf" ]; then
+ found=true
+ break
+ fi
+ done
+
+ $found || _notrun "$QEMU_PROG doesn't support format $f"
+ done
+}
+
# make sure this script returns success
true
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index e2abf0cb53..698ef2b2c0 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -119,6 +119,17 @@ def qemu_io(*args):
sys.stderr.write('qemu-io received signal %i: %s\n' %
(-subp.returncode, ' '.join(args)))
return output
+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)
+ output = subp.communicate()[0]
+ if subp.returncode < 0:
+ sys.stderr.write('qemu received signal %i: %s\n' % (-subp.returncode,
' '.join(args)))
+ return output
+
class QemuIoInteractive:
def __init__(self, *args):
@@ -550,13 +561,26 @@ def verify_cache_mode(supported_cache_modes=[]):
if supported_cache_modes and (cachemode not in supported_cache_modes):
notrun('not suitable for this cache mode: %s' % cachemode)
+rw_formats = None
+
+def supports_format(format_name):
+ format_message = qemu_pipe('-drive', 'format=?')
+ global rw_formats
+ if rw_formats is None:
+ rw_formats = format_message.splitlines()[0].split(':')[1].split()
+ return format_name in rw_formats
+
+def require_formats(*formats):
+ for fmt in formats:
+ if not supports_format(fmt):
+ notrun('%s does not support format %s' % (qemu_prog, fmt))
+
def supports_quorum():
- return 'quorum' in qemu_img_pipe('--help')
+ return supports_format('quorum')
def verify_quorum():
'''Skip test suite if quorum support is not available'''
- if not supports_quorum():
- notrun('quorum support missing')
+ require_formats('quorum')
def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
unsupported_fmts=[]):
--
2.14.3
- [Qemu-block] [PATCH 00/17] iotests: don't choke on disabled drivers, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 03/17] iotests: ask qemu for supported formats,
Roman Kagan <=
- [Qemu-block] [PATCH 04/17] iotest 030: skip quorum test setup/teardown too, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 05/17] iotest 030: require blkdebug, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 02/17] iotests: iotests.py: prevent deadlock in subprocess, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 01/17] block: iterate_format with account of whitelisting, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 11/17] iotest 087: notrun if null-co is disabled, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 12/17] iotest 093: notrun if null-co or null-aio is disabled, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 14/17] iotest 124: skip testcases using blkdebug if disabled, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 09/17] iotest 071: notrun if blkdebug or blkverify is disabled, Roman Kagan, 2018/04/26
- [Qemu-block] [PATCH 08/17] iotest 056: skip testcases using blkdebug if disabled, Roman Kagan, 2018/04/26