tests: Save the log of wmediumd

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2017-02-28 09:50:51 +09:00 committed by Jouni Malinen
parent 33a6da6908
commit d760db19b1
2 changed files with 38 additions and 11 deletions

View file

@ -516,6 +516,8 @@ def main():
rename_log(args.logdir, 'fst-wpa_supplicant', name, None) rename_log(args.logdir, 'fst-wpa_supplicant', name, None)
if os.path.exists(os.path.join(args.logdir, 'fst-hostapd')): if os.path.exists(os.path.join(args.logdir, 'fst-hostapd')):
rename_log(args.logdir, 'fst-hostapd', name, None) rename_log(args.logdir, 'fst-hostapd', name, None)
if os.path.exists(os.path.join(args.logdir, 'wmediumd.log')):
rename_log(args.logdir, 'wmediumd.log', name, None)
end = datetime.now() end = datetime.now()
diff = end - start diff = end - start

View file

@ -18,26 +18,51 @@ ifaces :
}; };
""" """
def test_wmediumd_simple(dev, apdev): def output_wmediumd_log(p, params, data):
log_file = open(os.path.abspath(os.path.join(params['logdir'],
'wmediumd.log')), 'a')
log_file.write(data)
log_file.close()
def start_wmediumd(fn, params):
try:
p = subprocess.Popen(['wmediumd', '-c', fn],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except OSError, e:
if e.errno == errno.ENOENT:
raise HwsimSkip('wmediumd not available')
raise
logs = ''
while True:
line = p.stdout.readline()
if not line:
output_wmediumd_log(p, params, logs)
raise Exception('wmediumd was terminated unexpectedly')
if line.find('REGISTER SENT!') > -1:
break
logs += line
return p
def stop_wmediumd(p, params):
p.terminate()
p.wait()
stdoutdata, stderrdata = p.communicate()
output_wmediumd_log(p, params, stdoutdata)
def test_wmediumd_simple(dev, apdev, params):
"""test a simple wmediumd configuration""" """test a simple wmediumd configuration"""
fd, fn = tempfile.mkstemp() fd, fn = tempfile.mkstemp()
try: try:
f = os.fdopen(fd, 'w') f = os.fdopen(fd, 'w')
f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr())) f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr()))
f.close() f.close()
try: p = start_wmediumd(fn, params)
p = subprocess.Popen(['wmediumd', '-c', fn],
stdout=open('/dev/null', 'a'),
stderr=subprocess.STDOUT)
except OSError, e:
if e.errno == errno.ENOENT:
raise HwsimSkip("wmediumd not available")
raise
try: try:
_test_ap_open(dev, apdev) _test_ap_open(dev, apdev)
finally: finally:
p.terminate() stop_wmediumd(p, params)
p.wait()
# test that releasing hwsim works correctly # test that releasing hwsim works correctly
_test_ap_open(dev, apdev) _test_ap_open(dev, apdev)
finally: finally: