# 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:
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:
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",
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()
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"""
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")
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)
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")
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)
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")
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")
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()
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()
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"""
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"""
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")
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)
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