tests: Generate a tarball of test results if a test fails

This makes it easier to collect failure data from test servers for
further analysis.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-04-26 13:48:48 +03:00
parent 7800d45c71
commit f59a10d405
2 changed files with 12 additions and 1 deletions

View file

@ -3,8 +3,10 @@
errors=0 errors=0
umask 0002 umask 0002
./start.sh ./start.sh
./run-tests.py || errors=1 DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
./run-tests.py -e logs/$DATE-failed || errors=1
./stop-wifi.sh ./stop-wifi.sh
if [ $errors -gt 0 ]; then if [ $errors -gt 0 ]; then
tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz logs/$DATE*
exit 1 exit 1
fi fi

View file

@ -25,6 +25,7 @@ def reset_devs(dev, apdev):
def main(): def main():
test_file = None test_file = None
error_file = None
idx = 1 idx = 1
if len(sys.argv) > 1 and sys.argv[1] == '-d': if len(sys.argv) > 1 and sys.argv[1] == '-d':
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
@ -35,6 +36,10 @@ def main():
else: else:
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
if len(sys.argv) > idx + 1 and sys.argv[idx] == '-e':
error_file = sys.argv[idx + 1]
idx = idx + 2
if len(sys.argv) > idx + 1 and sys.argv[idx] == '-f': if len(sys.argv) > idx + 1 and sys.argv[idx] == '-f':
test_file = sys.argv[idx + 1] test_file = sys.argv[idx + 1]
idx = idx + 2 idx = idx + 2
@ -107,6 +112,10 @@ def main():
if len(failed): if len(failed):
print "passed " + str(len(passed)) + " test case(s)" print "passed " + str(len(passed)) + " test case(s)"
print "failed tests: " + str(failed) print "failed tests: " + str(failed)
if error_file:
f = open(error_file, 'w')
f.write(str(failed) + '\n')
f.close()
sys.exit(1) sys.exit(1)
print "passed all " + str(len(passed)) + " test case(s)" print "passed all " + str(len(passed)) + " test case(s)"