From patchwork Fri May 22 15:26:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 475673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E57F41402A5 for ; Sat, 23 May 2015 01:35:29 +1000 (AEST) Received: from localhost ([::1]:34636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvoyt-0002O0-Rw for incoming@patchwork.ozlabs.org; Fri, 22 May 2015 11:35:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvor1-00055w-3j for qemu-devel@nongnu.org; Fri, 22 May 2015 11:27:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yvoqx-00072M-DR for qemu-devel@nongnu.org; Fri, 22 May 2015 11:27:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvoqm-0006ny-6O; Fri, 22 May 2015 11:27:04 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DB0FCBAEF5; Fri, 22 May 2015 15:27:03 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4MFQf9g016774; Fri, 22 May 2015 11:27:02 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 22 May 2015 17:26:33 +0200 Message-Id: <1432308400-13958-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1432308400-13958-1-git-send-email-kwolf@redhat.com> References: <1432308400-13958-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 15/22] qemu-iotests: Make debugging python tests easier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Fam Zheng Adding "-d" option. The output goes to "tee" so it appears in your console. Also, raise the verbosity of unnitest runner. When testing a topic branch, it's possible that a bug introduced by a code change makes the python test case hang, with debug output, it is much easier to locate the problem. This can also be helpful if you want to watch the progress of a python test, it offers you a way to sense the speed of each test case method you're writing. Note: because there is no easy way to get *both* the verbose output and the output expected by ./check comparison, the case would always fail with an "output mismatch". The sole purpose of using this option is giving developers a quick way to debug when things go wrong. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/qemu-iotests/check | 12 +++++++++--- tests/qemu-iotests/common | 6 ++++++ tests/qemu-iotests/iotests.py | 14 +++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index baeae80..1fa6319 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -296,9 +296,15 @@ do run_command="./$seq" fi export OUTPUT_DIR=$PWD - (cd "$source_iotests"; - MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - $run_command >$tmp.out 2>&1) + if $debug; then + (cd "$source_iotests"; + MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ + $run_command -d 2>&1 | tee $tmp.out) + else + (cd "$source_iotests"; + MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ + $run_command >$tmp.out 2>&1) + fi sts=$? $timestamp && _timestamp stop=`_wallclock` diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common index 1e556bb..1030aaf 100644 --- a/tests/qemu-iotests/common +++ b/tests/qemu-iotests/common @@ -32,6 +32,7 @@ check=${check-true} diff="diff -u" verbose=false +debug=false group=false xgroup=false imgopts=false @@ -132,6 +133,7 @@ s/ .*//p common options -v verbose + -d debug check options -raw test raw (default) @@ -322,6 +324,10 @@ testlist options verbose=true xpand=false ;; + -d) + debug=true + xpand=false + ;; -x) # -x group ... exclude from group file xgroup=true xpand=false diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index e93e623..04a294d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -338,6 +338,8 @@ def notrun(reason): def main(supported_fmts=[], supported_oses=['linux']): '''Run tests''' + debug = '-d' in sys.argv + verbosity = 1 if supported_fmts and (imgfmt not in supported_fmts): notrun('not suitable for this image format: %s' % imgfmt) @@ -347,14 +349,20 @@ def main(supported_fmts=[], supported_oses=['linux']): # We need to filter out the time taken from the output so that qemu-iotest # can reliably diff the results against master output. import StringIO - output = StringIO.StringIO() + if debug: + output = sys.stdout + verbosity = 2 + sys.argv.remove('-d') + else: + output = StringIO.StringIO() class MyTestRunner(unittest.TextTestRunner): - def __init__(self, stream=output, descriptions=True, verbosity=1): + def __init__(self, stream=output, descriptions=True, verbosity=verbosity): unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity) # unittest.main() will use sys.exit() so expect a SystemExit exception try: unittest.main(testRunner=MyTestRunner) finally: - sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue())) + if not debug: + sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue()))