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'])
|
logger.info("APDEV: " + ap['ifname'])
|
||||||
|
|
||||||
passed = []
|
passed = []
|
||||||
|
skipped = []
|
||||||
failed = []
|
failed = []
|
||||||
|
|
||||||
for t in tests:
|
for t in tests:
|
||||||
|
@ -124,13 +125,19 @@ def main():
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
try:
|
try:
|
||||||
if t.func_code.co_argcount > 1:
|
if t.func_code.co_argcount > 1:
|
||||||
t(dev, apdev)
|
res = t(dev, apdev)
|
||||||
else:
|
else:
|
||||||
t(dev)
|
res = t(dev)
|
||||||
passed.append(t.__name__)
|
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
diff = end - start
|
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)
|
logger.info(result)
|
||||||
if log_file or print_res:
|
if log_file or print_res:
|
||||||
print result
|
print result
|
||||||
|
@ -163,6 +170,7 @@ def main():
|
||||||
|
|
||||||
if len(failed):
|
if len(failed):
|
||||||
logger.info("passed " + str(len(passed)) + " test case(s)")
|
logger.info("passed " + str(len(passed)) + " test case(s)")
|
||||||
|
logger.info("skipped " + str(len(skipped)) + " test case(s)")
|
||||||
logger.info("failed tests: " + str(failed))
|
logger.info("failed tests: " + str(failed))
|
||||||
if error_file:
|
if error_file:
|
||||||
f = open(error_file, 'w')
|
f = open(error_file, 'w')
|
||||||
|
@ -170,8 +178,12 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
logger.info("passed all " + str(len(passed)) + " test case(s)")
|
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:
|
if log_file:
|
||||||
print "passed all " + str(len(passed)) + " test case(s)"
|
print "passed all " + str(len(passed)) + " test case(s)"
|
||||||
|
if len(skipped):
|
||||||
|
print "skipped " + str(len(skipped)) + " test case(s)"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue