From 003716ec7bd7e1e73a0ae43b08d4f2c674ac782c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 1 Jan 2019 11:35:22 +0200 Subject: [PATCH] tests: Clear regdom changes more robustly in FST test cases Signed-off-by: Jouni Malinen --- tests/hwsim/fst_module_aux.py | 1 + tests/hwsim/fst_test_common.py | 9 +++++++++ tests/hwsim/test_fst_config.py | 1 + tests/hwsim/test_fst_module.py | 2 ++ 4 files changed, 13 insertions(+) diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index fa6078871..9fd838fd5 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -101,6 +101,7 @@ def stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2): sta2.stop() ap1.stop() ap2.stop() + fst_test_common.fst_clear_regdom() def connect_two_ap_sta_pairs(ap1, ap2, dev1, dev2, rsn=False): """Connects a pair of stations, each one to a separate AP""" diff --git a/tests/hwsim/fst_test_common.py b/tests/hwsim/fst_test_common.py index 22d0ff6e9..c0255ce31 100644 --- a/tests/hwsim/fst_test_common.py +++ b/tests/hwsim/fst_test_common.py @@ -5,6 +5,7 @@ # See README for more details. import subprocess +import time import logging import hostapd @@ -86,3 +87,11 @@ class HapdRegCtrl: raise Exception("Cannot restore regulatory domain") logger.debug("fst hostapd: regulatory domain ready") + +def fst_clear_regdom(): + cmd = subprocess.Popen([ "iw", "reg", "get" ], stdout=subprocess.PIPE) + res = cmd.stdout.read() + cmd.stdout.close() + if "country 00:" not in res: + subprocess.call(['iw', 'reg', 'set', '00']) + time.sleep(0.1) diff --git a/tests/hwsim/test_fst_config.py b/tests/hwsim/test_fst_config.py index 03287b238..9244740cd 100644 --- a/tests/hwsim/test_fst_config.py +++ b/tests/hwsim/test_fst_config.py @@ -219,6 +219,7 @@ class FstLauncher: while len(self.cfgs_to_run) != 0: cfg = self.cfgs_to_run[0] self.remove_cfg(cfg) + fst_test_common.fst_clear_regdom() def kill_pid(self, pidfile, try_again=False): """Kills process by PID file""" diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index 0d6f552ee..4e182b97e 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -1523,6 +1523,7 @@ def test_fst_ap_start_session_oom(dev, apdev, test_params): run_fst_ap_start_session_oom(apdev, ap1) finally: ap1.stop() + fst_test_common.fst_clear_regdom() def run_fst_ap_start_session_oom(apdev, ap1): with alloc_fail(ap1, 1, "fst_iface_create"): @@ -2137,6 +2138,7 @@ def test_fst_ap_config_oom(dev, apdev, test_params): # This is allowed to complete currently ap1.stop() + fst_test_common.fst_clear_regdom() def test_fst_send_oom(dev, apdev, test_params): """FST send action OOM"""