tests: Use logger.info() instead of print to get one stream

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>
This commit is contained in:
Jouni Malinen 2013-08-24 19:48:04 +03:00
parent 4896ddaea1
commit 3ed2814a1e
2 changed files with 19 additions and 19 deletions

View File

@ -24,8 +24,8 @@ def test_connectivity(ifname1, ifname2):
s = subprocess.check_output(cmd) s = subprocess.check_output(cmd)
logger.debug(s) logger.debug(s)
except subprocess.CalledProcessError, e: except subprocess.CalledProcessError, e:
print "hwsim failed: " + str(e.returncode) logger.info("hwsim failed: " + str(e.returncode))
print e.output logger.info(e.output)
raise raise
def test_connectivity_p2p(dev1, dev2): def test_connectivity_p2p(dev1, dev2):

View File

@ -12,6 +12,7 @@ import sys
import time import time
import logging import logging
logger = logging.getLogger(__name__)
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from hostapd import HostapdGlobal from hostapd import HostapdGlobal
@ -59,11 +60,11 @@ def main():
for d in dev: for d in dev:
if not d.ping(): if not d.ping():
print d.ifname + ": No response from wpa_supplicant" logger.info(d.ifname + ": No response from wpa_supplicant")
return return
print "DEV: " + d.ifname + ": " + d.p2p_dev_addr() logger.info("DEV: " + d.ifname + ": " + d.p2p_dev_addr())
for ap in apdev: for ap in apdev:
print "APDEV: " + ap['ifname'] logger.info("APDEV: " + ap['ifname'])
tests = [] tests = []
for t in os.listdir("."): for t in os.listdir("."):
@ -71,7 +72,7 @@ def main():
if m: if m:
if test_file and test_file not in t: if test_file and test_file not in t:
continue continue
print "Import test cases from " + t logger.info("Import test cases from " + t)
mod = __import__(m.group(1)) mod = __import__(m.group(1))
for s in dir(mod): for s in dir(mod):
if s.startswith("test_"): if s.startswith("test_"):
@ -86,46 +87,45 @@ def main():
if test_filter != t.__name__: if test_filter != t.__name__:
continue continue
reset_devs(dev, apdev) reset_devs(dev, apdev)
print "START " + t.__name__ logger.info("START " + t.__name__)
if t.__doc__: if t.__doc__:
print "Test: " + t.__doc__ logger.info("Test: " + t.__doc__)
for d in dev: for d in dev:
try: try:
d.request("NOTE TEST-START " + t.__name__) d.request("NOTE TEST-START " + t.__name__)
except Exception, e: except Exception, e:
print "Failed to issue TEST-START before " + t.__name__ + " for " + d.ifname logger.info("Failed to issue TEST-START before " + t.__name__ + " for " + d.ifname)
print e logger.info(e)
try: try:
if t.func_code.co_argcount > 1: if t.func_code.co_argcount > 1:
t(dev, apdev) t(dev, apdev)
else: else:
t(dev) t(dev)
passed.append(t.__name__) passed.append(t.__name__)
print "PASS " + t.__name__ logger.info("PASS " + t.__name__)
except Exception, e: except Exception, e:
print e logger.info(e)
failed.append(t.__name__) failed.append(t.__name__)
print "FAIL " + t.__name__ logger.info("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__)
except Exception, e: except Exception, e:
print "Failed to issue TEST-STOP after " + t.__name__ + " for " + d.ifname logger.info("Failed to issue TEST-STOP after " + t.__name__ + " for " + d.ifname)
print e logger.info(e)
if not test_filter: if not test_filter:
reset_devs(dev, apdev) reset_devs(dev, apdev)
print
if len(failed): if len(failed):
print "passed " + str(len(passed)) + " test case(s)" logger.info("passed " + str(len(passed)) + " test case(s)")
print "failed tests: " + str(failed) logger.info("failed tests: " + str(failed))
if error_file: if error_file:
f = open(error_file, 'w') f = open(error_file, 'w')
f.write(str(failed) + '\n') f.write(str(failed) + '\n')
f.close() f.close()
sys.exit(1) 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__": if __name__ == "__main__":
main() main()