tests: Add mechanism for test cases to indicate a skipped run
This can be used by test cases that depend on some external component that may not always be available to indicate clearly that a test case was skipped rather than passed or failed. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
9b00f24a76
commit
0d84c400f9
1 changed files with 16 additions and 4 deletions
|
@ -103,6 +103,7 @@ def main():
|
|||
logger.info("APDEV: " + ap['ifname'])
|
||||
|
||||
passed = []
|
||||
skipped = []
|
||||
failed = []
|
||||
|
||||
for t in tests:
|
||||
|
@ -124,13 +125,19 @@ def main():
|
|||
logger.info(e)
|
||||
try:
|
||||
if t.func_code.co_argcount > 1:
|
||||
t(dev, apdev)
|
||||
res = t(dev, apdev)
|
||||
else:
|
||||
t(dev)
|
||||
passed.append(t.__name__)
|
||||
res = t(dev)
|
||||
end = datetime.now()
|
||||
diff = end - start
|
||||
result = "PASS " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end)
|
||||
if res == "skip":
|
||||
skipped.append(t.__name__)
|
||||
result = "SKIP "
|
||||
else:
|
||||
passed.append(t.__name__)
|
||||
result = "PASS "
|
||||
result = result + t.__name__ + " "
|
||||
result = result + str(diff.total_seconds()) + " " + str(end)
|
||||
logger.info(result)
|
||||
if log_file or print_res:
|
||||
print result
|
||||
|
@ -163,6 +170,7 @@ def main():
|
|||
|
||||
if len(failed):
|
||||
logger.info("passed " + str(len(passed)) + " test case(s)")
|
||||
logger.info("skipped " + str(len(skipped)) + " test case(s)")
|
||||
logger.info("failed tests: " + str(failed))
|
||||
if error_file:
|
||||
f = open(error_file, 'w')
|
||||
|
@ -170,8 +178,12 @@ def main():
|
|||
f.close()
|
||||
sys.exit(1)
|
||||
logger.info("passed all " + str(len(passed)) + " test case(s)")
|
||||
if len(skipped):
|
||||
logger.info("skipped " + str(len(skipped)) + " test case(s)")
|
||||
if log_file:
|
||||
print "passed all " + str(len(passed)) + " test case(s)"
|
||||
if len(skipped):
|
||||
print "skipped " + str(len(skipped)) + " test case(s)"
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue