diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index 1833c0fd8..450a38fa1 100644 --- a/tests/hwsim/test_ap_acs.py +++ b/tests/hwsim/test_ap_acs.py @@ -10,7 +10,6 @@ import time import hostapd from utils import * -from test_ap_ht import clear_scan_cache from test_dfs import wait_dfs_event def force_prev_ap_on_24g(ap): diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index c2b032c11..51187177b 100644 --- a/tests/hwsim/test_ap_ht.py +++ b/tests/hwsim/test_ap_ht.py @@ -12,27 +12,10 @@ import struct import hostapd from wpasupplicant import WpaSupplicant -from utils import HwsimSkip, alloc_fail, parse_ie, clear_regdom +from utils import * import hwsim_utils from test_ap_csa import csa_supported -def clear_scan_cache(apdev): - ifname = apdev['ifname'] - hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'up']) - hostapd.cmd_execute(apdev, ['iw', ifname, 'scan', 'trigger', 'freq', '2412', - 'flush']) - time.sleep(0.1) - hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'down']) - -def set_world_reg(apdev0=None, apdev1=None, dev0=None): - if apdev0: - hostapd.cmd_execute(apdev0, ['iw', 'reg', 'set', '00']) - if apdev1: - hostapd.cmd_execute(apdev1, ['iw', 'reg', 'set', '00']) - if dev0: - dev0.cmd_execute(['iw', 'reg', 'set', '00']) - time.sleep(0.1) - def test_ap_ht40_scan(dev, apdev): """HT40 co-ex scan""" clear_scan_cache(apdev[0]) diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index fd9919bb1..62f221542 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -18,7 +18,6 @@ from tshark import run_tshark from utils import * from wpasupplicant import WpaSupplicant from wlantest import WlantestCapture -from test_ap_ht import set_world_reg @remote_compatible def test_ap_open(dev, apdev): diff --git a/tests/hwsim/test_ap_vht.py b/tests/hwsim/test_ap_vht.py index 338e8c806..f0e2f3d61 100644 --- a/tests/hwsim/test_ap_vht.py +++ b/tests/hwsim/test_ap_vht.py @@ -16,7 +16,6 @@ from wpasupplicant import WpaSupplicant from utils import * from test_dfs import wait_dfs_event from test_ap_csa import csa_supported -from test_ap_ht import clear_scan_cache def test_ap_vht80(dev, apdev): """VHT with 80 MHz channel width""" diff --git a/tests/hwsim/test_he.py b/tests/hwsim/test_he.py index 25f53e713..22c9402f7 100644 --- a/tests/hwsim/test_he.py +++ b/tests/hwsim/test_he.py @@ -15,7 +15,6 @@ from wpasupplicant import WpaSupplicant from utils import * from test_dfs import wait_dfs_event from test_ap_csa import csa_supported -from test_ap_ht import clear_scan_cache def test_he_open(dev, apdev): """HE AP with open mode configuration""" diff --git a/tests/hwsim/test_ocv.py b/tests/hwsim/test_ocv.py index df84e7124..5456f3ba0 100644 --- a/tests/hwsim/test_ocv.py +++ b/tests/hwsim/test_ocv.py @@ -12,9 +12,8 @@ logger = logging.getLogger() import hostapd from wpasupplicant import WpaSupplicant import hwsim_utils -from utils import HwsimSkip +from utils import * -from test_ap_ht import set_world_reg from test_ap_psk import parse_eapol, build_eapol, pmk_to_ptk, eapol_key_mic, recv_eapol, send_eapol, reply_eapol, build_eapol_key_3_4, aes_wrap, pad_key_data #TODO: Refuse setting up AP with OCV but without MFP support diff --git a/tests/hwsim/test_p2p_concurrency.py b/tests/hwsim/test_p2p_concurrency.py index 512886ba4..8fb2bb929 100644 --- a/tests/hwsim/test_p2p_concurrency.py +++ b/tests/hwsim/test_p2p_concurrency.py @@ -13,8 +13,7 @@ import time import hwsim_utils import hostapd from p2p_utils import * -from test_ap_ht import clear_scan_cache -from utils import HwsimSkip +from utils import * @remote_compatible def test_concurrent_autogo(dev, apdev): diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index 425edb20e..2b43c4c59 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -17,7 +17,6 @@ import time import hostapd from wpasupplicant import WpaSupplicant from utils import * -from test_ap_ht import clear_scan_cache from remotehost import remote_compatible def check_rrm_support(dev): diff --git a/tests/hwsim/test_ssid.py b/tests/hwsim/test_ssid.py index d4ee4e370..faee75d5f 100644 --- a/tests/hwsim/test_ssid.py +++ b/tests/hwsim/test_ssid.py @@ -77,7 +77,7 @@ def test_ssid_utf8(dev, apdev): if "[UTF-8]" not in dev[0].request("SCAN_RESULTS"): raise Exception("[UTF-8] flag not included in SCAN_RESULTS") -def clear_scan_cache(hapd, dev): +def clear_scan_cache2(hapd, dev): # clear BSS table to avoid issues in following test cases dev[0].request("REMOVE_NETWORK all") dev[1].request("REMOVE_NETWORK all") @@ -97,7 +97,7 @@ def test_ssid_hidden(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - clear_scan_cache(hapd, dev) + clear_scan_cache2(hapd, dev) @remote_compatible def test_ssid_hidden2(dev, apdev): @@ -110,7 +110,7 @@ def test_ssid_hidden2(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - clear_scan_cache(hapd, dev) + clear_scan_cache2(hapd, dev) @remote_compatible def test_ssid_hidden_wpa2(dev, apdev): @@ -124,4 +124,4 @@ def test_ssid_hidden_wpa2(dev, apdev): ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection") - clear_scan_cache(hapd, dev) + clear_scan_cache2(hapd, dev) diff --git a/tests/hwsim/test_wpas_mesh.py b/tests/hwsim/test_wpas_mesh.py index aac49e2d0..3c918184f 100644 --- a/tests/hwsim/test_wpas_mesh.py +++ b/tests/hwsim/test_wpas_mesh.py @@ -18,7 +18,6 @@ import hostapd from wpasupplicant import WpaSupplicant from utils import * from tshark import run_tshark, run_tshark_json -from test_ap_ht import set_world_reg from test_sae import build_sae_commit, sae_rx_commit_token_req from hwsim_utils import set_group_map diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index 57b570c2e..5afa76b24 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -13,6 +13,7 @@ import time import remotehost import logging logger = logging.getLogger() +import hostapd def get_ifnames(): ifnames = [] @@ -224,3 +225,20 @@ def start_monitor(ifname, freq=2412): def stop_monitor(ifname): subprocess.call(["ip", "link", "set", "dev", ifname, "down"]) subprocess.call(["iw", ifname, "set", "type", "managed"]) + +def clear_scan_cache(apdev): + ifname = apdev['ifname'] + hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'up']) + hostapd.cmd_execute(apdev, ['iw', ifname, 'scan', 'trigger', 'freq', '2412', + 'flush']) + time.sleep(0.1) + hostapd.cmd_execute(apdev, ['ifconfig', ifname, 'down']) + +def set_world_reg(apdev0=None, apdev1=None, dev0=None): + if apdev0: + hostapd.cmd_execute(apdev0, ['iw', 'reg', 'set', '00']) + if apdev1: + hostapd.cmd_execute(apdev1, ['iw', 'reg', 'set', '00']) + if dev0: + dev0.cmd_execute(['iw', 'reg', 'set', '00']) + time.sleep(0.1)