hwsim tests: Allow collecting dmesg
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 <johannes.berg@intel.com>
This commit is contained in:
parent
0141fa5244
commit
0d5a54048b
2 changed files with 28 additions and 24 deletions
|
@ -66,7 +66,7 @@ fi
|
||||||
if ! [ -z "$LOGBASEDIR" ] ; then
|
if ! [ -z "$LOGBASEDIR" ] ; then
|
||||||
rm $LOGBASEDIR/last-debug 2>/dev/null
|
rm $LOGBASEDIR/last-debug 2>/dev/null
|
||||||
fi
|
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
|
if ! [ -z "$LOGBASEDIR" ] ; then
|
||||||
cat $LOGDIR/run >> $LOGBASEDIR/last-debug
|
cat $LOGDIR/run >> $LOGBASEDIR/last-debug
|
||||||
|
|
|
@ -48,27 +48,30 @@ def report(conn, build, commit, run, test, result, diff):
|
||||||
print "sqlite: " + str(e)
|
print "sqlite: " + str(e)
|
||||||
print "sql: %r" % (params, )
|
print "sql: %r" % (params, )
|
||||||
|
|
||||||
class Tracer(object):
|
class DataCollector(object):
|
||||||
def __init__(self, tracedir, testname):
|
def __init__(self, logdir, testname, tracing, dmesg):
|
||||||
self._tracedir = tracedir
|
self._logdir = logdir
|
||||||
self._testname = testname
|
self._testname = testname
|
||||||
|
self._tracing = tracing
|
||||||
|
self._dmesg = dmesg
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
if not self._tracedir:
|
if self._tracing:
|
||||||
return
|
output = os.path.join(self._logdir, '%s.dat' % (self._testname, ))
|
||||||
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'],
|
||||||
self._trace_cmd = subprocess.Popen(['sudo', 'trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', 'sh', '-c', 'echo STARTED ; read l'],
|
stdin=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stderr=open('/dev/null', 'w'),
|
||||||
stderr=open('/dev/null', 'w'),
|
cwd=self._logdir)
|
||||||
cwd=self._tracedir)
|
l = self._trace_cmd.stdout.read(7)
|
||||||
l = self._trace_cmd.stdout.read(7)
|
while not 'STARTED' in l:
|
||||||
while not 'STARTED' in l:
|
l += self._trace_cmd.stdout.read(1)
|
||||||
l += self._trace_cmd.stdout.read(1)
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, type, value, traceback):
|
||||||
if not self._tracedir:
|
if self._tracing:
|
||||||
return
|
self._trace_cmd.stdin.write('DONE\n')
|
||||||
self._trace_cmd.stdin.write('DONE\n')
|
self._trace_cmd.wait()
|
||||||
self._trace_cmd.wait()
|
if self._dmesg:
|
||||||
|
output = os.path.join(self._logdir, '%s.dmesg' % (self._testname, ))
|
||||||
|
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open(output, 'w'))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
tests = []
|
tests = []
|
||||||
|
@ -117,6 +120,8 @@ def main():
|
||||||
help='List tests (and update descriptions in DB)')
|
help='List tests (and update descriptions in DB)')
|
||||||
parser.add_argument('-T', action='store_true', dest='tracing',
|
parser.add_argument('-T', action='store_true', dest='tracing',
|
||||||
help='collect tracing per test case (in log directory)')
|
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='<test module>',
|
parser.add_argument('-f', dest='testmodules', metavar='<test module>',
|
||||||
help='execute only tests from these test modules',
|
help='execute only tests from these test modules',
|
||||||
type=str, choices=[[]] + test_modules, nargs='+')
|
type=str, choices=[[]] + test_modules, nargs='+')
|
||||||
|
@ -149,10 +154,6 @@ def main():
|
||||||
error_file = args.errorfile and os.path.join(args.logdir, args.errorfile)
|
error_file = args.errorfile and os.path.join(args.logdir, args.errorfile)
|
||||||
results_file = args.resultsfile and os.path.join(args.logdir, args.resultsfile)
|
results_file = args.resultsfile and os.path.join(args.logdir, args.resultsfile)
|
||||||
|
|
||||||
tracedir = None
|
|
||||||
if args.tracing:
|
|
||||||
tracedir = args.logdir
|
|
||||||
|
|
||||||
if args.database:
|
if args.database:
|
||||||
import sqlite3
|
import sqlite3
|
||||||
conn = sqlite3.connect(args.database)
|
conn = sqlite3.connect(args.database)
|
||||||
|
@ -199,6 +200,9 @@ def main():
|
||||||
skipped = []
|
skipped = []
|
||||||
failed = []
|
failed = []
|
||||||
|
|
||||||
|
if args.dmesg:
|
||||||
|
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
|
||||||
|
|
||||||
for t in tests:
|
for t in tests:
|
||||||
if args.tests:
|
if args.tests:
|
||||||
if not t.__name__ in args.tests:
|
if not t.__name__ in args.tests:
|
||||||
|
@ -206,7 +210,7 @@ def main():
|
||||||
if args.testmodules:
|
if args.testmodules:
|
||||||
if not t.__module__ in args.testmodules:
|
if not t.__module__ in args.testmodules:
|
||||||
continue
|
continue
|
||||||
with Tracer(tracedir, t.__name__):
|
with DataCollector(args.logdir, t.__name__, args.tracing, args.dmesg):
|
||||||
reset_devs(dev, apdev)
|
reset_devs(dev, apdev)
|
||||||
logger.info("START " + t.__name__)
|
logger.info("START " + t.__name__)
|
||||||
if log_to_file:
|
if log_to_file:
|
||||||
|
|
Loading…
Reference in a new issue