From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Cleber Rosa <crosa@redhat.com>
Subject: [Qemu-devel] [PATCH 1/8] device-crash-test: Refactor loglevel configuration code
Date: Fri, 9 Mar 2018 17:28:20 -0300 [thread overview]
Message-ID: <20180309202827.12085-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20180309202827.12085-1-ehabkost@redhat.com>
Use action='store_const', dest='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 <ehabkost@redhat.com>
---
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 = list(cases)
cases = random.sample(cases, min(args.random, len(cases)))
- if args.debug:
+ if logger.isEnabledFor(logging.DEBUG):
cases = list(cases)
dbg("%d test cases to test", len(cases))
if args.shuffle:
@@ -511,11 +511,15 @@ def main():
parser.add_argument('-t', metavar='KEY=VALUE', nargs='*',
help="Limit test cases to KEY=VALUE",
action='append', dest='testcases', default=[])
- parser.add_argument('-d', '--debug', action='store_true',
+ parser.set_defaults(loglevel=logging.INFO)
+ parser.add_argument('-d', '--debug',action='store_const',
+ dest='loglevel', const=logging.DEBUG,
help='debug output')
- parser.add_argument('-v', '--verbose', action='store_true', default=True,
+ parser.add_argument('-v', '--verbose',action='store_const',
+ dest='loglevel', const=logging.INFO,
help='verbose output')
- parser.add_argument('-q', '--quiet', dest='verbose', action='store_false',
+ parser.add_argument('-q', '--quiet',action='store_const',
+ dest='loglevel', const=logging.WARN,
help='non-verbose output')
parser.add_argument('-r', '--random', type=int, metavar='COUNT',
help='run a random sample of COUNT test cases',
@@ -536,13 +540,7 @@ def main():
help='QEMU binary to run')
args = parser.parse_args()
- if args.debug:
- lvl = logging.DEBUG
- elif args.verbose:
- lvl = logging.INFO
- else:
- lvl = logging.WARN
- logging.basicConfig(stream=sys.stdout, level=lvl, format='%(levelname)s: %(message)s')
+ logging.basicConfig(stream=sys.stdout, level=args.loglevel, format='%(levelname)s: %(message)s')
fatal_failures = []
wl_stats = {}
@@ -599,7 +597,7 @@ def main():
if skipped:
logger.info("Skipped %d test cases", skipped)
- if args.debug:
+ if logger.isEnabledFor(logging.DEBUG):
stats = sorted([(len(wl_stats.get(i, [])), wl) for i, wl in enumerate(ERROR_WHITELIST)])
for count, wl in stats:
dbg("whitelist entry stats: %d: %r", count, wl)
--
2.14.3
next prev parent reply other threads:[~2018-03-09 20:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 20:28 [Qemu-devel] [PATCH 0/8] tests: Run device-crash-test on "make check" Eduardo Habkost
2018-03-09 20:28 ` Eduardo Habkost [this message]
2018-03-09 20:28 ` [Qemu-devel] [PATCH 2/8] device-crash-test: Add examples to script documentation Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 3/8] device-crash-test: Accept machine=DEFAULT to test the default machine Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 4/8] device-crash-test: New known crashes Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 5/8] device-crash-test: Remove runnable-machine check Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 6/8] device-crash-test: Use WARN for known crashes Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 7/8] device-crash-test: Don't print warnings in quiet mode Eduardo Habkost
2018-03-09 20:28 ` [Qemu-devel] [PATCH 8/8] tests: Run device-crash-test on "make check" Eduardo Habkost
2018-03-12 18:23 ` Eduardo Habkost
2018-03-12 18:25 ` [Qemu-devel] [PATCH v2 8/8] tests: Add check-device-crash-* rules Eduardo Habkost
2018-03-09 20:48 ` [Qemu-devel] [PATCH 0/8] tests: Run device-crash-test on "make check" no-reply
2018-03-09 20:55 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180309202827.12085-2-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=crosa@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).