with open(testfile, "w") as f:
f.write("ff:ff:ff:ff:ff:ff")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("No disconnection after two Michael MIC failures")
+ ev = dev[0].wait_disconnected(timeout=10,
+ error="No disconnection after two Michael MIC failures")
if "reason=14" not in ev:
raise Exception("Unexpected disconnection reason: " + ev)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
with open(testfile, "w") as f:
f.write("ff:ff:ff:ff:ff:ff")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("No disconnection after two Michael MIC failures")
+ ev = dev[0].wait_disconnected(timeout=10,
+ error="No disconnection after two Michael MIC failures")
if "reason=14 locally_generated=1" not in ev:
raise Exception("Unexpected disconnection reason: " + ev)
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
ev = hapd.wait_event(["AP-DISABLED"], timeout=30)
if ev is None:
raise Exception("AP disabling timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("STA disconnect event timed out")
+ dev[0].wait_disconnected(timeout=10)
hapd.enable()
ev = hapd.wait_event(["AP-ENABLED"], timeout=30)
if ev is None:
raise Exception("AP startup timed out")
dev[1].connect("dynamic", key_mgmt="NONE", scan_freq="2412")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("STA connect event timed out")
+ dev[0].wait_connected(timeout=10)
def test_ap_double_disable(dev, apdev):
"""Double DISABLE regression test"""
ev = dev.wait_event(["CTRL-EVENT-EAP-FAILURE"])
if ev is None:
raise Exception("EAP failure timed out")
- ev = dev.wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Disconnection timed out")
+ ev = dev.wait_disconnected(timeout=10)
if not local_error_report:
if "reason=23" not in ev:
raise Exception("Proper reason code for disconnection not reported")
identity="6555444333222111@both",
password="5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123",
wait_connect=False, scan_freq="2412")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection with the AP timed out")
+ dev[1].wait_connected(timeout=15)
logger.info("Negative test with incorrect key")
dev[0].request("REMOVE_NETWORK all")
raise Exception("Request for private key passphrase timed out")
id = ev.split(':')[0].split('-')[-1]
dev[0].request("CTRL-RSP-PASSPHRASE-" + id + ":whatever")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=10)
def test_ap_wpa2_eap_tls_pkcs12_blob(dev, apdev):
"""WPA2-Enterprise connection using EAP-TLS and PKCS#12 from configuration blob"""
if ev is None:
raise Exception("EAP-TTLS not re-started")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ ev = dev[0].wait_disconnected(timeout=15)
if "reason=23" not in ev:
raise Exception("Proper reason code for disconnection not reported")
if ev is None:
raise Exception("EAP-TTLS not re-started")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ ev = dev[0].wait_disconnected(timeout=15)
if "reason=23" not in ev:
raise Exception("Proper reason code for disconnection not reported")
if ev is None:
raise Exception("EAP-TTLS not re-started")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ ev = dev[0].wait_disconnected(timeout=15)
if "reason=23" not in ev:
raise Exception("Proper reason code for disconnection not reported")
raise Exception("EAP result timed out")
if "Server certificate chain probe" not in ev:
raise Exception("Server certificate probe not reported")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection event not seen")
+ dev[0].wait_disconnected(timeout=10)
dev[0].request("REMOVE_NETWORK all")
dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", eap="TTLS",
raise Exception("EAP result timed out")
if "Server certificate mismatch" not in ev:
raise Exception("Server certificate mismatch not reported")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection event not seen")
+ dev[0].wait_disconnected(timeout=10)
dev[0].request("REMOVE_NETWORK all")
eap_connect(dev[0], apdev[0], "TTLS", "DOMAIN\mschapv2 user",
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=10)
logger.info("Test failed algorithm negotiation")
dev[0].set_network_quoted(id, "phase1", "cipher=9")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=10)
logger.info("Test failed algorithm negotiation")
dev[0].set_network_quoted(id, "phase1", "dhgroup=9 encr=9 prf=9 mac=9")
id = ev.split(':')[0].split('-')[-1]
type = "OTP" if "CTRL-REQ-OTP" in ev else "PASSWORD"
dev[0].request("CTRL-RSP-" + type + "-" + id + ":" + req_pw)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=10)
dev[0].request("REMOVE_NETWORK all")
def test_ap_wpa2_eap_vendor_test(dev, apdev):
def check_auto_select(dev, bssid):
dev.scan_for_bss(bssid, freq="2412")
dev.request("INTERWORKING_SELECT auto freq=2412")
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev.wait_connected(timeout=15)
if bssid not in ev:
raise Exception("Connected to incorrect network")
dev.request("REMOVE_NETWORK all")
resp = res.split(' ')[2].rstrip()
dev.request("CTRL-RSP-SIM-" + id + ":GSM-AUTH:" + resp)
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ dev.wait_connected(timeout=15)
def interworking_connect(dev, bssid, method):
dev.request("INTERWORKING_CONNECT " + bssid)
if "(" + method + ")" not in ev:
raise Exception("Unexpected EAP method selection")
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ dev.wait_connected(timeout=15)
def check_probe_resp(wt, bssid_unexpected, bssid_expected):
if bssid_unexpected:
'domain': "example.com",
'update_identifier': "1234" })
dev[0].request("REASSOCIATE")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=15)
check_sp_type(dev[0], "home")
status = dev[0].get_status()
if status['pairwise_cipher'] != "CCMP":
raise Exception("Selected incorrect BSS")
break
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev.wait_connected(timeout=15)
if bssid and bssid not in ev:
raise Exception("Connected to incorrect BSS")
if "1 120 http://example.com/" not in ev:
raise Exception("Unexpected deauth imminent notice: " + ev)
hapd.request("DEAUTHENTICATE " + addr)
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection")
+ dev[0].wait_disconnected(timeout=10)
if "[TEMP-DISABLED]" not in dev[0].list_networks()[0]['flags']:
raise Exception("Network not marked temporarily disabled")
ev = dev[0].wait_event(["SME: Trying to authenticate",
if "0 120 http://example.com/" not in ev:
raise Exception("Unexpected deauth imminent notice: " + ev)
hapd.request("DEAUTHENTICATE " + addr + " reason=4")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection")
+ ev = dev[0].wait_disconnected(timeout=10)
if "reason=4" not in ev:
raise Exception("Unexpected disconnection reason")
if "[TEMP-DISABLED]" not in dev[0].list_networks()[0]['flags']:
raise Exception("Timeout on deauth imminent notice")
if " 1 100" not in ev:
raise Exception("Unexpected deauth imminent contents")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=3)
- if ev is None:
- raise Exception("Timeout on disconnection")
+ dev[0].wait_disconnected(timeout=3)
def test_ap_hs20_remediation_required(dev, apdev):
"""Hotspot 2.0 connection and remediation required from RADIUS"""
dev[0].scan_for_bss(bssid, freq="2412")
dev[0].request("INTERWORKING_SELECT auto freq=2412")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev[0].wait_connected(timeout=15)
if bssid not in ev:
raise Exception("Unexpected network selected")
dev[0].scan_for_bss(bssid2, freq="2412")
dev[0].request("INTERWORKING_SELECT auto freq=2412")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev[0].wait_connected(timeout=15)
if bssid2 not in ev:
raise Exception("Unexpected network selected")
dev[0].scan_for_bss(bssid, freq="2412")
dev[0].scan_for_bss(bssid2, freq="2412")
dev[0].request("INTERWORKING_SELECT auto freq=2412")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev[0].wait_connected(timeout=15)
if bssid not in ev:
raise Exception("Unexpected network selected")
dev[0].scan_for_bss(bssid, freq="2412")
dev[0].scan_for_bss(bssid2, freq="2412")
dev[0].request("INTERWORKING_SELECT auto freq=2412")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Connection timed out")
+ ev = dev[0].wait_connected(timeout=15)
if bssid not in ev:
raise Exception("Unexpected network selected")
dev[0].add_network()
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection")
+ dev[0].wait_disconnected(timeout=10)
hapd.disable()
hapd.set("ssid", "another ssid")
dev[0].remove_cred(id)
if len(dev[0].list_networks()) != 3:
raise Exception("Unexpected number of networks after to remove_crec")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection")
+ dev[0].wait_disconnected(timeout=10)
def _test_ap_hs20_proxyarp(dev, apdev):
bssid = apdev[0]['bssid']
dev[i].connect("open", key_mgmt="NONE", scan_freq="2412",
wait_connect=False)
for i in range(0, 3):
- ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[i].wait_connected(timeout=20)
def test_ap_open_unknown_action(dev, apdev):
"""AP with open mode configuration and unknown Action frame"""
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
hapd.request("DEAUTHENTICATE " + dev[0].p2p_interface_addr() + " reason=4")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Timeout on disconnection")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=2)
- if ev is None:
- raise Exception("Timeout on reconnection")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=2, error="Timeout on reconnection")
def test_ap_open_assoc_timeout(dev, apdev):
"""AP timing out association"""
if assoc != 3:
raise Exception("Association Request frames not received: assoc=%d" % assoc)
hapd.set("ext_mgmt_frame_handling", "0")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Timeout on connection")
+ dev[0].wait_connected(timeout=15)
def test_ap_open_id_str(dev, apdev):
"""AP with open mode and id_str"""
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", id_str="foo",
wait_connect=False)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Association with the AP timed out")
+ ev = dev[0].wait_connected(timeout=10)
if "id_str=foo" not in ev:
raise Exception("CTRL-EVENT-CONNECT did not have matching id_str: " + ev)
if dev[0].get_status_field("id_str") != "foo":
raise Exception("Unexpected connection")
dev[0].select_network("any")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=10)
def test_ap_open_unexpected_assoc_event(dev, apdev):
"""AP with open mode and unexpected association event"""
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
dev[0].request("DISCONNECT")
- dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
+ dev[0].wait_disconnected(timeout=15)
dev[0].dump_monitor()
# This will be accepted due to matching network
subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
apdev[0]['bssid']])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
dev[0].dump_monitor()
dev[0].request("REMOVE_NETWORK all")
- dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
+ dev[0].wait_disconnected(timeout=5)
dev[0].dump_monitor()
# This will result in disconnection due to no matching network
subprocess.call(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412",
apdev[0]['bssid']])
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection with the AP timed out")
+ dev[0].wait_disconnected(timeout=15)
def test_ap_bss_load(dev, apdev):
"""AP with open mode (no security) configuration"""
scan_freq="2412")
hapd.set("ext_mgmt_frame_handling", "1")
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection")
+ dev[0].wait_disconnected(timeout=10)
hapd.set("ext_mgmt_frame_handling", "0")
dev[0].request("REASSOCIATE")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout on re-connection")
+ dev[0].wait_connected(timeout=10, error="Timeout on re-connection")
if wt.get_sta_counter("assocresp_comeback", apdev[0]['bssid'],
dev[0].p2p_interface_addr()) < 1:
raise Exception("AP did not use association comeback request")
if "OK" not in dev[0].request("DROP_SA"):
raise Exception("DROP_SA failed")
dev[0].request("REASSOCIATE")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout on re-connection")
+ dev[0].wait_connected(timeout=10, error="Timeout on re-connection")
if wt.get_sta_counter("reassocresp_comeback", apdev[0]['bssid'],
dev[0].p2p_interface_addr()) < 1:
raise Exception("AP did not use reassociation comeback request")
if ev is None:
raise Exception("Timeout on EAPOL-TX from hostapd")
if "AP-STA-CONNECTED" in ev:
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Timeout on connection event from wpa_supplicant")
+ dev[0].wait_connected(timeout=15)
break
res = dev[0].request("EAPOL_RX " + bssid + " " + ev.split(' ')[2])
if "OK" not in res:
dev[0].connect("test-open", key_mgmt="NONE")
dev[0].request("REASSOCIATE")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Reassociation with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Reassociation timed out")
hwsim_utils.test_connectivity(dev[0], hapd)
dev[0].request("REATTACH")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Reassociation (reattach) with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Reattach timed out")
hwsim_utils.test_connectivity(dev[0], hapd)
def test_ap_roam_set_bssid(dev, apdev):
dev[0].request("ENABLE_NETWORK %s no-connect" % id)
dev[0].request("WPS_PBC")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
raise Exception("Not fully connected")
raise Exception("WPS cred event not seen")
if "100e" not in ev:
raise Exception("WPS attributes not included in the cred event")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True)
dev[1].scan_for_bss(apdev[1]['bssid'], freq="2412")
raise Exception("WPS-AUTH flag missing from AP2")
dev[0].dump_monitor()
dev[0].request("WPS_PIN any " + pin)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True)
dev[1].scan_for_bss(apdev[1]['bssid'], freq="2412")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected")
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="5180")
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
sta = hapd.get_sta(dev[0].p2p_interface_addr())
if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
logger.info("WPS provisioning step")
hapd.request("WPS_PBC")
dev[0].request("WPS_PBC")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
sta = hapd.get_sta(dev[0].p2p_interface_addr())
if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A":
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
dev[0].request("DISCONNECT")
logger.info("Restart AP with different passphrase and re-run WPS")
hapd.request("WPS_PBC")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
networks = dev[0].list_networks()
if len(networks) > 1:
raise Exception("Unexpected duplicated network block present")
raise Exception("Incorrect config_error reported")
if "msg=8" not in ev:
raise Exception("PIN error detected on incorrect message")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection event")
+ dev[0].wait_disconnected(timeout=10)
dev[0].request("WPS_CANCEL")
# if a scan was in progress, wait for it to complete before trying WPS again
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 5)
raise Exception("Incorrect config_error reported")
if "msg=10" not in ev:
raise Exception("PIN error detected on incorrect message")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection event")
+ dev[0].wait_disconnected(timeout=10)
def test_ap_wps_conf_pin(dev, apdev):
"""WPS PIN provisioning with configured AP"""
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].dump_monitor()
dev[0].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
raise Exception("Not fully connected")
if "WPS-M2D" not in ev:
raise Exception("Unexpected WPS operation started")
hapd.request("WPS_PIN any " + pin)
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=30)
def test_ap_wps_conf_pin_v1(dev, apdev):
"""WPS PIN provisioning with configured WPS v1.0 AP"""
raise Exception("WPS-PIN flag not seen in scan results")
dev[0].dump_monitor()
dev[0].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
+ dev[0].wait_connected(timeout=30)
hapd.request("SET wps_version_number 0x20")
- if ev is None:
- raise Exception("Association with the AP timed out")
def test_ap_wps_conf_pin_2sta(dev, apdev):
"""Two stations trying to use WPS PIN at the same time"""
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
dev[1].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
+ dev[1].wait_connected(timeout=30)
def test_ap_wps_conf_pin_timeout(dev, apdev):
"""WPS PIN provisioning with configured AP timing out PIN"""
hapd.request("WPS_PIN any " + pin + " 20 " + addr)
dev[0].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
def test_ap_wps_reg_connect(dev, apdev):
"""WPS registrar using AP PIN to connect"""
dev[1].wps_reg(apdev[0]['bssid'], appin)
dev[0].request("REMOVE_NETWORK all")
dev[1].request("REMOVE_NETWORK all")
- dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
+ dev[0].wait_disconnected(timeout=10)
+ dev[1].wait_disconnected(timeout=10)
logger.info("WPS provisioning step after AP PIN timeout")
hapd.request("WPS_AP_PIN disable")
hapd.request("SET wps_cred_processing 0")
if "FAIL" in hapd.request("WPS_CONFIG " + new_ssid.encode("hex") + " WPA2PSK CCMP " + new_passphrase.encode("hex")):
raise Exception("WPS_CONFIG command failed")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
def test_ap_wps_reg_config_tkip(dev, apdev):
"""WPS registrar configuring AP to use TKIP and AP upgrading to TKIP+CCMP"""
ap_setup_locked=True
elif "config_error=18" not in ev:
raise Exception("config_error=18 not reported")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection event")
+ dev[0].wait_disconnected(timeout=10)
time.sleep(0.1)
if not ap_setup_locked:
raise Exception("AP setup was not locked")
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=30)
if ev is None:
raise Exception("WPS success was not reported")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
appin = hapd.request("WPS_AP_PIN random")
if "FAIL" in appin:
break
elif "config_error=18" not in ev:
raise Exception("config_error=18 not reported")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on disconnection event")
+ dev[0].wait_disconnected(timeout=10)
time.sleep(0.1)
if not ap_setup_locked:
raise Exception("AP setup was not locked")
ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30)
if ev is None:
raise Exception("Enrollee did not report success")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=15)
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS ER did not report success")
if addr2 not in ev:
raise Exception("Unexpected Enrollee MAC address")
dev[0].request("WPS_ER_PIN " + addr2 + " " + pin + " " + addr2)
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[2].wait_connected(timeout=30)
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS ER did not report success")
logger.info("Verify registrar selection behavior")
dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr())
dev[1].request("DISCONNECT")
- dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
+ dev[1].wait_disconnected(timeout=10)
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[1].scan(freq="2412")
bss = dev[1].get_bss(apdev[0]['bssid'])
ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("Enrollee did not report success")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=15)
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS ER did not report success")
dev[1].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[1].dump_monitor()
dev[1].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=30)
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS ER did not report success")
ev = dev[0].wait_event(["WPS-SUCCESS"])
if ev is None:
raise Exception("WPS ER configuration operation timed out")
- dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
+ dev[0].wait_disconnected(timeout=10)
dev[0].connect(ssid, psk="1234567890", scan_freq="2412")
logger.info("WPS ER restart")
dev[0].dump_monitor()
dev[0].request("SET wps_fragment_size 50")
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected")
dev[1].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[1].request("SET wps_fragment_size 50")
dev[1].request("WPS_PIN %s %s" % (apdev[0]['bssid'], pin))
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=30)
status = dev[1].get_status()
if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected")
dev[0].request("SET wps_version_number 0x43")
dev[0].request("SET wps_vendor_ext_m1 000137100100020001")
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
def test_ap_wps_new_version_ap(dev, apdev):
"""WPS compatibility with new version number on the AP"""
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
+ dev[0].wait_connected(timeout=30)
hapd.request("SET wps_version_number 0x20")
- if ev is None:
- raise Exception("Association with the AP timed out")
def test_ap_wps_check_pin(dev, apdev):
"""Verify PIN checking through control interface"""
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
bss = dev[0].get_bss(apdev[0]['bssid'])
if "wps_device_name" not in bss or bss['wps_device_name'] != "1234567890abcdef1234567890abcdef":
logger.info("Device Name not received correctly")
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out (1)")
+ dev[0].wait_connected(timeout=30)
logger.info("Second enrollee")
hapd.request("WPS_PBC")
dev[1].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[1].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out (2)")
+ dev[1].wait_connected(timeout=30)
logger.info("External registrar")
dev[2].scan_for_bss(apdev[0]['bssid'], freq=2412)
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out (1)")
+ dev[0].wait_connected(timeout=30)
logger.info("Second enrollee")
hapd.request("WPS_PBC")
dev[1].scan_for_bss(apdev[0]['bssid'], freq=2412)
dev[1].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out (2)")
+ dev[1].wait_connected(timeout=30)
logger.info("External registrar")
dev[2].scan_for_bss(apdev[0]['bssid'], freq=2412)
hapd.request("WPS_PBC")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
with open(conffile, "r") as f:
lines = f.read().splitlines()
vals = dict()
hapd.request("WPS_PBC")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['bssid'] != apdev[0]['bssid']:
raise Exception("Unexpected BSSID")
hapd.request("WPS_PBC")
dev[0].dump_monitor()
dev[0].request("WPS_PBC " + apdev[0]['bssid'])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
status = dev[0].get_status()
if status['bssid'] != apdev[0]['bssid']:
raise Exception("Unexpected BSSID")
if vals[5] != '4':
raise Exception("Unexpected Device Password Id: " + vals[5])
hapd.request("WPS_PBC")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
def test_ap_wps_ap_scan_2(dev, apdev):
"""AP_SCAN 2 for WPS"""
ev = wpas.wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS-SUCCESS event timed out")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ wpas.wait_connected(timeout=30)
wpas.request("DISCONNECT")
wpas.request("BSS_FLUSH 0")
wpas.dump_monitor()
wpas.request("REASSOCIATE")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ wpas.wait_connected(timeout=30)
attrs += build_nl80211_attr_mac('MAC', apdev[0]['bssid'])
attrs += build_nl80211_attr_flag('LOCAL_STATE_CHANGE')
nl80211_command(dev[0], 'DEAUTHENTICATE', attrs)
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Local-deauth timed out")
+ dev[0].wait_disconnected(timeout=5, error="Local-deauth timed out")
# the previous command results in deauth event followed by auto-reconnect
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Reassociation with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Reassociation timed out")
hwsim_utils.test_connectivity(dev[0], hapd)
erp="1", scan_freq="2412")
for i in range(3):
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ dev[0].wait_disconnected(timeout=15)
dev[0].request("RECONNECT")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
if ev is None:
raise Exception("EAP success timed out")
if "EAP re-authentication completed successfully" not in ev:
raise Exception("Did not use ERP")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def test_erp_server_no_match(dev, apdev):
"""ERP enabled on server and peer, but server has no key match"""
password_hex="0123456789abcdef0123456789abcdef",
erp="1", scan_freq="2412")
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ dev[0].wait_disconnected(timeout=15)
hapd.request("ERP_FLUSH")
dev[0].request("RECONNECT")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS",
raise Exception("EAP success timed out")
if "EAP re-authentication completed successfully" in ev:
raise Exception("Unexpected use of ERP")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def start_erp_as(apdev):
params = { "ssid": "as", "beacon_int": "2000",
erp="1", scan_freq="2412")
for i in range(3):
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ dev[0].wait_disconnected(timeout=15)
dev[0].request("RECONNECT")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
if ev is None:
raise Exception("EAP success timed out")
if "EAP re-authentication completed successfully" not in ev:
raise Exception("Did not use ERP")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def erp_test(dev, hapd, **kwargs):
hapd.dump_monitor()
id = dev.connect("test-wpa2-eap", key_mgmt="WPA-EAP", erp="1",
scan_freq="2412", **kwargs)
dev.request("DISCONNECT")
- ev = dev.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Disconnection timed out")
+ dev.wait_disconnected(timeout=15)
hapd.dump_monitor()
dev.request("RECONNECT")
ev = dev.wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
raise Exception("EAP success timed out")
if "EAP re-authentication completed successfully" not in ev:
raise Exception("Did not use ERP")
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev.wait_connected(timeout=15, error="Reconnection timed out")
ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
if ev is None:
raise Exception("No connection event received from hostapd")
get_gas_response(dev[0], bssid, ev)
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection timed out")
+ dev[0].wait_disconnected(timeout=5)
logger.debug("Wait six seconds for expiration of connect-without-scan")
time.sleep(6)
if ev is None:
raise Exception("No new scan results reported")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Operation timed out")
+ ev = dev[0].wait_connected(timeout=20, error="Operation tiemd out")
if "CTRL-EVENT-CONNECTED" not in ev:
raise Exception("Unexpected operation order")
addr = dev[0].p2p_dev_addr()
if "OK" not in hapd.request("DEAUTHENTICATE " + addr + " p2p=2"):
raise Exception("DEAUTHENTICATE command failed")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Re-connection timed out")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
if "OK" not in hapd.request("DISASSOCIATE " + addr + " p2p=2"):
raise Exception("DISASSOCIATE command failed")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Re-connection timed out")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
def test_hapd_ctrl_sta(dev, apdev):
"""hostapd and STA ctrl_iface commands"""
if "OK" not in hapd.request("DEAUTHENTICATE ff:ff:ff:ff:ff:ff"):
raise Exception("Unexpected DEAUTHENTICATE failure")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Re-connection timed out")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
if "FAIL" not in hapd.request("DISASSOCIATE 00:11:22:33:44"):
raise Exception("Unexpected DISASSOCIATE success")
if "OK" not in hapd.request("DISASSOCIATE ff:ff:ff:ff:ff:ff"):
raise Exception("Unexpected DISASSOCIATE failure")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Re-connection timed out")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
def test_hapd_ctrl_chan_switch(dev, apdev):
"""hostapd and CHAN_SWITCH ctrl_iface command"""
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
if "OK" not in hapd.request("SET deny_mac_file hostapd.macaddr"):
raise Exception("Unexpected SET failure")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], 15)
- if ev is None:
- raise Exception("Disconnection timeout")
+ dev[0].wait_disconnected(timeout=15)
ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
if ev is not None:
raise Exception("Unexpected disconnection")
hapd.request("SET macaddr_acl 1")
if "OK" not in hapd.request("SET accept_mac_file hostapd.macaddr"):
raise Exception("Unexpected SET failure")
- ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], 15)
- if ev is None:
- raise Exception("Disconnection timeout")
+ dev[1].wait_disconnected(timeout=15)
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], 1)
if ev is not None:
raise Exception("Unexpected disconnection")
def wait_ibss_connection(dev):
logger.info(dev.ifname + " waiting for IBSS start/join to complete")
- ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Connection to the IBSS timed out")
+ ev = dev.wait_connected(timeout=20,
+ error="Connection to the IBSS timed out")
exp = r'<.>(CTRL-EVENT-CONNECTED) - Connection to ([0-9a-f:]*) completed.*'
s = re.split(exp, ev)
if len(s) < 3:
res = dev[1].request("WPS_NFC_TAG_READ " + conf)
if "FAIL" in res:
raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Joining the group timed out")
+ dev[1].wait_connected(timeout=15, error="Joining the group timed out")
hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
dev[1].request("DISCONNECT")
dev[0].remove_group()
res = dev[1].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to wpa_supplicant (legacy STA)")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Joining the group timed out")
+ dev[1].wait_connected(timeout=15, error="Joining the group timed out")
hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
dev[1].request("DISCONNECT")
dev[0].remove_group()
res = dev[0].request("WPS_NFC")
if "FAIL" in res:
raise Exception("Failed to start Enrollee using NFC password token")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_config_token(dev, apdev):
res = dev[0].request("WPS_NFC_TAG_READ " + conf)
if "FAIL" in res:
raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_config_token_init(dev, apdev):
res = dev[0].request("WPS_NFC_TAG_READ " + conf)
if "FAIL" in res:
raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_password_token_sta_init(dev, apdev):
res = dev[0].request("WPS_NFC")
if "FAIL" in res:
raise Exception("Failed to start Enrollee using NFC password token")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_password_token_ap(dev, apdev):
res = dev[0].request("WPS_REG " + apdev[0]['bssid'] + " nfc-pw " + new_ssid.encode("hex") + " WPA2PSK CCMP " + new_passphrase.encode("hex"))
if "FAIL" in res:
raise Exception("Failed to start Registrar using NFC password token")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, new_ssid, mixed=True)
if "FAIL" in hapd.request("WPS_NFC_TOKEN disable"):
raise Exception("Failed to disable AP password token")
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid, mixed=True)
def test_nfc_wps_handover_errors(dev, apdev):
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_handover_5ghz(dev, apdev):
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
finally:
dev[0].request("DISCONNECT")
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
finally:
dev[0].request("DISCONNECT")
res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
check_wpa2_connection(dev[0], apdev[0], hapd, ssid)
def test_nfc_wps_handover_pk_hash_mismatch_sta(dev, apdev):
ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15)
if ev is None:
raise Exception("WPS ER did not report success")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=15)
check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_config_token(dev, apdev):
res = dev[1].request("WPS_NFC_TAG_READ " + conf)
if "FAIL" in res:
raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=15)
check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_handover(dev, apdev):
res = dev[1].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel)
if "FAIL" in res:
raise Exception("Failed to report NFC connection handover to to wpa_supplicant")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=15)
check_wpa2_connection(dev[1], apdev[0], hapd, ssid)
def test_nfc_wps_er_handover_pk_hash_mismatch_sta(dev, apdev):
dev[2].request("P2P_SET disabled 1")
dev[2].dump_monitor()
dev[2].request("WPS_PIN any " + pin)
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the GO timed out")
+ dev[2].wait_connected(timeout=30)
status = dev[2].get_status()
if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected")
dev[2].request("P2P_SET disabled 1")
dev[2].dump_monitor()
dev[2].request("WPS_PIN any " + pin)
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the GO timed out")
+ dev[2].wait_connected(timeout=30)
status = dev[2].get_status()
if status['wpa_state'] != 'COMPLETED':
raise Exception("Not fully connected")
# make group client non-responsive on operating channel
dev[1].dump_monitor()
dev[1].group_request("DISCONNECT")
- ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout on waiting disconnection")
+ dev[1].wait_disconnected(timeout=10)
dev[2].request("P2P_CONNECT {} {} display".format(dev[1].p2p_dev_addr(),
pin))
ev = dev[1].wait_event(["P2P-GO-NEG-REQUEST"], timeout=2)
dev[0].p2p_go_authorize_client_pbc()
dev[2].request("WPS_PBC")
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the GO timed out")
+ dev[2].wait_connected(timeout=30)
hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
raise Exception("P2P_SET discoverability 1 failed")
dev[1].dump_monitor()
dev[1].group_request("REASSOCIATE")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Reassociation with the GO timed out")
+ dev[1].wait_connected(timeout=20)
dev[2].request("P2P_FLUSH")
if not dev[2].discover_peer(addr1, timeout=10):
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Roaming timed out")
pmksa2 = dev[0].get_pmksa(bssid2)
if pmksa2 is None:
raise Exception("No PMKSA cache entry found")
raise Exception("PMKSA_FLUSH failed")
if dev[0].get_pmksa(bssid) is not None or dev[0].get_pmksa(bssid2) is not None:
raise Exception("PMKSA_FLUSH did not remove PMKSA entries")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev[0].wait_disconnected(timeout=5)
+ dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def test_pmksa_cache_opportunistic_only_on_sta(dev, apdev):
"""Opportunistic PMKSA caching enabled only on station"""
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Roaming timed out")
pmksa2 = dev[0].get_pmksa(bssid2)
if pmksa2 is None:
raise Exception("No PMKSA cache entry found")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ dev[0].wait_connected(timeout=10, error="Roaming timed out")
dev[0].dump_monitor()
logger.info("Roam back to AP1")
raise Exception("Roaming with the AP timed out")
if "CTRL-EVENT-CONNECTED" in ev:
raise Exception("EAP exchange missing")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Reassociation with the AP timed out")
+ dev[0].wait_connected(timeout=20, error="Reconnect timed out")
dev[0].dump_monitor()
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Reassociation with the AP timed out")
+ dev[0].wait_disconnected(timeout=20)
+ dev[0].wait_connected(timeout=20, error="Reassociation timed out")
def test_pmksa_cache_multiple_sta(dev, apdev):
"""PMKSA cache with multiple stations"""
ev = sta.wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = sta.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ sta.wait_connected(timeout=10, error="Roaming timed out")
logger.info("Roam back to AP1")
for sta in [ dev[1], wpas, dev[0], dev[2] ]:
sta.scan(freq="2412")
sta.dump_monitor()
sta.request("ROAM " + bssid)
- ev = sta.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ sta.wait_connected(timeout=10, error="Roaming timed out")
sta.dump_monitor()
time.sleep(4)
sta.scan(freq="2412")
sta.dump_monitor()
sta.request("ROAM " + bssid2)
- ev = sta.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ sta.wait_connected(timeout=10, error="Roaming timed out")
sta.dump_monitor()
def test_pmksa_cache_opportunistic_multiple_sta(dev, apdev):
password_hex="0123456789abcdef0123456789abcdef")
for d in [ dev[0], dev[1] ]:
d.request("REASSOCIATE")
- ev = d.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reassociation timed out")
+ d.wait_connected(timeout=15, error="Reassociation timed out")
count = 0
while True:
if reply.code != pyrad.packet.DisconnectACK:
raise Exception("Unexpected response code")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for re-connection")
+ dev[0].wait_disconnected(timeout=10)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
logger.info("Disconnect-Request with matching User-Name")
req = radius_das.DisconnectPacket(dict=dict, secret="secret",
if reply.code != pyrad.packet.DisconnectACK:
raise Exception("Unexpected response code")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for re-connection")
+ dev[0].wait_disconnected(timeout=10)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
logger.info("Disconnect-Request with matching Calling-Station-Id")
req = radius_das.DisconnectPacket(dict=dict, secret="secret",
if reply.code != pyrad.packet.DisconnectACK:
raise Exception("Unexpected response code")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
+ dev[0].wait_disconnected(timeout=10)
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"])
if ev is None:
raise Exception("Timeout while waiting for re-connection")
if "CTRL-EVENT-EAP-STARTED" not in ev:
raise Exception("Unexpected skipping of EAP authentication in reconnection")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for re-connection to complete")
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
logger.info("Disconnect-Request with matching Calling-Station-Id and non-matching CUI")
req = radius_das.DisconnectPacket(dict=dict, secret="secret",
if reply.code != pyrad.packet.DisconnectACK:
raise Exception("Unexpected response code")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for re-connection")
+ dev[0].wait_disconnected(timeout=10)
+ dev[0].wait_connected(timeout=10, error="Re-connection timed out")
logger.info("Disconnect-Request with matching CUI")
dev[1].connect("radius-das", key_mgmt="WPA-EAP",
if reply.code != pyrad.packet.DisconnectACK:
raise Exception("Unexpected response code")
- ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for re-connection")
+ dev[1].wait_disconnected(timeout=10)
+ dev[1].wait_connected(timeout=10, error="Re-connection timed out")
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
if ev is not None:
'192.168.213.17'])
dev[0].request("SET EAPOL::authPeriod 5")
connect(dev[0], "radius-failover", wait_connect=False)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=60)
- if ev is None:
- raise Exception("Connection with the AP timed out")
+ dev[0].wait_connected(timeout=60)
finally:
dev[0].request("SET EAPOL::authPeriod 30")
subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17'])
try:
logger.info("rfkill block")
subprocess.call(['sudo', 'rfkill', 'block', id])
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing disconnection event on rfkill block")
+ dev[0].wait_disconnected(timeout=10,
+ error="Missing disconnection event on rfkill block")
if "FAIL" not in dev[0].request("REASSOCIATE"):
raise Exception("REASSOCIATE accepted while disabled")
logger.info("rfkill unblock")
subprocess.call(['sudo', 'rfkill', 'unblock', id])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing connection event on rfkill unblock")
+ dev[0].wait_connected(timeout=10,
+ error="Missing connection event on rfkill unblock")
hwsim_utils.test_connectivity(dev[0], hapd)
finally:
subprocess.call(['sudo', 'rfkill', 'unblock', id])
try:
logger.info("rfkill block")
subprocess.call(['sudo', 'rfkill', 'block', id])
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing disconnection event on rfkill block")
+ dev[0].wait_disconnected(timeout=10,
+ error="Missing disconnection event on rfkill block")
logger.info("rfkill unblock")
subprocess.call(['sudo', 'rfkill', 'unblock', id])
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing connection event on rfkill unblock")
+ dev[0].wait_connected(timeout=10,
+ error="Missing connection event on rfkill unblock")
hwsim_utils.test_connectivity(dev[0], hapd)
finally:
subprocess.call(['sudo', 'rfkill', 'unblock', id])
ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5)
if ev is None:
raise Exception("INTERFACE-DISABLED event not seen")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing disconnection event")
+ dev[0].wait_disconnected(timeout=10)
dev[0].request("DISCONNECT")
hapd.disable()
scan_freq="2412")
dev[0].request("DISCONNECT")
dev[0].request("RECONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnect timed out")
+ dev[0].wait_connected(timeout=15, error="Reconnect timed out")
if dev[0].get_status_field('sae_group') is not None:
raise Exception("SAE group claimed to have been used")
scan_freq="2412")
dev[0].request("DISCONNECT")
dev[0].request("RECONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnect timed out")
+ dev[0].wait_connected(timeout=15, error="Reconnect timed out")
if dev[0].get_status_field('sae_group') != '19':
raise Exception("Expected default SAE group not used")
for i in range(0, 2):
dev[i].select_network(id[i])
for i in range(0, 2):
- ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[i].wait_connected(timeout=10)
def test_sae_forced_anti_clogging(dev, apdev):
"""SAE anti clogging (forced)"""
# cfg80211 BSS entry missing.
dev[0].request("RADIO_WORK done " + id)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=15)
def test_scan_hidden(dev, apdev):
"""Control interface behavior on scan parameters"""
dev[0].request("RADIO_WORK done " + id)
wpas.request("RADIO_WORK done " + w_id)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("No connection (sme-connect)")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("No connection (connect)")
+ dev[0].wait_connected(timeout=15, error="No connection (sme-connect)")
+ wpas.wait_connected(timeout=15, error="No connection (connect)")
def test_scan_reqs_with_non_scan_radio_work(dev, apdev):
"""SCAN commands while non-scan radio_work is in progress"""
dev[0].set_network(id, "scan_ssid", "1")
dev[0].request("REASSOCIATE")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=30)
wpas.request("SCAN")
time.sleep(0.5)
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection not reported")
+ wpas.wait_connected(timeout=10)
wpas.request("SCAN")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Connection not reported")
+ wpas.wait_connected(timeout=5)
def test_sta_ap_scan_2(dev, apdev):
"""Dynamically added wpa_supplicant interface with AP_SCAN 2 connection"""
'freq', '2412'])
time.sleep(1)
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection not reported")
+ wpas.wait_connected(timeout=10)
wpas.request("SET disallow_aps bssid " + bssid)
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection not reported")
+ wpas.wait_disconnected(timeout=10)
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(wpas, hapd)
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down'])
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection not reported")
+ wpas.wait_disconnected(timeout=10)
if wpas.get_status_field("wpa_state") != "INTERFACE_DISABLED":
raise Exception("Unexpected wpa_state")
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'up'])
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection not reported")
+ wpas.wait_connected(timeout=15, error="Reconnection not reported")
hwsim_utils.test_connectivity(wpas, hapd)
def test_sta_dynamic_ext_mac_addr_change(dev, apdev):
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(wpas, hapd)
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down'])
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection not reported")
+ wpas.wait_disconnected(timeout=10)
if wpas.get_status_field("wpa_state") != "INTERFACE_DISABLED":
raise Exception("Unexpected wpa_state")
prev_addr = wpas.p2p_interface_addr()
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', wpas.ifname,
'address', new_addr])
subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'up'])
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection not reported")
+ wpas.wait_connected(timeout=15, error="Reconnection not reported")
if wpas.get_driver_status_field('addr') != new_addr:
raise Exception("Address change not reported")
hwsim_utils.test_connectivity(wpas, hapd)
raise Exception("Unexpected BSS flags: " + bss['flags'])
dev[0].request("DISCONNECT")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Disconnection event timed out")
+ dev[0].wait_disconnected(timeout=20)
dev[0].dump_monitor()
dev[0].request("RECONNECT")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
phase1="peapver=0 tnc=soh cryptobinding=0",
phase2="auth=MSCHAPV2",
wait_connect=False)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=10)
dev[1].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
eap="PEAP", identity="user", password="password",
phase1="peapver=0 tnc=soh1 cryptobinding=1",
phase2="auth=MSCHAPV2",
wait_connect=False)
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[1].wait_connected(timeout=10)
dev[2].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
eap="PEAP", identity="user", password="password",
phase1="peapver=0 tnc=soh2 cryptobinding=2",
phase2="auth=MSCHAPV2",
wait_connect=False)
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[2].wait_connected(timeout=10)
def test_tnc_ttls(dev, apdev):
"""TNC TTLS"""
phase2="auth=MSCHAPV2",
ca_cert="auth_serv/ca.pem",
wait_connect=False)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=10)
def test_tnc_fast(dev, apdev):
"""TNC FAST"""
pac_file="blob://fast_pac_auth_tnc",
ca_cert="auth_serv/ca.pem",
wait_connect=False)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Connection timed out")
+ dev[0].wait_connected(timeout=10)
dev[2].set_network(id, "wep_tx_keyidx", "1")
dev[2].request("REASSOCIATE")
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Reassociation with the AP timed out")
+ dev[2].wait_connected(timeout=10, error="Reassociation timed out")
hwsim_utils.test_connectivity(dev[2], hapd)
wpas.dump_monitor()
hapd.request("DEAUTHENTICATE " + wpas.p2p_interface_addr())
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Timeout on disconnection event")
+ wpas.wait_disconnected(timeout=15)
def test_wext_wpa_psk(dev, apdev):
"""WEXT driver interface with WPA-PSK"""
with open(testfile, "w") as f:
f.write("ff:ff:ff:ff:ff:ff")
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("No disconnection after two Michael MIC failures")
+ ev = wpas.wait_disconnected(timeout=10,
+ error="No disconnection after two Michael MIC failures")
if "reason=14 locally_generated=1" not in ev:
raise Exception("Unexpected disconnection reason: " + ev)
ev = wpas.wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
if ev is None:
raise Exception("EAP success timed out")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ wpas.wait_connected(timeout=10, error="Roaming timed out")
pmksa2 = wpas.get_pmksa(bssid2)
if pmksa2 is None:
raise Exception("No PMKSA cache entry found")
raise Exception("PMKSA_FLUSH failed")
if wpas.get_pmksa(bssid) is not None or wpas.get_pmksa(bssid2) is not None:
raise Exception("PMKSA_FLUSH did not remove PMKSA entries")
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reconnection timed out")
+ wpas.wait_disconnected(timeout=5)
+ wpas.wait_connected(timeout=15, error="Reconnection timed out")
def test_wext_wep_open_auth(dev, apdev):
"""WEP Open System authentication"""
wep_key0='"hello12345678"', scan_freq="2412")
hwsim_utils.test_connectivity(wpas, hapd)
wpas.request("REMOVE_NETWORK all")
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection event timed out")
+ wpas.wait_disconnected(timeout=5)
wpas.connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
wep_key0='"hello12345678"', scan_freq="2412")
addr = wpas.p2p_interface_addr()
hapd.request("DEAUTHENTICATE " + addr)
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("No disconnection")
+ wpas.wait_disconnected(timeout=5)
def test_wext_scan_hidden(dev, apdev):
"""WEXT with hidden SSID"""
try:
logger.info("rfkill block")
subprocess.call(['rfkill', 'block', id])
- ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Missing disconnection event on rfkill block")
+ wpas.wait_disconnected(timeout=10,
+ error="Missing disconnection event on rfkill block")
logger.info("rfkill unblock")
subprocess.call(['rfkill', 'unblock', id])
- ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
- if ev is None:
- raise Exception("Missing connection event on rfkill unblock")
+ wpas.wait_connected(timeout=20,
+ error="Missing connection event on rfkill unblock")
hwsim_utils.test_connectivity(wpas, hapd)
finally:
subprocess.call(['rfkill', 'unblock', id])
raise Exception("BSS transition request was not accepted: " + ev)
if "target_bssid=" + apdev[1]['bssid'] not in ev:
raise Exception("Unexpected target BSS: " + ev)
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("No reassociation seen");
+ dev[0].wait_connected(timeout=15, error="No reassociation seen")
if apdev[1]['bssid'] not in ev:
raise Exception("Unexpected reassociation target: " + ev)
ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=0.1)
dev[2].dump_monitor()
dev[0].request("DEAUTHENTICATE " + addr1)
dev[0].request("DISASSOCIATE " + addr2)
- ev = dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Disconnection timed out")
- ev = dev[2].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Disconnection timed out")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Reconnection timed out")
- ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"])
- if ev is None:
- raise Exception("Reconnection timed out")
+ dev[1].wait_disconnected(timeout=10)
+ dev[2].wait_disconnected(timeout=10)
+ dev[1].wait_connected(timeout=10, error="Reconnection timed out")
+ dev[2].wait_connected(timeout=10, error="Reconnection timed out")
dev[1].request("DISCONNECT")
dev[2].request("DISCONNECT")
if ev is None:
raise Exception("PBC mode start timeout")
dev[1].request("WPS_PBC")
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("WPS PBC operation timed out")
+ dev[1].wait_connected(timeout=30, error="WPS PBC operation timed out")
hwsim_utils.test_connectivity(dev[0], dev[1])
logger.info("Test AP PIN to learn configuration")
pin = dev[1].wps_read_pin()
dev[0].request("WPS_PIN any " + pin)
dev[1].request("WPS_PIN any " + pin)
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=30)
dev[1].request("REMOVE_NETWORK all")
dev[1].dump_monitor()
dev[0].request("WPS_PIN any " + pin + " 100")
dev[1].request("WPS_PIN any " + pin)
- ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[1].wait_connected(timeout=30)
dev[1].request("REMOVE_NETWORK all")
dev[1].dump_monitor()
raise Exception("WPS operation timed out")
if "WPS-SUCCESS" in ev:
raise Exception("WPS operation succeeded unexpectedly")
- ev = dev[2].wait_event(["CTRL-EVENT-DISCONNECTED"])
- if ev is None:
- raise Exception("Timeout while waiting for disconnection")
+ dev[2].wait_disconnected(timeout=10)
dev[2].request("WPS_CANCEL")
dev[2].request("REMOVE_NETWORK all")
ev = dev[0].wait_event(["WPS-AP-SETUP-LOCKED"])
raise Exception("Failed to set disallow_aps")
if "OK" not in dev[0].request("SET disallow_aps bssid " + apdev[0]['bssid']):
raise Exception("Failed to set disallow_aps")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Reassociation timed out")
+ ev = dev[0].wait_connected(timeout=15, error="Reassociation timed out")
if apdev[1]['bssid'] not in ev:
raise Exception("Unexpected BSSID")
dev[0].dump_monitor()
if "OK" not in dev[0].request("SET disallow_aps ssid " + "test".encode("hex")):
raise Exception("Failed to set disallow_aps")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
- if ev is None:
- raise Exception("Disconnection not seen")
+ dev[0].wait_disconnected(timeout=5, error="Disconnection not seen")
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
if ev is not None:
raise Exception("Unexpected reassociation")
raise Exception("Failed to disable networks")
if "OK" not in dev[0].request("ENABLE_NETWORK " + str(id)):
raise Exception("Failed to enable network")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=10)
if "OK" not in dev[0].request("DISABLE_NETWORK " + str(id)):
raise Exception("Failed to disable network")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection with the AP timed out")
+ dev[0].wait_disconnected(timeout=10)
time.sleep(0.1)
if "OK" not in dev[0].request("ENABLE_NETWORK all"):
raise Exception("Failed to enable network")
- ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ dev[0].wait_connected(timeout=10)
if "OK" not in dev[0].request("DISABLE_NETWORK all"):
raise Exception("Failed to disable network")
- ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Disconnection with the AP timed out")
+ dev[0].wait_disconnected(timeout=10)
def test_wpas_ctrl_country(dev, apdev):
"""wpa_supplicant SET/GET country code"""
def connect_network(self, id, timeout=10):
self.dump_monitor()
self.select_network(id)
- ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=timeout)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ self.wait_connected(timeout=timeout)
self.dump_monitor()
def get_status(self, extra=None):
raise Exception("Unexpected connection")
self.dump_monitor()
return
- ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ self.wait_connected(timeout=10, error="Roaming with the AP timed out")
self.dump_monitor()
def roam_over_ds(self, bssid, fail_test=False):
raise Exception("Unexpected connection")
self.dump_monitor()
return
- ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
- if ev is None:
- raise Exception("Roaming with the AP timed out")
+ self.wait_connected(timeout=10, error="Roaming with the AP timed out")
self.dump_monitor()
def wps_reg(self, bssid, pin, new_ssid=None, key_mgmt=None, cipher=None,
ev = self.wait_event(["WPS-FAIL"], timeout=15)
if ev is None:
raise Exception("WPS timed out")
- ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
- if ev is None:
- raise Exception("Association with the AP timed out")
+ self.wait_connected(timeout=15)
def relog(self):
self.global_request("RELOG")
msg['payload'] = frame[24:]
return msg
+
+ def wait_connected(self, timeout=10, error="Connection timed out"):
+ ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=timeout)
+ if ev is None:
+ raise Exception(error)
+ return ev
+
+ def wait_disconnected(self, timeout=10, error="Disconnection timed out"):
+ ev = self.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=timeout)
+ if ev is None:
+ raise Exception(error)
+ return ev