From nobody Sat Oct 25 19:45:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520627428051140.17255098458884; Fri, 9 Mar 2018 12:30:28 -0800 (PST) Received: from localhost ([::1]:47941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euOep-00014f-4u for importer@patchew.org; Fri, 09 Mar 2018 15:30:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euOd1-0008C7-AY for qemu-devel@nongnu.org; Fri, 09 Mar 2018 15:28:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euOd0-0006m1-96 for qemu-devel@nongnu.org; Fri, 09 Mar 2018 15:28:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1euOd0-0006lo-0h for qemu-devel@nongnu.org; Fri, 09 Mar 2018 15:28:34 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 523AC80C36; Fri, 9 Mar 2018 20:28:33 +0000 (UTC) Received: from localhost (ovpn-116-64.gru2.redhat.com [10.97.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 228607E230; Fri, 9 Mar 2018 20:28:30 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2018 17:28:20 -0300 Message-Id: <20180309202827.12085-2-ehabkost@redhat.com> In-Reply-To: <20180309202827.12085-1-ehabkost@redhat.com> References: <20180309202827.12085-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 09 Mar 2018 20:28:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/8] device-crash-test: Refactor loglevel configuration code 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: Peter Maydell , Thomas Huth , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use action=3D'store_const', dest=3D'loglevel' to represent the effect of each option more clearly. This will also make the last option in the command-line override the previous ones (e.g.: "-d -q"). Signed-off-by: Eduardo Habkost --- scripts/device-crash-test | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 7417177ebb..c6a7875357 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -484,7 +484,7 @@ def casesToTest(args, testcase): if args.random: cases =3D list(cases) cases =3D random.sample(cases, min(args.random, len(cases))) - if args.debug: + if logger.isEnabledFor(logging.DEBUG): cases =3D list(cases) dbg("%d test cases to test", len(cases)) if args.shuffle: @@ -511,11 +511,15 @@ def main(): parser.add_argument('-t', metavar=3D'KEY=3DVALUE', nargs=3D'*', help=3D"Limit test cases to KEY=3DVALUE", action=3D'append', dest=3D'testcases', default=3D[= ]) - parser.add_argument('-d', '--debug', action=3D'store_true', + parser.set_defaults(loglevel=3Dlogging.INFO) + parser.add_argument('-d', '--debug',action=3D'store_const', + dest=3D'loglevel', const=3Dlogging.DEBUG, help=3D'debug output') - parser.add_argument('-v', '--verbose', action=3D'store_true', default= =3DTrue, + parser.add_argument('-v', '--verbose',action=3D'store_const', + dest=3D'loglevel', const=3Dlogging.INFO, help=3D'verbose output') - parser.add_argument('-q', '--quiet', dest=3D'verbose', action=3D'store= _false', + parser.add_argument('-q', '--quiet',action=3D'store_const', + dest=3D'loglevel', const=3Dlogging.WARN, help=3D'non-verbose output') parser.add_argument('-r', '--random', type=3Dint, metavar=3D'COUNT', help=3D'run a random sample of COUNT test cases', @@ -536,13 +540,7 @@ def main(): help=3D'QEMU binary to run') args =3D parser.parse_args() =20 - if args.debug: - lvl =3D logging.DEBUG - elif args.verbose: - lvl =3D logging.INFO - else: - lvl =3D logging.WARN - logging.basicConfig(stream=3Dsys.stdout, level=3Dlvl, format=3D'%(leve= lname)s: %(message)s') + logging.basicConfig(stream=3Dsys.stdout, level=3Dargs.loglevel, format= =3D'%(levelname)s: %(message)s') =20 fatal_failures =3D [] wl_stats =3D {} @@ -599,7 +597,7 @@ def main(): if skipped: logger.info("Skipped %d test cases", skipped) =20 - if args.debug: + if logger.isEnabledFor(logging.DEBUG): stats =3D sorted([(len(wl_stats.get(i, [])), wl) for i, wl in enum= erate(ERROR_WHITELIST)]) for count, wl in stats: dbg("whitelist entry stats: %d: %r", count, wl) --=20 2.14.3