]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Save debug log to a file and clean up stdout status
authorJouni Malinen <j@w1.fi>
Sun, 25 Aug 2013 17:15:54 +0000 (20:15 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 25 Aug 2013 17:15:54 +0000 (20:15 +0300)
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>

tests/hwsim/run-all.sh
tests/hwsim/run-tests.py

index 5d409cfe039ba42e25646dac98d8d195225b7391..984d75474af68e6db276f33bf305d3b3eb1b7091 100755 (executable)
@@ -6,8 +6,10 @@ umask 0002
 if [ "x$1" = "xconcurrent-valgrind" ]; then
     ./start-p2p-concurrent.sh valgrind
     DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    rm logs/last-debug
     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
     ./stop-wifi.sh valgrind
     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
     ./start-p2p-concurrent.sh
     DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    rm logs/last-debug
     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
     ./stop-wifi.sh
     if [ $errors -gt 0 ]; then
@@ -33,7 +37,8 @@ elif [ "x$1" = "xconcurrent" ]; then
 elif [ "x$1" = "xvalgrind" ]; then
     ./start.sh valgrind
     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
     failures=`grep "ERROR SUMMARY" logs/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
     if [ $failures -gt 0 ]; then
@@ -47,7 +52,8 @@ elif [ "x$1" = "xvalgrind" ]; then
 else
     ./start.sh
     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
     if [ $errors -gt 0 ]; then
        tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz logs/$DATE*
index 51cad6d39a621b539fc4728a2e9fd0087d758a55..ba24ca0cf73eea1e9f6de1c6308fb332339e2267 100755 (executable)
@@ -30,6 +30,7 @@ def reset_devs(dev, apdev):
 def main():
     test_file = None
     error_file = None
+    log_file = None
     idx = 1
     if len(sys.argv) > 1 and sys.argv[1] == '-d':
         logging.basicConfig(level=logging.DEBUG)
@@ -37,6 +38,10 @@ def main():
     elif len(sys.argv) > 1 and sys.argv[1] == '-q':
         logging.basicConfig(level=logging.WARNING)
         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:
         logging.basicConfig(level=logging.INFO)
 
@@ -91,6 +96,8 @@ def main():
                 continue
         reset_devs(dev, apdev)
         logger.info("START " + t.__name__)
+        if log_file:
+            print "START " + t.__name__
         if t.__doc__:
             logger.info("Test: " + t.__doc__)
         for d in dev:
@@ -106,10 +113,14 @@ def main():
                 t(dev)
             passed.append(t.__name__)
             logger.info("PASS " + t.__name__)
+            if log_file:
+                print "PASS " + t.__name__
         except Exception, e:
             logger.info(e)
             failed.append(t.__name__)
             logger.info("FAIL " + t.__name__)
+            if log_file:
+                print "FAIL " + t.__name__
         for d in dev:
             try:
                 d.request("NOTE TEST-STOP " + t.__name__)
@@ -129,6 +140,8 @@ def main():
             f.close()
         sys.exit(1)
     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__":
     main()