diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 1cb86b74e..fd81b025a 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -252,13 +252,13 @@ def main(): # read the modules from the modules file if args.mfile: - args.testmodules = [] - with open(args.mfile) as f: - for line in f.readlines(): - line = line.strip() - if not line or line.startswith('#'): - continue - args.testmodules.append(line) + args.testmodules = [] + with open(args.mfile) as f: + for line in f.readlines(): + line = line.strip() + if not line or line.startswith('#'): + continue + args.testmodules.append(line) tests_to_run = [] if args.tests: diff --git a/tests/hwsim/test_ap_roam.py b/tests/hwsim/test_ap_roam.py index 1bf6802c4..4456384eb 100644 --- a/tests/hwsim/test_ap_roam.py +++ b/tests/hwsim/test_ap_roam.py @@ -74,7 +74,7 @@ def test_ap_roam_wpa2_psk_failed(dev, apdev, params): raise Exception("ROAM failed") ev = dev[0].wait_event(["CTRL-EVENT-SSID-TEMP-DISABLED", - "CTRL-EVENT-CONNECTED"], 5) + "CTRL-EVENT-CONNECTED"], 5) if "CTRL-EVENT-CONNECTED" in ev: raise Exception("Got unexpected CTRL-EVENT-CONNECTED") if "CTRL-EVENT-SSID-TEMP-DISABLED" not in ev: diff --git a/tests/hwsim/test_mbo.py b/tests/hwsim/test_mbo.py index 0c3d0dcf2..f0e8c9650 100644 --- a/tests/hwsim/test_mbo.py +++ b/tests/hwsim/test_mbo.py @@ -19,21 +19,21 @@ def test_mbo_assoc_disallow(dev, apdev, params): logger.debug("Set mbo_assoc_disallow with invalid value") if "FAIL" not in hapd1.request("SET mbo_assoc_disallow 2"): - raise Exception("Set mbo_assoc_disallow for AP1 succeeded unexpectedly with value 2") + raise Exception("Set mbo_assoc_disallow for AP1 succeeded unexpectedly with value 2") logger.debug("Disallow associations to AP1 and allow association to AP2") if "OK" not in hapd1.request("SET mbo_assoc_disallow 1"): - raise Exception("Failed to set mbo_assoc_disallow for AP1") + raise Exception("Failed to set mbo_assoc_disallow for AP1") if "OK" not in hapd2.request("SET mbo_assoc_disallow 0"): - raise Exception("Failed to set mbo_assoc_disallow for AP2") + raise Exception("Failed to set mbo_assoc_disallow for AP2") dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412") out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), - "wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00", + "wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00", wait=False) if "Destination address: " + hapd1.own_addr() in out: - raise Exception("Association request sent to disallowed AP") + raise Exception("Association request sent to disallowed AP") timestamp = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), "wlan.fc.type_subtype == 0x00", @@ -41,9 +41,9 @@ def test_mbo_assoc_disallow(dev, apdev, params): logger.debug("Allow associations to AP1 and disallow assications to AP2") if "OK" not in hapd1.request("SET mbo_assoc_disallow 0"): - raise Exception("Failed to set mbo_assoc_disallow for AP1") + raise Exception("Failed to set mbo_assoc_disallow for AP1") if "OK" not in hapd2.request("SET mbo_assoc_disallow 1"): - raise Exception("Failed to set mbo_assoc_disallow for AP2") + raise Exception("Failed to set mbo_assoc_disallow for AP2") dev[0].request("DISCONNECT") dev[0].wait_disconnected() @@ -57,7 +57,7 @@ def test_mbo_assoc_disallow(dev, apdev, params): out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), filter, wait=False) if "Destination address: " + hapd2.own_addr() in out: - raise Exception("Association request sent to disallowed AP 2") + raise Exception("Association request sent to disallowed AP 2") def test_mbo_cell_capa_update(dev, apdev): """MBO cellular data capability update""" @@ -66,7 +66,7 @@ def test_mbo_cell_capa_update(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] if "OK" not in dev[0].request("SET mbo_cell_capa 1"): - raise Exception("Failed to set STA as cellular data capable") + raise Exception("Failed to set STA as cellular data capable") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") @@ -76,7 +76,7 @@ def test_mbo_cell_capa_update(dev, apdev): raise Exception("mbo_cell_capa missing after association") if "OK" not in dev[0].request("SET mbo_cell_capa 3"): - raise Exception("Failed to set STA as cellular data not-capable") + raise Exception("Failed to set STA as cellular data not-capable") time.sleep(0.2) sta = hapd.get_sta(addr) @@ -96,7 +96,7 @@ def test_mbo_cell_capa_update_pmf(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] if "OK" not in dev[0].request("SET mbo_cell_capa 1"): - raise Exception("Failed to set STA as cellular data capable") + raise Exception("Failed to set STA as cellular data capable") dev[0].connect(ssid, psk=passphrase, key_mgmt="WPA-PSK-SHA256", proto="WPA2", ieee80211w="2", scan_freq="2412") @@ -107,7 +107,7 @@ def test_mbo_cell_capa_update_pmf(dev, apdev): raise Exception("mbo_cell_capa missing after association") if "OK" not in dev[0].request("SET mbo_cell_capa 3"): - raise Exception("Failed to set STA as cellular data not-capable") + raise Exception("Failed to set STA as cellular data not-capable") time.sleep(0.2) sta = hapd.get_sta(addr) @@ -123,9 +123,9 @@ def test_mbo_non_pref_chan(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] if "OK" not in dev[0].request("SET non_pref_chan 81:7:200:3"): - raise Exception("Failed to set non-preferred channel list") + raise Exception("Failed to set non-preferred channel list") if "OK" not in dev[0].request("SET non_pref_chan 81:7:200:1:123 81:9:100:2"): - raise Exception("Failed to set non-preferred channel list") + raise Exception("Failed to set non-preferred channel list") dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412") diff --git a/tests/hwsim/test_p2ps.py b/tests/hwsim/test_p2ps.py index 0d475755a..ad2382ce1 100644 --- a/tests/hwsim/test_p2ps.py +++ b/tests/hwsim/test_p2ps.py @@ -393,8 +393,8 @@ def p2ps_connect_pd(dev0, dev1, ev0, ev1, pin=None, join_extra="", go_ev=None): def set_no_group_iface(dev, enable): if enable: res = dev.get_driver_status() - if (int(res['capa.flags'], 0) & 0x20000000): - raise HwsimSkip("P2P Device used. Cannot set enable no_group_iface") + if (int(res['capa.flags'], 0) & 0x20000000): + raise HwsimSkip("P2P Device used. Cannot set enable no_group_iface") dev.global_request("SET p2p_no_group_iface 1") else: dev.global_request("SET p2p_no_group_iface 0") diff --git a/tests/hwsim/test_rfkill.py b/tests/hwsim/test_rfkill.py index 3b0aa6cce..d13753107 100644 --- a/tests/hwsim/test_rfkill.py +++ b/tests/hwsim/test_rfkill.py @@ -135,11 +135,11 @@ def _test_rfkill_p2p_discovery(dev0, dev1): if dev0.get_status_field("wpa_state") == "INTERFACE_DISABLED" and dev1.get_status_field("wpa_state") == "INTERFACE_DISABLED": break - if "OK" in dev0.p2p_listen(): - raise Exception("P2P Listen success although in rfkill") + if "OK" in dev0.p2p_listen(): + raise Exception("P2P Listen success although in rfkill") - if "OK" in dev1.p2p_find(): - raise Exception("P2P Find success although in rfkill") + if "OK" in dev1.p2p_find(): + raise Exception("P2P Find success although in rfkill") dev0.dump_monitor() dev1.dump_monitor() @@ -154,11 +154,11 @@ def _test_rfkill_p2p_discovery(dev0, dev1): if dev0.get_status_field("wpa_state") != "INTERFACE_DISABLED" and dev1.get_status_field("wpa_state") != "INTERFACE_DISABLED": break - if not "OK" in dev0.p2p_listen(): - raise Exception("P2P Listen failed after unblocking rfkill") + if not "OK" in dev0.p2p_listen(): + raise Exception("P2P Listen failed after unblocking rfkill") - if not dev1.discover_peer(addr0, social=True): - raise Exception("Failed to discover peer after unblocking rfkill") + if not dev1.discover_peer(addr0, social=True): + raise Exception("Failed to discover peer after unblocking rfkill") finally: rfk0.unblock() @@ -177,8 +177,8 @@ def test_rfkill_p2p_discovery_p2p_dev(dev, apdev): with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) - _test_rfkill_p2p_discovery(dev[0], wpas) - _test_rfkill_p2p_discovery(wpas, dev[1]) + _test_rfkill_p2p_discovery(dev[0], wpas) + _test_rfkill_p2p_discovery(wpas, dev[1]) def test_rfkill_hostapd(dev, apdev): """rfkill block/unblock during and prior to hostapd operations""" diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index c1f08fcce..804811314 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -1204,57 +1204,57 @@ def test_wnm_bss_tm_req_with_mbo_ie(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] if "OK" not in dev[0].request("SET mbo_cell_capa 1"): - raise Exception("Failed to set STA as cellular data capable") + raise Exception("Failed to set STA as cellular data capable") dev[0].connect(ssid, psk="12345678", key_mgmt="WPA-PSK", proto="WPA2", ieee80211w="0", scan_freq="2412") logger.debug("BTM request with MBO reassociation delay when disassoc imminent is not set") if 'FAIL' not in hapd.request("BSS_TM_REQ " + dev[0].own_addr() + " mbo=3:2:1"): - raise Exception("BSS transition management succeeded unexpectedly") + raise Exception("BSS transition management succeeded unexpectedly") logger.debug("BTM request with invalid MBO transition reason code") if 'FAIL' not in hapd.request("BSS_TM_REQ " + dev[0].own_addr() + " mbo=10:2:1"): - raise Exception("BSS transition management succeeded unexpectedly") + raise Exception("BSS transition management succeeded unexpectedly") logger.debug("BTM request with MBO reassociation retry delay of 5 seconds") if 'OK' not in hapd.request("BSS_TM_REQ " + dev[0].own_addr() + " disassoc_imminent=1 disassoc_timer=3 mbo=3:5:1"): - raise Exception("BSS transition management command failed") + raise Exception("BSS transition management command failed") ev = dev[0].wait_event(['MBO-CELL-PREFERENCE'], 1) if ev is None or "preference=1" not in ev: - raise Exception("Timeout waiting for MBO-CELL-PREFERENCE event") + raise Exception("Timeout waiting for MBO-CELL-PREFERENCE event") ev = dev[0].wait_event(['MBO-TRANSITION-REASON'], 1) if ev is None or "reason=3" not in ev: - raise Exception("Timeout waiting for MBO-TRANSITION-REASON event") + raise Exception("Timeout waiting for MBO-TRANSITION-REASON event") ev = hapd.wait_event(['BSS-TM-RESP'], timeout=10) if ev is None: - raise Exception("No BSS Transition Management Response") + raise Exception("No BSS Transition Management Response") if dev[0].own_addr() not in ev: - raise Exception("Unexpected BSS Transition Management Response address") + raise Exception("Unexpected BSS Transition Management Response address") ev = dev[0].wait_event(['CTRL-EVENT-DISCONNECTED'], 5) if ev is None: - raise Exception("Station did not disconnect although disassoc imminent was set") + raise Exception("Station did not disconnect although disassoc imminent was set") # Set the scan interval to make dev[0] look for connections if 'OK' not in dev[0].request("SCAN_INTERVAL 1"): - raise Exception("Failed to set scan interval") + raise Exception("Failed to set scan interval") # Make sure no connection is made during the retry delay ev = dev[0].wait_event(['CTRL-EVENT-CONNECTED'], 5) if ev is not None: - raise Exception("Station connected before assoc retry delay was over") + raise Exception("Station connected before assoc retry delay was over") # After the assoc retry delay is over, we can reconnect ev = dev[0].wait_event(['CTRL-EVENT-CONNECTED'], 5) if ev is None: - raise Exception("Station did not connect after assoc retry delay is over") + raise Exception("Station did not connect after assoc retry delay is over") if "OK" not in dev[0].request("SET mbo_cell_capa 3"): - raise Exception("Failed to set STA as cellular data not-capable") + raise Exception("Failed to set STA as cellular data not-capable") def test_wnm_bss_transition_mgmt_query(dev, apdev): """WNM BSS Transition Management query""" diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index eec21a889..4894fa13b 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -449,8 +449,8 @@ class WpaSupplicant: return None def get_mcc(self): - mcc = int(self.get_driver_status_field('capa.num_multichan_concurrent')) - return 1 if mcc < 2 else mcc + mcc = int(self.get_driver_status_field('capa.num_multichan_concurrent')) + return 1 if mcc < 2 else mcc def get_mib(self): res = self.request("MIB") @@ -1102,7 +1102,7 @@ class WpaSupplicant: return res.split(' ') def get_bss(self, bssid, ifname=None): - if not ifname or ifname == self.ifname: + if not ifname or ifname == self.ifname: res = self.request("BSS " + bssid) elif ifname == self.group_ifname: res = self.group_request("BSS " + bssid) @@ -1220,8 +1220,8 @@ class WpaSupplicant: cmd = "P2P_ASP_PROVISION_RESP" params = "status=%d" % status - if role is not None: - params += " role=" + role + if role is not None: + params += " role=" + role if cpt is not None: params += " cpt=" + cpt