mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
tests: Write debug logs into the database for failed test cases
This makes it easier to build a web page for analyzing failures without having to fetch the log files themselves from the test server. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
26b846672c
commit
1d646f5ee1
@ -181,4 +181,7 @@ CREATE TABLE results (test,result,run,time,duration,build,commitid);
|
|||||||
CREATE INDEX results_idx ON results (test);
|
CREATE INDEX results_idx ON results (test);
|
||||||
CREATE INDEX results_idx2 ON results (run);
|
CREATE INDEX results_idx2 ON results (run);
|
||||||
CREATE TABLE tests (test,description);
|
CREATE TABLE tests (test,description);
|
||||||
|
CREATE TABLE logs (test,run,type,contents);
|
||||||
|
CREATE INDEX logs_idx ON logs (test);
|
||||||
|
CREATE INDEX logs_idx2 ON logs (run);
|
||||||
EOF
|
EOF
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# AP tests
|
# AP tests
|
||||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
@ -52,7 +52,24 @@ def reset_devs(dev, apdev):
|
|||||||
ok = False
|
ok = False
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def report(conn, prefill, build, commit, run, test, result, duration):
|
def add_log_file(conn, test, run, type, path):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return
|
||||||
|
contents = None
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
contents = f.read()
|
||||||
|
if contents is None:
|
||||||
|
return
|
||||||
|
sql = "INSERT INTO logs(test,run,type,contents) VALUES(?, ?, ?, ?)"
|
||||||
|
params = (test, run, type, contents)
|
||||||
|
try:
|
||||||
|
conn.execute(sql, params)
|
||||||
|
conn.commit()
|
||||||
|
except Exception, e:
|
||||||
|
print "sqlite: " + str(e)
|
||||||
|
print "sql: %r" % (params, )
|
||||||
|
|
||||||
|
def report(conn, prefill, build, commit, run, test, result, duration, logdir):
|
||||||
if conn:
|
if conn:
|
||||||
if not build:
|
if not build:
|
||||||
build = ''
|
build = ''
|
||||||
@ -69,6 +86,12 @@ def report(conn, prefill, build, commit, run, test, result, duration):
|
|||||||
print "sqlite: " + str(e)
|
print "sqlite: " + str(e)
|
||||||
print "sql: %r" % (params, )
|
print "sql: %r" % (params, )
|
||||||
|
|
||||||
|
if result == "FAIL":
|
||||||
|
for log in [ "log", "log0", "log1", "log2", "log3", "log5",
|
||||||
|
"hostapd", "dmesg", "hwsim0", "hwsim0.pcapng" ]:
|
||||||
|
add_log_file(conn, test, run, log,
|
||||||
|
logdir + "/" + test + "." + log)
|
||||||
|
|
||||||
class DataCollector(object):
|
class DataCollector(object):
|
||||||
def __init__(self, logdir, testname, tracing, dmesg):
|
def __init__(self, logdir, testname, tracing, dmesg):
|
||||||
self._logdir = logdir
|
self._logdir = logdir
|
||||||
@ -197,6 +220,7 @@ def main():
|
|||||||
conn = sqlite3.connect(args.database)
|
conn = sqlite3.connect(args.database)
|
||||||
conn.execute('CREATE TABLE IF NOT EXISTS results (test,result,run,time,duration,build,commitid)')
|
conn.execute('CREATE TABLE IF NOT EXISTS results (test,result,run,time,duration,build,commitid)')
|
||||||
conn.execute('CREATE TABLE IF NOT EXISTS tests (test,description)')
|
conn.execute('CREATE TABLE IF NOT EXISTS tests (test,description)')
|
||||||
|
conn.execute('CREATE TABLE IF NOT EXISTS logs (test,run,type,contents)')
|
||||||
else:
|
else:
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
@ -266,7 +290,8 @@ def main():
|
|||||||
if conn and args.prefill:
|
if conn and args.prefill:
|
||||||
for t in tests_to_run:
|
for t in tests_to_run:
|
||||||
name = t.__name__.replace('test_', '', 1)
|
name = t.__name__.replace('test_', '', 1)
|
||||||
report(conn, False, args.build, args.commit, run, name, 'NOTRUN', 0)
|
report(conn, False, args.build, args.commit, run, name, 'NOTRUN', 0,
|
||||||
|
args.logdir)
|
||||||
|
|
||||||
if args.shuffle_tests:
|
if args.shuffle_tests:
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
@ -368,7 +393,8 @@ def main():
|
|||||||
else:
|
else:
|
||||||
failed.append(name)
|
failed.append(name)
|
||||||
|
|
||||||
report(conn, args.prefill, args.build, args.commit, run, name, result, diff.total_seconds())
|
report(conn, args.prefill, args.build, args.commit, run, name, result,
|
||||||
|
diff.total_seconds(), args.logdir)
|
||||||
result = "{} {} {} {}".format(result, name, diff.total_seconds(), end)
|
result = "{} {} {} {}".format(result, name, diff.total_seconds(), end)
|
||||||
logger.info(result)
|
logger.info(result)
|
||||||
if args.loglevel == logging.WARNING:
|
if args.loglevel == logging.WARNING:
|
||||||
|
Loading…
Reference in New Issue
Block a user