diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py index b48cc41e8..cd4a1b770 100644 --- a/tests/hwsim/hwsim_utils.py +++ b/tests/hwsim/hwsim_utils.py @@ -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): diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index e7796cfe9..bf08a5530 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -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()