tests: Save debug log to a file and clean up stdout status
This makes it easier to figure out what failed and allows builbot to integrate multiple logs and state information about the test cases. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
25a8f9e316
commit
c548fb27c8
2 changed files with 23 additions and 4 deletions
|
@ -6,8 +6,10 @@ umask 0002
|
||||||
if [ "x$1" = "xconcurrent-valgrind" ]; then
|
if [ "x$1" = "xconcurrent-valgrind" ]; then
|
||||||
./start-p2p-concurrent.sh valgrind
|
./start-p2p-concurrent.sh valgrind
|
||||||
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
||||||
|
rm logs/last-debug
|
||||||
for i in autogo discovery grpform; do
|
for i in autogo discovery grpform; do
|
||||||
./run-tests.py -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 -f test_p2p_$i.py || errors=1
|
||||||
|
cat logs/$DATE-run-$i >> logs/last-debug
|
||||||
done
|
done
|
||||||
./stop-wifi.sh valgrind
|
./stop-wifi.sh valgrind
|
||||||
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`
|
||||||
|
@ -22,8 +24,10 @@ if [ "x$1" = "xconcurrent-valgrind" ]; then
|
||||||
elif [ "x$1" = "xconcurrent" ]; then
|
elif [ "x$1" = "xconcurrent" ]; then
|
||||||
./start-p2p-concurrent.sh
|
./start-p2p-concurrent.sh
|
||||||
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
||||||
|
rm logs/last-debug
|
||||||
for i in autogo discovery grpform; do
|
for i in autogo discovery grpform; do
|
||||||
./run-tests.py -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 -f test_p2p_$i.py || errors=1
|
||||||
|
cat logs/$DATE-run-$i >> logs/last-debug
|
||||||
done
|
done
|
||||||
./stop-wifi.sh
|
./stop-wifi.sh
|
||||||
if [ $errors -gt 0 ]; then
|
if [ $errors -gt 0 ]; then
|
||||||
|
@ -33,7 +37,8 @@ elif [ "x$1" = "xconcurrent" ]; then
|
||||||
elif [ "x$1" = "xvalgrind" ]; then
|
elif [ "x$1" = "xvalgrind" ]; then
|
||||||
./start.sh valgrind
|
./start.sh valgrind
|
||||||
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
||||||
./run-tests.py -e logs/$DATE-failed || errors=1
|
./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1
|
||||||
|
cat logs/$DATE-run > logs/last-debug
|
||||||
./stop-wifi.sh valgrind
|
./stop-wifi.sh valgrind
|
||||||
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`
|
||||||
if [ $failures -gt 0 ]; then
|
if [ $failures -gt 0 ]; then
|
||||||
|
@ -47,7 +52,8 @@ elif [ "x$1" = "xvalgrind" ]; then
|
||||||
else
|
else
|
||||||
./start.sh
|
./start.sh
|
||||||
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
|
||||||
./run-tests.py -e logs/$DATE-failed || errors=1
|
./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1
|
||||||
|
cat logs/$DATE-run > logs/last-debug
|
||||||
./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*
|
tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz logs/$DATE*
|
||||||
|
|
|
@ -30,6 +30,7 @@ def reset_devs(dev, apdev):
|
||||||
def main():
|
def main():
|
||||||
test_file = None
|
test_file = None
|
||||||
error_file = None
|
error_file = None
|
||||||
|
log_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)
|
||||||
|
@ -37,6 +38,10 @@ def main():
|
||||||
elif len(sys.argv) > 1 and sys.argv[1] == '-q':
|
elif len(sys.argv) > 1 and sys.argv[1] == '-q':
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
idx = idx + 1
|
idx = idx + 1
|
||||||
|
elif len(sys.argv) > 2 and sys.argv[1] == '-l':
|
||||||
|
log_file = sys.argv[2]
|
||||||
|
logging.basicConfig(filename=log_file,level=logging.DEBUG)
|
||||||
|
idx = idx + 2
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
@ -91,6 +96,8 @@ def main():
|
||||||
continue
|
continue
|
||||||
reset_devs(dev, apdev)
|
reset_devs(dev, apdev)
|
||||||
logger.info("START " + t.__name__)
|
logger.info("START " + t.__name__)
|
||||||
|
if log_file:
|
||||||
|
print "START " + t.__name__
|
||||||
if t.__doc__:
|
if t.__doc__:
|
||||||
logger.info("Test: " + t.__doc__)
|
logger.info("Test: " + t.__doc__)
|
||||||
for d in dev:
|
for d in dev:
|
||||||
|
@ -106,10 +113,14 @@ def main():
|
||||||
t(dev)
|
t(dev)
|
||||||
passed.append(t.__name__)
|
passed.append(t.__name__)
|
||||||
logger.info("PASS " + t.__name__)
|
logger.info("PASS " + t.__name__)
|
||||||
|
if log_file:
|
||||||
|
print "PASS " + t.__name__
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
failed.append(t.__name__)
|
failed.append(t.__name__)
|
||||||
logger.info("FAIL " + t.__name__)
|
logger.info("FAIL " + t.__name__)
|
||||||
|
if log_file:
|
||||||
|
print "FAIL " + t.__name__
|
||||||
for d in dev:
|
for d in dev:
|
||||||
try:
|
try:
|
||||||
d.request("NOTE TEST-STOP " + t.__name__)
|
d.request("NOTE TEST-STOP " + t.__name__)
|
||||||
|
@ -129,6 +140,8 @@ 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 log_file:
|
||||||
|
print "passed all " + str(len(passed)) + " test case(s)"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue