Message ID | 1488159716-16578-1-git-send-email-masashi.honma@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Mon, Feb 27, 2017 at 10:41:55AM +0900, Masashi Honma wrote: > diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py > index 3319673..bdce59c 100644 > --- a/tests/hwsim/test_wmediumd.py > +++ b/tests/hwsim/test_wmediumd.py > @@ -18,26 +18,46 @@ ifaces : > }; > """ > > -def test_wmediumd_simple(dev, apdev): > +def start_wmediumd(fn): > + try: > + p = subprocess.Popen(['wmediumd', '-l', '6', '-c', fn], > + stdout=subprocess.PIPE, > + stderr=subprocess.STDOUT) [...] > + if line.find('invalid option') > -1: > + raise HwsimSkip('wmediumd looks old. Retry after updation.') But fail the whole test just because we couldn't set log level? What if I just set default loglevel to 6 in wmediumd and then you can drop the "-l 6" change? Ok, I did that, default of 7 is too much anyhow.
On 2017/02/27 22:27, Bob Copeland wrote: > But fail the whole test just because we couldn't set log level? Yes, wmediumd could finish by other unexpected cases. I have modified patch to catch the full log for such cases. And old wmediumd could not pass the test_wmediumd_path_simple, because we changed the RSSI table. So we need to use new wmediumd... > What if I just set default loglevel to 6 in wmediumd and then you can > drop the "-l 6" change? Ok, I did that, default of 7 is too much anyhow. Oh, thanks ! I will remove -l option also. "-l 6" was needed to catch the message "REGISTER SENT!". Without it, we could unexpectedly run the test before wmediumd booted. Masashi Honma.
diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 6f62dea..80981ba 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -516,6 +516,8 @@ def main(): rename_log(args.logdir, 'fst-wpa_supplicant', name, None) if os.path.exists(os.path.join(args.logdir, 'fst-hostapd')): 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() diff = end - start diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py index 3319673..bdce59c 100644 --- a/tests/hwsim/test_wmediumd.py +++ b/tests/hwsim/test_wmediumd.py @@ -18,26 +18,46 @@ ifaces : }; """ -def test_wmediumd_simple(dev, apdev): +def start_wmediumd(fn): + try: + p = subprocess.Popen(['wmediumd', '-l', '6', '-c', fn], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + except OSError, e: + if e.errno == errno.ENOENT: + raise HwsimSkip('wmediumd not available') + raise + + while True: + line = p.stdout.readline() + if not line: + raise HwsimSkip('wmediumd was terminated unexpectedly') + if line.find('invalid option') > -1: + raise HwsimSkip('wmediumd looks old. Retry after updation.') + if line.find('REGISTER SENT!') > -1: + break + return p + +def stop_wmediumd(p, logdir): + p.terminate() + p.wait() + stdoutdata, stderrdata = p.communicate() + log_file = open(os.path.abspath(os.path.join(logdir, 'wmediumd.log')), 'a') + log_file.write(stdoutdata) + log_file.close() + +def test_wmediumd_simple(dev, apdev, params): """test a simple wmediumd configuration""" fd, fn = tempfile.mkstemp() try: f = os.fdopen(fd, 'w') f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr())) f.close() - try: - 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 + p = start_wmediumd(fn) try: _test_ap_open(dev, apdev) finally: - p.terminate() - p.wait() + stop_wmediumd(p, params['logdir']) # test that releasing hwsim works correctly _test_ap_open(dev, apdev) finally:
Signed-off-by: Masashi Honma <masashi.honma@gmail.com> --- tests/hwsim/run-tests.py | 2 ++ tests/hwsim/test_wmediumd.py | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-)