import hostapd
import hwsim_utils
import utils
+from wpasupplicant import WpaSupplicant
def check_grpform_results(i_res, r_res):
if i_res['result'] != 'success' or r_res['result'] != 'success':
addr1 = dev[1].p2p_dev_addr()
if not dev[0].discover_peer(addr1):
raise Exception("Peer " + addr1 + " not found")
+ if not dev[2].discover_peer(addr1):
+ raise Exception("Peer " + addr1 + " not found(2)")
+
start = os.times()[4]
- if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " 12345670 display"):
+
+ cmd = "P2P_CONNECT " + addr1 + " 12345670 display"
+ if "OK" not in dev[0].global_request(cmd):
raise Exception("Failed to initiate GO Neg")
- ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=200)
+
+ if "OK" not in dev[2].global_request(cmd):
+ raise Exception("Failed to initiate GO Neg(2)")
+
+ # First, check with p2p_find
+ ev = dev[2].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=30)
+ if ev is not None:
+ raise Exception("Too early GO Negotiation timeout reported(2)")
+ dev[2].dump_monitor()
+ logger.info("Starting p2p_find to change state")
+ dev[2].p2p_find()
+ ev = dev[2].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=100)
if ev is None:
- raise Exception("GO Negotiation failure timed out")
+ raise Exception("GO Negotiation failure timed out(2)")
+ dev[2].dump_monitor()
end = os.times()[4]
- logger.info("GO Negotiation wait time: {} seconds".format(end - start))
+ logger.info("GO Negotiation wait time: {} seconds(2)".format(end - start))
if end - start < 120:
- raise Exception("Too short GO Negotiation wait time: {}".format(end - start))
+ raise Exception("Too short GO Negotiation wait time(2): {}".format(end - start))
-def test_grpform_cred_ready_timeout2(dev, apdev, params):
- """P2P GO Negotiation wait for credentials to become ready (2) [long]"""
- if not params['long']:
- logger.info("Skip test case with long duration due to --long not specified")
- return "skip"
+ wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+ wpas.interface_add("wlan5")
- dev[1].p2p_listen()
- addr1 = dev[1].p2p_dev_addr()
- if not dev[0].discover_peer(addr1):
- raise Exception("Peer " + addr1 + " not found")
- start = os.times()[4]
- if "OK" not in dev[0].global_request("P2P_CONNECT " + addr1 + " 12345670 display"):
- raise Exception("Failed to initiate GO Neg")
- ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=30)
- if ev is not None:
- raise Exception("Too early GO Negotiation timeout reported")
- dev[0].dump_monitor()
- logger.info("Starting p2p_find to change state")
- dev[0].p2p_find()
- ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=100)
+ wpas.p2p_listen()
+ ev = dev[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
+ if ev is None:
+ raise Exception("Did not discover new device after GO Negotiation failure")
+ if wpas.p2p_dev_addr() not in ev:
+ raise Exception("Unexpected device found: " + ev)
+ dev[2].p2p_stop_find()
+ wpas.p2p_stop_find()
+
+ # Finally, verify without p2p_find
+ ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=120)
if ev is None:
raise Exception("GO Negotiation failure timed out")
- dev[0].dump_monitor()
end = os.times()[4]
logger.info("GO Negotiation wait time: {} seconds".format(end - start))
if end - start < 120:
raise Exception("Too short GO Negotiation wait time: {}".format(end - start))
- dev[2].p2p_listen()
- ev = dev[0].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
- if ev is None:
- raise Exception("Did not discovery new device after GO Negotiation failure")
- if dev[2].p2p_dev_addr() not in ev:
- raise Exception("Unexpected device found: " + ev)
-
def test_grpform_no_wsc_done(dev):
"""P2P group formation with WSC-Done not sent"""
addr0 = dev[0].p2p_dev_addr()