tests: Use logger.info() instead of print to get one stream
authorJouni Malinen <j@w1.fi>
Sat, 24 Aug 2013 16:48:04 +0000 (19:48 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 24 Aug 2013 16:48:04 +0000 (19:48 +0300)
print and logger.info() were directing output to different locations
(stdout and stderr, respectively) which resulted in buildbot showing
reordered entries. Use logger consistently to avoid that.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/hwsim_utils.py
tests/hwsim/run-tests.py

index b48cc41..cd4a1b7 100644 (file)
@@ -24,8 +24,8 @@ def test_connectivity(ifname1, ifname2):
         s = subprocess.check_output(cmd)
         logger.debug(s)
     except subprocess.CalledProcessError, e:
-        print "hwsim failed: " + str(e.returncode)
-        print e.output
+        logger.info("hwsim failed: " + str(e.returncode))
+        logger.info(e.output)
         raise
 
 def test_connectivity_p2p(dev1, dev2):
index e7796cf..bf08a55 100755 (executable)
@@ -12,6 +12,7 @@ import sys
 import time
 
 import logging
+logger = logging.getLogger(__name__)
 
 from wpasupplicant import WpaSupplicant
 from hostapd import HostapdGlobal
@@ -59,11 +60,11 @@ def main():
 
     for d in dev:
         if not d.ping():
-            print d.ifname + ": No response from wpa_supplicant"
+            logger.info(d.ifname + ": No response from wpa_supplicant")
             return
-        print "DEV: " + d.ifname + ": " + d.p2p_dev_addr()
+        logger.info("DEV: " + d.ifname + ": " + d.p2p_dev_addr())
     for ap in apdev:
-        print "APDEV: " + ap['ifname']
+        logger.info("APDEV: " + ap['ifname'])
 
     tests = []
     for t in os.listdir("."):
@@ -71,7 +72,7 @@ def main():
         if m:
             if test_file and test_file not in t:
                 continue
-            print "Import test cases from " + t
+            logger.info("Import test cases from " + t)
             mod = __import__(m.group(1))
             for s in dir(mod):
                 if s.startswith("test_"):
@@ -86,46 +87,45 @@ def main():
             if test_filter != t.__name__:
                 continue
         reset_devs(dev, apdev)
-        print "START " + t.__name__
+        logger.info("START " + t.__name__)
         if t.__doc__:
-            print "Test: " + t.__doc__
+            logger.info("Test: " + t.__doc__)
         for d in dev:
             try:
                 d.request("NOTE TEST-START " + t.__name__)
             except Exception, e:
-                print "Failed to issue TEST-START before " + t.__name__ + " for " + d.ifname
-                print e
+                logger.info("Failed to issue TEST-START before " + t.__name__ + " for " + d.ifname)
+                logger.info(e)
         try:
             if t.func_code.co_argcount > 1:
                 t(dev, apdev)
             else:
                 t(dev)
             passed.append(t.__name__)
-            print "PASS " + t.__name__
+            logger.info("PASS " + t.__name__)
         except Exception, e:
-            print e
+            logger.info(e)
             failed.append(t.__name__)
-            print "FAIL " + t.__name__
+            logger.info("FAIL " + t.__name__)
         for d in dev:
             try:
                 d.request("NOTE TEST-STOP " + t.__name__)
             except Exception, e:
-                print "Failed to issue TEST-STOP after " + t.__name__ + " for " + d.ifname
-                print e
+                logger.info("Failed to issue TEST-STOP after " + t.__name__ + " for " + d.ifname)
+                logger.info(e)
 
     if not test_filter:
         reset_devs(dev, apdev)
 
-    print
     if len(failed):
-        print "passed " + str(len(passed)) + " test case(s)"
-        print "failed tests: " + str(failed)
+        logger.info("passed " + str(len(passed)) + " test case(s)")
+        logger.info("failed tests: " + str(failed))
         if error_file:
             f = open(error_file, 'w')
             f.write(str(failed) + '\n')
             f.close()
         sys.exit(1)
-    print "passed all " + str(len(passed)) + " test case(s)"
+    logger.info("passed all " + str(len(passed)) + " test case(s)")
 
 if __name__ == "__main__":
     main()