tests: Remove the 'test_' prefix from test names

This is unnecessary extra complexity for user and reports, so use the
'test_' prefix only internally within the python scripts.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-10-31 11:43:45 +02:00 committed by Jouni Malinen
parent d05159ccc5
commit 4cd8343f4d
2 changed files with 25 additions and 22 deletions

View file

@ -154,7 +154,7 @@ verbose debug output) and -q (less verbose output) on the command
line. "-f <test_filename(without.py)>" can be used to specify that all line. "-f <test_filename(without.py)>" can be used to specify that all
test cases from a single file are to be run. Test name as the last test cases from a single file are to be run. Test name as the last
command line argument can be specified that a single test case is to be command line argument can be specified that a single test case is to be
run (e.g., "./run-tests.py test_ap_pmf_required"). run (e.g., "./run-tests.py ap_pmf_required").
Adding/modifying test cases Adding/modifying test cases
@ -171,7 +171,8 @@ line is a convenient way of verifying functionality.
run-tests.py will automatically import all test cases from the test_*.py run-tests.py will automatically import all test cases from the test_*.py
files in this directory. All functions starting with the "test_" prefix files in this directory. All functions starting with the "test_" prefix
in these files are assumed to be test cases. in these files are assumed to be test cases. Each test case is named by
the function name following the "test_" prefix.
Results database Results database

View file

@ -40,7 +40,7 @@ def report(conn, build, commit, run, test, result, diff):
if not commit: if not commit:
commit = '' commit = ''
sql = "INSERT INTO results(test,result,run,time,duration,build,commitid) VALUES(?, ?, ?, ?, ?, ?, ?)" sql = "INSERT INTO results(test,result,run,time,duration,build,commitid) VALUES(?, ?, ?, ?, ?, ?, ?)"
params = (test.replace('test_', '', 1), result, run, time.time(), diff.total_seconds(), build, commit) params = (test, result, run, time.time(), diff.total_seconds(), build, commit)
try: try:
conn.execute(sql, params) conn.execute(sql, params)
conn.commit() conn.commit()
@ -86,7 +86,7 @@ def main():
if s.startswith("test_"): if s.startswith("test_"):
func = mod.__dict__.get(s) func = mod.__dict__.get(s)
tests.append(func) tests.append(func)
test_names = list(set([t.__name__ for t in tests])) test_names = list(set([t.__name__.replace('test_', '', 1) for t in tests]))
run = None run = None
print_res = False print_res = False
@ -165,10 +165,11 @@ def main():
if args.update_tests_db: if args.update_tests_db:
for t in tests: for t in tests:
print t.__name__ + " - " + t.__doc__ name = t.__name__.replace('test_', '', 1)
print name + " - " + t.__doc__
if conn: if conn:
sql = 'INSERT OR REPLACE INTO tests(test,description) VALUES (?, ?)' sql = 'INSERT OR REPLACE INTO tests(test,description) VALUES (?, ?)'
params = (t.__name__.replace('test_', '', 1), t.__doc__) params = (name, t.__doc__)
try: try:
conn.execute(sql, params) conn.execute(sql, params)
except Exception, e: except Exception, e:
@ -208,27 +209,28 @@ def main():
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w')) subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
for t in tests: for t in tests:
name = t.__name__.replace('test_', '', 1)
if args.tests: if args.tests:
if not t.__name__ in args.tests: if not name in args.tests:
continue continue
if args.testmodules: if args.testmodules:
if not t.__module__ in args.testmodules: if not t.__module__ in args.testmodules:
continue continue
with DataCollector(args.logdir, t.__name__, args.tracing, args.dmesg): with DataCollector(args.logdir, name, args.tracing, args.dmesg):
logger.info("START " + t.__name__) logger.info("START " + name)
if log_to_file: if log_to_file:
print "START " + t.__name__ print "START " + name
sys.stdout.flush() sys.stdout.flush()
if t.__doc__: if t.__doc__:
logger.info("Test: " + t.__doc__) logger.info("Test: " + t.__doc__)
start = datetime.now() start = datetime.now()
for d in dev: for d in dev:
try: try:
d.request("NOTE TEST-START " + t.__name__) d.request("NOTE TEST-START " + name)
except Exception, e: except Exception, e:
logger.info("Failed to issue TEST-START before " + t.__name__ + " for " + d.ifname) logger.info("Failed to issue TEST-START before " + name + " for " + d.ifname)
logger.info(e) logger.info(e)
print "FAIL " + t.__name__ + " - could not start test" print "FAIL " + name + " - could not start test"
if conn: if conn:
conn.close() conn.close()
conn = None conn = None
@ -241,13 +243,13 @@ def main():
end = datetime.now() end = datetime.now()
diff = end - start diff = end - start
if res == "skip": if res == "skip":
skipped.append(t.__name__) skipped.append(name)
result = "SKIP" result = "SKIP"
else: else:
passed.append(t.__name__) passed.append(name)
result = "PASS" result = "PASS"
report(conn, args.build, args.commit, run, t.__name__, result, diff) report(conn, args.build, args.commit, run, name, result, diff)
result = result + " " + t.__name__ + " " result = result + " " + name + " "
result = result + str(diff.total_seconds()) + " " + str(end) result = result + str(diff.total_seconds()) + " " + str(end)
logger.info(result) logger.info(result)
if log_to_file or print_res: if log_to_file or print_res:
@ -261,9 +263,9 @@ def main():
end = datetime.now() end = datetime.now()
diff = end - start diff = end - start
logger.info(e) logger.info(e)
failed.append(t.__name__) failed.append(name)
report(conn, args.build, args.commit, run, t.__name__, "FAIL", diff) report(conn, args.build, args.commit, run, name, "FAIL", diff)
result = "FAIL " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end) result = "FAIL " + name + " " + str(diff.total_seconds()) + " " + str(end)
logger.info(result) logger.info(result)
if log_to_file: if log_to_file:
print result print result
@ -274,9 +276,9 @@ def main():
f.close() f.close()
for d in dev: for d in dev:
try: try:
d.request("NOTE TEST-STOP " + t.__name__) d.request("NOTE TEST-STOP " + name)
except Exception, e: except Exception, e:
logger.info("Failed to issue TEST-STOP after " + t.__name__ + " for " + d.ifname) logger.info("Failed to issue TEST-STOP after " + name + " for " + d.ifname)
logger.info(e) logger.info(e)
reset_devs(dev, apdev) reset_devs(dev, apdev)