From nobody Sun Nov 9 19:12:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551694258549260.07192892321495; Mon, 4 Mar 2019 02:10:58 -0800 (PST) Received: from localhost ([127.0.0.1]:51241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0kYe-0007CK-3k for importer@patchew.org; Mon, 04 Mar 2019 05:10:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0kWk-0005m2-DL for qemu-devel@nongnu.org; Mon, 04 Mar 2019 05:08:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0kWg-0005pP-Ml for qemu-devel@nongnu.org; Mon, 04 Mar 2019 05:08:54 -0500 Received: from relay.sw.ru ([185.231.240.75]:41438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0kWe-0005fN-K3; Mon, 04 Mar 2019 05:08:48 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h0kWX-0006jh-BB; Mon, 04 Mar 2019 13:08:41 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 4 Mar 2019 13:08:39 +0300 Message-Id: <1551694120-768127-3-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551694120-768127-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1551694120-768127-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 2/3] iotests: ask QEMU for supported formats X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, rkagan@virtuozzo.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3Dhelp'. 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 Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Shinkevich --- tests/qemu-iotests/check | 16 +++++++++++++- tests/qemu-iotests/iotests.py | 50 +++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 895e1e3..b9d539c 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -25,6 +25,7 @@ try=3D0 n_bad=3D0 bad=3D"" notrun=3D"" +casenotrun=3D"" interrupt=3Dtrue =20 # 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 !=3D 0 ] then echo "Failures:$bad" @@ -743,6 +749,10 @@ do printf " " # prettier output with timestamps. fi rm -f core $seq.notrun + if [ -f $seq.casenotrun ] + then + rm -f $seq.casenotrun + fi =20 start=3D$(_wallclock) $timestamp && printf %s " [$(date "+%T")]" @@ -823,7 +833,11 @@ do fi fi fi - + if [ -f $seq.casenotrun ] + then + cat $seq.casenotrun + casenotrun=3D"$casenotrun $seq" + fi fi =20 # 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 b461f53..8fe1620 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -728,6 +728,56 @@ def verify_quorum(): if not supports_quorum(): notrun('quorum support missing') =20 +def qemu_pipe(*args): + '''Run qemu with an option to print something and exit (e.g. a help op= tion), + and return its output''' + args =3D [qemu_prog] + qemu_opts + list(args) + subp =3D subprocess.Popen(args, stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT) + exitcode =3D 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=3DFalse): + '''Set 'read_only' to True to check ro-whitelist + Otherwise, rw-whitelist is checked''' + format_message =3D qemu_pipe("-drive", "format=3Dhelp") + available =3D [] + + if read_only: + # Check read-only whitelist + available =3D format_message.splitlines()[1].split(":")[1].split() + else: + # Check read-write whitelist + available =3D format_message.splitlines()[0].split(":")[1].split() + + return available + +def case_notrun(reason): + '''Skip this test case''' + # Each test in qemu-iotests has a number ("seq") + seq =3D os.path.basename(sys.argv[0]) + + open('%s/%s.casenotrun' % (output_dir, seq), 'ab').write( + ' [case not run] ' + reason + '\n') + +def skip_if_unsupported(required_formats=3D[], read_only=3DFalse): + '''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 =3D 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=3D[], supported_oses=3D['linux'], supported_cache_= modes=3D[], unsupported_fmts=3D[]): '''Run tests''' --=20 1.8.3.1