From patchwork Wed Oct 30 21:51:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 287352 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7E90E2C03B2 for ; Thu, 31 Oct 2013 08:52:03 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4F1159C178; Wed, 30 Oct 2013 17:52:01 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yQnbgKfTtAru; Wed, 30 Oct 2013 17:52:01 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1BAFE9C169; Wed, 30 Oct 2013 17:51:57 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CDE969C169 for ; Wed, 30 Oct 2013 17:51:55 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IvQZtbs-OT6F for ; Wed, 30 Oct 2013 17:51:51 -0400 (EDT) Received: from sipsolutions.net (s3.sipsolutions.net [144.76.43.152]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id B3C2A9C161 for ; Wed, 30 Oct 2013 17:51:51 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Vbdg6-00026L-Fr; Wed, 30 Oct 2013 22:51:50 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH] hwsim tests: allow collecting dmesg Date: Wed, 30 Oct 2013 22:51:47 +0100 Message-Id: <1383169907-24387-1-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 1.8.4.rc3 Cc: Johannes Berg X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg In addition to tracing, allow collecting dmesg. There's no provision for actually looking at it and finding problems in it yet though. Signed-hostap: Johannes Berg --- tests/hwsim/run-all.sh | 2 +- tests/hwsim/run-tests.py | 51 ++++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh index fc659ba..48f1424 100755 --- a/tests/hwsim/run-all.sh +++ b/tests/hwsim/run-all.sh @@ -66,7 +66,7 @@ fi if ! [ -z "$LOGBASEDIR" ] ; then rm $LOGBASEDIR/last-debug 2>/dev/null fi -./run-tests.py --logdir "$LOGDIR" $TRACE_ARGS -l run $DB -e failed -r results.txt $CONCURRENT_TESTS $@ || errors=1 +./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -l run $DB -e failed -r results.txt $CONCURRENT_TESTS $@ || errors=1 if ! [ -z "$LOGBASEDIR" ] ; then cat $LOGDIR/run >> $LOGBASEDIR/last-debug diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 24d30e4..080d151 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -48,27 +48,31 @@ def report(conn, build, commit, run, test, result, diff): print "sqlite: " + str(e) print "sql: %r" % (params, ) -class Tracer(object): - def __init__(self, tracedir, testname): - self._tracedir = tracedir +class DataCollector(object): + def __init__(self, logdir, testname, tracing, dmesg): + self._logdir = logdir self._testname = testname + self._tracing = tracing + self._dmesg = dmesg def __enter__(self): - if not self._tracedir: - return - output = os.path.join(self._tracedir, '%s.dat' % (self._testname, )) - self._trace_cmd = subprocess.Popen(['sudo', 'trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', 'sh', '-c', 'echo STARTED ; read l'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w'), - cwd=self._tracedir) - l = self._trace_cmd.stdout.read(7) - while not 'STARTED' in l: - l += self._trace_cmd.stdout.read(1) + if self._tracing: + output = os.path.join(self._logdir, '%s.dat' % (self._testname, )) + self._trace_cmd = subprocess.Popen(['sudo', 'trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', 'sh', '-c', 'echo STARTED ; read l'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w'), + cwd=self._logdir) + l = self._trace_cmd.stdout.read(7) + while not 'STARTED' in l: + l += self._trace_cmd.stdout.read(1) def __exit__(self, type, value, traceback): - if not self._tracedir: - return - self._trace_cmd.stdin.write('DONE\n') - self._trace_cmd.wait() + if self._tracing: + self._trace_cmd.stdin.write('DONE\n') + self._trace_cmd.wait() + if self._dmesg: + output = os.path.join(self._logdir, '%s.dmesg' % (self._testname, )) + p = subprocess.Popen(['sudo', 'dmesg', '-c'], stdout=open(output, 'w')) + p.wait() def main(): tests = [] @@ -117,6 +121,8 @@ def main(): help='List tests (and update descriptions in DB)') parser.add_argument('-T', action='store_true', dest='tracing', help='collect tracing per test case (in log directory)') + parser.add_argument('-D', action='store_true', dest='dmesg', + help='collect dmesg per test case (in log directory)') parser.add_argument('-f', dest='testmodules', metavar='', help='execute only tests from these test modules', type=str, choices=[[]] + test_modules, nargs='+') @@ -149,10 +155,6 @@ def main(): error_file = args.errorfile and os.path.join(args.logdir, args.errorfile) results_file = args.resultsfile and os.path.join(args.logdir, args.resultsfile) - tracedir = None - if args.tracing: - tracedir = args.logdir - if args.database: import sqlite3 conn = sqlite3.connect(args.database) @@ -199,6 +201,9 @@ def main(): skipped = [] failed = [] + if args.dmesg: + subprocess.call(['dmesg', '-c'], stdout=open('/dev/null', 'w')) + for t in tests: if args.tests: if not t.__name__ in args.tests: @@ -206,7 +211,7 @@ def main(): if args.testmodules: if not t.__module__ in args.testmodules: continue - with Tracer(tracedir, t.__name__): + with DataCollector(args.logdir, t.__name__, args.tracing, args.dmesg): reset_devs(dev, apdev) logger.info("START " + t.__name__) if log_to_file: