tests: Write test case result summary into a file

This can be used to build statistics from test execution without having
to go through number of log files.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-09-28 18:31:00 +03:00
parent 1fc114a16a
commit 3b7475d365
2 changed files with 24 additions and 9 deletions

View file

@ -11,7 +11,7 @@ if [ "x$1" = "xconcurrent-valgrind" ]; then
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
rm logs/last-debug rm logs/last-debug
for i in autogo discovery grpform; do for i in autogo discovery grpform; do
./run-tests.py -l logs/$DATE-run-$i -e logs/$DATE-failed-$i -f test_p2p_$i.py || errors=1 ./run-tests.py -l logs/$DATE-run-$i -e logs/$DATE-failed-$i -r logs/results.txt -f test_p2p_$i.py || errors=1
cat logs/$DATE-run-$i >> logs/last-debug cat logs/$DATE-run-$i >> logs/last-debug
done done
./stop-wifi.sh ./stop-wifi.sh
@ -32,7 +32,7 @@ elif [ "x$1" = "xconcurrent" ]; then
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
rm logs/last-debug rm logs/last-debug
for i in autogo discovery grpform; do for i in autogo discovery grpform; do
./run-tests.py -l logs/$DATE-run-$i -e logs/$DATE-failed-$i -f test_p2p_$i.py || errors=1 ./run-tests.py -l logs/$DATE-run-$i -e logs/$DATE-failed-$i -r logs/results.txt -f test_p2p_$i.py || errors=1
cat logs/$DATE-run-$i >> logs/last-debug cat logs/$DATE-run-$i >> logs/last-debug
done done
./stop-wifi.sh ./stop-wifi.sh
@ -46,7 +46,7 @@ elif [ "x$1" = "xvalgrind" ]; then
exit 1 exit 1
fi fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1 ./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed -r logs/results.txt || errors=1
cat logs/$DATE-run > logs/last-debug cat logs/$DATE-run > logs/last-debug
./stop-wifi.sh ./stop-wifi.sh
failures=`grep "ERROR SUMMARY" logs/$DATE-valgrind-* | grep -v " 0 errors" | wc -l` failures=`grep "ERROR SUMMARY" logs/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
@ -64,7 +64,7 @@ elif [ "x$1" = "xtrace" ]; then
exit 1 exit 1
fi fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
sudo trace-cmd record -o logs/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c "./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed" || errors=1 sudo trace-cmd record -o logs/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c "./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed -r logs/results.txt" || errors=1
if [ -e logs/$DATE-failed ]; then if [ -e logs/$DATE-failed ]; then
error=1 error=1
fi fi
@ -81,7 +81,7 @@ else
exit 1 exit 1
fi fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1 ./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed -r logs/results.txt || errors=1
cat logs/$DATE-run > logs/last-debug cat logs/$DATE-run > logs/last-debug
./stop-wifi.sh ./stop-wifi.sh
if [ $errors -gt 0 ]; then if [ $errors -gt 0 ]; then

View file

@ -33,6 +33,7 @@ def main():
test_file = None test_file = None
error_file = None error_file = None
log_file = None log_file = None
results_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)
@ -51,6 +52,10 @@ def main():
error_file = sys.argv[idx + 1] error_file = sys.argv[idx + 1]
idx = idx + 2 idx = idx + 2
if len(sys.argv) > idx + 1 and sys.argv[idx] == '-r':
results_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
@ -117,17 +122,27 @@ def main():
passed.append(t.__name__) passed.append(t.__name__)
end = datetime.now() end = datetime.now()
diff = end - start diff = end - start
logger.info("PASS " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end)) result = "PASS " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end)
logger.info(result)
if log_file: if log_file:
print "PASS " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end) print result
if results_file:
f = open(results_file, 'a')
f.write(result + "\n")
f.close()
except Exception, e: except Exception, e:
end = datetime.now() end = datetime.now()
diff = end - start diff = end - start
logger.info(e) logger.info(e)
failed.append(t.__name__) failed.append(t.__name__)
logger.info("FAIL " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end)) result = "FAIL " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end)
logger.info(result)
if log_file: if log_file:
print "FAIL " + t.__name__ + " " + str(diff.total_seconds()) + " " + str(end) print result
if results_file:
f = open(results_file, 'a')
f.write(result + "\n")
f.close()
for d in dev: for d in dev:
try: try:
d.request("NOTE TEST-STOP " + t.__name__) d.request("NOTE TEST-STOP " + t.__name__)