diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index 0e4ef477c..b08025f33 100644 --- a/tests/hwsim/test_ap_acs.py +++ b/tests/hwsim/test_ap_acs.py @@ -154,12 +154,15 @@ def test_ap_acs_5ghz(dev, apdev): raise Exception("Unexpected frequency") dev[0].connect("test-acs", psk="12345678", scan_freq=freq) - + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_acs_5ghz_40mhz(dev, apdev): @@ -183,12 +186,15 @@ def test_ap_acs_5ghz_40mhz(dev, apdev): raise Exception("Secondary channel not set") dev[0].connect("test-acs", psk="12345678", scan_freq=freq) - + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_acs_vht(dev, apdev): @@ -214,12 +220,15 @@ def test_ap_acs_vht(dev, apdev): raise Exception("Secondary channel not set") dev[0].connect("test-acs", psk="12345678", scan_freq=freq) - + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_acs_vht40(dev, apdev): @@ -247,12 +256,15 @@ def test_ap_acs_vht40(dev, apdev): raise Exception("Secondary channel not set") dev[0].connect("test-acs", psk="12345678", scan_freq=freq) - + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_acs_vht160(dev, apdev): @@ -283,11 +295,16 @@ def test_ap_acs_vht160(dev, apdev): if int(freq) < 5000: raise Exception("Unexpected frequency") dev[0].connect("test-acs", psk="12345678", scan_freq=freq) + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) + dev[0].flush_scan_cache() def test_ap_acs_vht160_scan_disable(dev, apdev): """Automatic channel selection for VHT160 and DISABLE during scan""" diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index 20e00a2ef..45fb7920f 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -767,10 +767,16 @@ def test_ap_open_country_outdoor(dev, apdev): def _test_ap_open_country(dev, apdev, country_code, country3): try: - run_ap_open_country(dev, apdev, country_code, country3) + hapd = None + hapd = run_ap_open_country(dev, apdev, country_code, country3) finally: + if hapd: + hapd.request("DISABLE") dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) set_world_reg(apdev[0], apdev[1], dev[0]) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def run_ap_open_country(dev, apdev, country_code, country3): @@ -780,8 +786,8 @@ def run_ap_open_country(dev, apdev, country_code, country3): "ieee80211d": "1" }) dev[0].scan_for_bss(hapd.own_addr(), freq=2412) dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") - dev[0].request("DISCONNECT") - dev[0].wait_disconnected() + dev[0].wait_regdom(country_ie=True) + return hapd def test_ap_open_disable_select(dev, apdev): """DISABLE_NETWORK for connected AP followed by SELECT_NETWORK""" diff --git a/tests/hwsim/test_ap_params.py b/tests/hwsim/test_ap_params.py index cd6846956..a39bfcee2 100644 --- a/tests/hwsim/test_ap_params.py +++ b/tests/hwsim/test_ap_params.py @@ -116,10 +116,13 @@ def test_ap_country(dev, apdev): dev[0].connect(ssid, psk=passphrase, scan_freq="5180") hwsim_utils.test_connectivity(dev[0], hapd) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_acl_accept(dev, apdev): @@ -415,11 +418,15 @@ def test_ap_spectrum_management_required(dev, apdev): hapd = None hapd = hostapd.add_ap(apdev[0], params) dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180") + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() @remote_compatible diff --git a/tests/hwsim/test_ap_vht.py b/tests/hwsim/test_ap_vht.py index e6c39b659..64c0921b0 100644 --- a/tests/hwsim/test_ap_vht.py +++ b/tests/hwsim/test_ap_vht.py @@ -357,6 +357,7 @@ def test_ap_vht160(dev, apdev): raise Exception("Unexpected interface state") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) sig = dev[0].request("SIGNAL_POLL").splitlines() if "FREQUENCY=5180" not in sig: @@ -369,10 +370,13 @@ def test_ap_vht160(dev, apdev): raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_vht160b(dev, apdev): @@ -427,6 +431,7 @@ def test_ap_vht160b(dev, apdev): raise Exception("Unexpected frequency(2)") dev[0].connect("vht", key_mgmt="NONE", scan_freq="5520") + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) sig = dev[0].request("SIGNAL_POLL").splitlines() if "FREQUENCY=5520" not in sig: @@ -439,10 +444,13 @@ def test_ap_vht160b(dev, apdev): raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_vht160_no_dfs_100_plus(dev, apdev): @@ -503,6 +511,7 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab): freq = str(int(channel) * 5 + 5000) dev[0].connect("vht", key_mgmt="NONE", scan_freq=freq) + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) sig = dev[0].request("SIGNAL_POLL").splitlines() if "FREQUENCY=" + freq not in sig: @@ -515,10 +524,13 @@ def run_ap_vht160_no_dfs(dev, apdev, channel, ht_capab): raise HwsimSkip("80/160 MHz channel not supported in regulatory information") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_vht160_no_ht40(dev, apdev): @@ -947,16 +959,20 @@ def test_ap_vht80_pwr_constraint(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") + dev[0].wait_regdom(country_ie=True) except Exception, e: if isinstance(e, Exception) and str(e) == "AP startup failed": if not vht_supported(): raise HwsimSkip("80 MHz channel not supported in regulatory information") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_ap_vht_use_sta_nsts(dev, apdev): @@ -1059,12 +1075,16 @@ def test_ap_vht_40_fallback_to_20(devs, apdevs): } hapd = hostapd.add_ap(ap, params) dev.connect("test-vht40", scan_freq="5805", key_mgmt="NONE") + dev.wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev, hapd) finally: - dev.request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev.request("DISCONNECT") + dev.request("ABORT_SCAN") + dev.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev.wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev.flush_scan_cache() def test_ap_vht80_to_24g_ht(dev, apdev): diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index bf9af8f8b..ae07b90d7 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -106,6 +106,7 @@ def test_dfs(dev, apdev): raise Exception("Unexpected frequency") dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) hapd.request("RADAR DETECTED freq=5260 ht_enabled=1 chan_width=1") @@ -128,10 +129,13 @@ def test_dfs(dev, apdev): time.sleep(1) hwsim_utils.test_connectivity(dev[0], hapd) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_etsi(dev, apdev, params): @@ -161,6 +165,7 @@ def test_dfs_etsi(dev, apdev, params): raise Exception("Unexpected frequency") dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) hapd.request("RADAR DETECTED freq=%s ht_enabled=1 chan_width=1" % freq) @@ -197,10 +202,13 @@ def test_dfs_etsi(dev, apdev, params): time.sleep(1) hwsim_utils.test_connectivity(dev[0], hapd) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar1(dev, apdev): @@ -255,11 +263,15 @@ def test_dfs_radar1(dev, apdev): raise Exception("Unexpected frequency: " + freq) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar2(dev, apdev): @@ -324,11 +336,15 @@ def test_dfs_radar_chanlist(dev, apdev): if "AP-ENABLED" not in ev: raise Exception("Unexpected DFS event: " + ev) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar_chanlist_vht80(dev, apdev): @@ -359,14 +375,18 @@ def test_dfs_radar_chanlist_vht80(dev, apdev): if "AP-ENABLED" not in ev: raise Exception("Unexpected DFS event: " + ev) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) if hapd.get_status_field('vht_oper_centr_freq_seg0_idx') != "42": raise Exception("Unexpected seg0 idx") finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar_chanlist_vht20(dev, apdev): @@ -397,11 +417,15 @@ def test_dfs_radar_chanlist_vht20(dev, apdev): if "AP-ENABLED" not in ev: raise Exception("Unexpected DFS event: " + ev) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar_no_ht(dev, apdev): @@ -432,11 +456,15 @@ def test_dfs_radar_no_ht(dev, apdev): if "AP-ENABLED" not in ev: raise Exception("Unexpected DFS event: " + ev) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_dfs_radar_ht40minus(dev, apdev): @@ -467,12 +495,18 @@ def test_dfs_radar_ht40minus(dev, apdev): if "AP-ENABLED" not in ev: raise Exception("Unexpected DFS event: " + ev) dev[0].connect("dfs", key_mgmt="NONE") + dev[0].wait_regdom(country_ie=True) + dev[0].request("STA_AUTOCONNECT 0") finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() + dev[0].request("STA_AUTOCONNECT 1") def test_dfs_ht40_minus(dev, apdev, params): """DFS CAC functionality on channel 104 HT40- [long]""" @@ -502,10 +536,14 @@ def test_dfs_ht40_minus(dev, apdev, params): raise Exception("Unexpected frequency") dev[0].connect("dfs", key_mgmt="NONE", scan_freq="5520") + dev[0].wait_regdom(country_ie=True) hwsim_utils.test_connectivity(dev[0], hapd) finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() diff --git a/tests/hwsim/test_ocv.py b/tests/hwsim/test_ocv.py index 6244d2a8a..b76b6cfd5 100644 --- a/tests/hwsim/test_ocv.py +++ b/tests/hwsim/test_ocv.py @@ -98,6 +98,7 @@ def run_wpa2_ocv_5ghz(dev, apdev): for ocv in range(2): dev[0].connect(ssid, psk=passphrase, scan_freq="5200", ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() @@ -149,6 +150,7 @@ def run_wpa2_ocv_ht40(dev, apdev): ieee80211w="1", disable_ht="1") dev[1].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") dev[0].wait_disconnected() @@ -190,6 +192,7 @@ def run_wpa2_ocv_vht40(dev, apdev): ieee80211w="1", disable_vht="1") dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all") @@ -230,6 +233,7 @@ def run_wpa2_ocv_vht80(dev, apdev): ieee80211w="1", disable_vht="1") dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all") @@ -270,6 +274,7 @@ def run_wpa2_ocv_vht160(dev, apdev): ieee80211w="1", disable_vht="1") dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all") @@ -285,6 +290,7 @@ def test_wpa2_ocv_vht80plus80(dev, apdev): run_wpa2_ocv_vht80plus80(dev, apdev) finally: set_world_reg(apdev[0], apdev[1], dev[0]) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() dev[1].flush_scan_cache() dev[2].flush_scan_cache() @@ -313,13 +319,24 @@ def run_wpa2_ocv_vht80plus80(dev, apdev): ieee80211w="1", disable_vht="1") dev[2].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), ieee80211w="1") + dev[0].wait_regdom(country_ie=True) dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") dev[2].request("REMOVE_NETWORK all") dev[0].wait_disconnected() dev[1].wait_disconnected() dev[2].wait_disconnected() + for i in range(3): + dev[i].connect(ssid, psk=passphrase, scan_freq=freq, ocv=str(ocv), + ieee80211w="1") + if i == 0: + dev[i].wait_regdom(country_ie=True) hapd.disable() + for i in range(3): + dev[i].request("DISCONNECT") + dev[i].request("ABORT_SCAN") + for i in range(3): + dev[i].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) class APConnection: def init_params(self): @@ -372,6 +389,8 @@ class APConnection: dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq, ocv=sta_ocv, ieee80211w="1", wait_connect=False) + if "country_code" in params: + dev.wait_regdom(country_ie=True) self.addr = dev.p2p_interface_addr() # Wait for EAPOL-Key msg 1/4 from hostapd to determine when associated @@ -473,6 +492,7 @@ def test_wpa2_ocv_ap_vht160_mismatch(dev, apdev): run_wpa2_ocv_ap_vht160_mismatch(dev, apdev) finally: set_world_reg(apdev[0], apdev[1], dev[0]) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev): @@ -498,8 +518,11 @@ def run_wpa2_ocv_ap_vht160_mismatch(dev, apdev): conn.confirm_valid_oci(129, 100, 0) dev[0].dump_monitor() + if conn.hapd: + conn.hapd.request("DISABLE") dev[0].request("DISCONNECT") - dev[0].wait_disconnected() + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) @remote_compatible def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): @@ -508,6 +531,7 @@ def test_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev) finally: set_world_reg(apdev[0], apdev[1], dev[0]) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): @@ -530,8 +554,11 @@ def run_wpa2_ocv_ap_vht80plus80_mismatch(dev, apdev): conn.confirm_valid_oci(130, 36, 155) dev[0].dump_monitor() + if conn.hapd: + conn.hapd.request("DISABLE") dev[0].request("DISCONNECT") - dev[0].wait_disconnected() + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) @remote_compatible def test_wpa2_ocv_ap_unexpected1(dev, apdev): @@ -720,6 +747,8 @@ class STAConnection: self.dev.connect(self.ssid, raw_psk=self.psk, scan_freq=freq, wait_connect=False, **sta_params) + if "country_code" in params: + self.dev.wait_regdom(country_ie=True) self.addr = dev.p2p_interface_addr() # Forward msg 1/4 from AP to STA @@ -798,6 +827,7 @@ def test_wpa2_ocv_vht160_mismatch_client(dev, apdev): run_wpa2_ocv_vht160_mismatch_client(dev, apdev) finally: set_world_reg(apdev[0], apdev[1], dev[0]) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def run_wpa2_ocv_vht160_mismatch_client(dev, apdev): @@ -824,6 +854,13 @@ def run_wpa2_ocv_vht160_mismatch_client(dev, apdev): 129, 104, 0, "primary channel mismatch") conn.confirm_valid_oci(122, 100, 0) + dev[0].dump_monitor() + if conn.hapd: + conn.hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) + def test_wpa2_ocv_sta_group_hs(dev, apdev): """OCV group handshake (STA)""" params = { "channel": "1", diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index 155ab32b7..2b205bcad 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -1555,10 +1555,13 @@ def test_rrm_beacon_req_passive_scan_vht(dev, apdev): raise HwsimSkip("80 MHz channel not supported in regulatory information") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_rrm_beacon_req_passive_scan_vht160(dev, apdev): @@ -1601,10 +1604,13 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev): raise HwsimSkip("ZA regulatory rule likely did not have DFS requirement removed") raise finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_rrm_beacon_req_ap_errors(dev, apdev): diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index 1d13194c3..f2b5dd3ef 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -23,13 +23,13 @@ def clear_regdom_state(dev, hapd, hapd2): ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) if ev is None or "init=COUNTRY_IE" in ev: break - dev[0].request("DISCONNECT") - dev[0].request("ABORT_SCAN") - dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) if hapd: hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) dev[0].dump_monitor() subprocess.call(['iw', 'reg', 'set', '00']) dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) @@ -1128,13 +1128,13 @@ def start_wnm_tm(ap, country, dev, country3=None): return hapd, id def stop_wnm_tm(hapd, dev): + if hapd: + hapd.request("DISABLE") dev.request("DISCONNECT") try: dev.wait_disconnected() except: pass - if hapd: - hapd.request("DISABLE") subprocess.call(['iw', 'reg', 'set', '00']) dev.flush_scan_cache() @@ -1864,11 +1864,15 @@ def test_wnm_bss_tm_reject(dev, apdev): if "status_code=123" not in ev: raise Exception("Unexpected BSS Transition Management Response status: " + ev) dev[0].wait_disconnected() + dev[0].wait_connected() finally: - dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") + dev[0].request("DISCONNECT") + dev[0].request("ABORT_SCAN") + dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5) subprocess.call(['iw', 'reg', 'set', '00']) + dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5) dev[0].flush_scan_cache() def test_wnm_bss_tm_ap_proto(dev, apdev): diff --git a/tests/hwsim/test_wpas_ap.py b/tests/hwsim/test_wpas_ap.py index ba0445f57..1aff48ae5 100644 --- a/tests/hwsim/test_wpas_ap.py +++ b/tests/hwsim/test_wpas_ap.py @@ -382,7 +382,10 @@ def _test_wpas_ap_dfs(dev): raise Exception("AP failed to start") dev[1].connect("wpas-ap-dfs", key_mgmt="NONE") + dev[1].wait_regdom(country_ie=True) + dev[0].request("DISCONNECT") dev[1].request("DISCONNECT") + dev[1].request("ABORT_SCAN") dev[1].wait_disconnected() @remote_compatible