Browse Source

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>
Jouni Malinen 11 years ago
parent
commit
c548fb27c8
2 changed files with 23 additions and 4 deletions
  1. 10 4
      tests/hwsim/run-all.sh
  2. 13 0
      tests/hwsim/run-tests.py

+ 10 - 4
tests/hwsim/run-all.sh

@@ -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*

+ 13 - 0
tests/hwsim/run-tests.py

@@ -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()