1 # P2P persistent group test cases
2 # Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
7 from remotehost import remote_compatible
9 logger = logging.getLogger()
14 from p2p_utils import *
17 def test_persistent_group(dev):
18 """P2P persistent group formation and re-invocation"""
20 invite_from_cli(dev[0], dev[1])
21 invite_from_go(dev[0], dev[1])
23 logger.info("Remove group on the client and try to invite from GO")
25 for n in dev[0].list_networks(p2p=True):
26 if "[P2P-PERSISTENT]" in n['flags']:
30 raise Exception("Could not find persistent group entry")
31 clients = dev[0].global_request("GET_NETWORK " + id + " p2p_client_list").rstrip()
32 if dev[1].p2p_dev_addr() not in clients:
33 raise Exception("Peer missing from client list")
34 if "FAIL" not in dev[1].request("SELECT_NETWORK " + str(id)):
35 raise Exception("SELECT_NETWORK succeeded unexpectedly")
36 if "FAIL" not in dev[1].request("SELECT_NETWORK 1234567"):
37 raise Exception("SELECT_NETWORK succeeded unexpectedly(2)")
38 if "FAIL" not in dev[1].request("ENABLE_NETWORK " + str(id)):
39 raise Exception("ENABLE_NETWORK succeeded unexpectedly")
40 if "FAIL" not in dev[1].request("ENABLE_NETWORK 1234567"):
41 raise Exception("ENABLE_NETWORK succeeded unexpectedly(2)")
42 if "FAIL" not in dev[1].request("DISABLE_NETWORK " + str(id)):
43 raise Exception("DISABLE_NETWORK succeeded unexpectedly")
44 if "FAIL" not in dev[1].request("DISABLE_NETWORK 1234567"):
45 raise Exception("DISABLE_NETWORK succeeded unexpectedly(2)")
46 if "FAIL" not in dev[1].request("REMOVE_NETWORK 1234567"):
47 raise Exception("REMOVE_NETWORK succeeded unexpectedly")
48 dev[1].global_request("REMOVE_NETWORK all")
49 if len(dev[1].list_networks(p2p=True)) > 0:
50 raise Exception("Unexpected network block remaining")
51 invite(dev[0], dev[1])
52 ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
54 raise Exception("No invitation result seen")
55 if "status=8" not in ev:
56 raise Exception("Unexpected invitation result: " + ev)
57 clients = dev[0].request("GET_NETWORK " + id + " p2p_client_list").rstrip()
58 if dev[1].p2p_dev_addr() in clients:
59 raise Exception("Peer was still in client list")
62 def test_persistent_group2(dev):
63 """P2P persistent group formation with reverse roles"""
64 form(dev[0], dev[1], reverse_init=True)
65 invite_from_cli(dev[0], dev[1])
66 invite_from_go(dev[0], dev[1])
69 def test_persistent_group3(dev):
70 """P2P persistent group formation and re-invocation with empty BSS table"""
72 dev[1].request("BSS_FLUSH 0")
73 invite_from_cli(dev[0], dev[1])
74 dev[1].request("BSS_FLUSH 0")
75 invite_from_go(dev[0], dev[1])
77 def test_persistent_group_per_sta_psk(dev):
78 """P2P persistent group formation and re-invocation using per-client PSK"""
79 addr0 = dev[0].p2p_dev_addr()
80 addr1 = dev[1].p2p_dev_addr()
81 addr2 = dev[2].p2p_dev_addr()
82 dev[0].global_request("P2P_SET per_sta_psk 1")
83 logger.info("Form a persistent group")
84 [i_res, r_res] = go_neg_pin_authorized_persistent(i_dev=dev[0], i_intent=15,
85 r_dev=dev[1], r_intent=0)
86 if not i_res['persistent'] or not r_res['persistent']:
87 raise Exception("Formed group was not persistent")
89 logger.info("Join another client to the group")
90 pin = dev[2].wps_read_pin()
91 dev[0].p2p_go_authorize_client(pin)
92 social = int(i_res['freq']) in [ 2412, 2437, 2462 ]
93 c_res = dev[2].p2p_connect_group(addr0, pin, timeout=60, social=social,
95 if not c_res['persistent']:
96 raise Exception("Joining client did not recognize persistent group")
97 if r_res['psk'] == c_res['psk']:
98 raise Exception("Same PSK assigned for both clients")
99 hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
101 logger.info("Remove persistent group and re-start it manually")
102 dev[0].remove_group()
103 dev[1].wait_go_ending_session()
104 dev[2].wait_go_ending_session()
105 dev[0].dump_monitor()
106 dev[1].dump_monitor()
107 dev[2].dump_monitor()
109 for i in range(0, 3):
110 networks = dev[i].list_networks(p2p=True)
111 if len(networks) != 1:
112 raise Exception("Unexpected number of networks")
113 if "[P2P-PERSISTENT]" not in networks[0]['flags']:
114 raise Exception("Not the persistent group data")
116 # speed up testing by avoiding use of the old BSS entry since the
117 # GO may have changed channels
118 dev[i].request("BSS_FLUSH 0")
119 dev[i].scan(freq="2412", only_new=True)
120 if "OK" not in dev[i].global_request("P2P_GROUP_ADD persistent=" + networks[0]['id'] + " freq=2412"):
121 raise Exception("Could not re-start persistent group")
122 ev = dev[i].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
124 raise Exception("Timeout on group restart")
125 dev[i].group_form_result(ev)
127 logger.info("Leave persistent group and rejoin it")
128 dev[2].remove_group()
129 ev = dev[2].wait_global_event(["P2P-GROUP-REMOVED"], timeout=3)
131 raise Exception("Group removal event timed out")
132 if not dev[2].discover_peer(addr0, social=True):
133 raise Exception("Peer " + peer + " not found")
134 dev[2].dump_monitor()
135 peer = dev[2].get_peer(addr0)
136 dev[2].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'] + " freq=2412")
137 ev = dev[2].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
139 raise Exception("Timeout on group restart (on client)")
140 cli_res = dev[2].group_form_result(ev)
141 if not cli_res['persistent']:
142 raise Exception("Persistent group not restarted as persistent (cli)")
143 hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
145 logger.info("Remove one of the clients from the group without removing persistent group information for the client")
146 dev[0].global_request("P2P_REMOVE_CLIENT iface=" + dev[2].p2p_interface_addr())
147 dev[2].wait_go_ending_session()
149 logger.info("Try to reconnect after having been removed from group (but persistent group info still present)")
150 if not dev[2].discover_peer(addr0, social=True):
151 raise Exception("Peer " + peer + " not found")
152 dev[2].dump_monitor()
153 peer = dev[2].get_peer(addr0)
154 dev[2].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'] + " freq=2412")
155 ev = dev[2].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30)
157 raise Exception("Timeout on group restart (on client)")
158 if "P2P-GROUP-STARTED" not in ev:
159 raise Exception("Connection failed")
161 logger.info("Remove one of the clients from the group")
162 dev[0].global_request("P2P_REMOVE_CLIENT " + addr2)
163 dev[2].wait_go_ending_session()
165 logger.info("Try to reconnect after having been removed from group")
166 if not dev[2].discover_peer(addr0, social=True):
167 raise Exception("Peer " + peer + " not found")
168 dev[2].dump_monitor()
169 peer = dev[2].get_peer(addr0)
170 dev[2].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'] + " freq=2412")
171 ev = dev[2].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30)
173 raise Exception("Timeout on group restart (on client)")
174 if "P2P-GROUP-STARTED" in ev:
175 raise Exception("Client managed to connect after being removed")
177 logger.info("Remove the remaining client from the group")
178 dev[0].global_request("P2P_REMOVE_CLIENT " + addr1)
179 dev[1].wait_go_ending_session()
181 logger.info("Terminate persistent group")
182 dev[0].remove_group()
183 dev[0].dump_monitor()
185 logger.info("Try to re-invoke persistent group from client")
186 dev[0].global_request("SET persistent_reconnect 1")
188 if not dev[1].discover_peer(addr0, social=True):
189 raise Exception("Peer " + peer + " not found")
190 dev[1].dump_monitor()
191 peer = dev[1].get_peer(addr0)
192 dev[1].global_request("P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr0)
193 ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
194 dev[0].group_form_result(ev)
195 ev = dev[1].wait_global_event(["P2P-GROUP-STARTED","WPA: 4-Way Handshake failed"], timeout=30)
197 raise Exception("Timeout on group restart (on client)")
198 if "P2P-GROUP-STARTED" in ev:
199 raise Exception("Client managed to re-invoke after being removed")
200 dev[0].dump_monitor()
202 logger.info("Terminate persistent group")
203 dev[0].remove_group()
204 dev[0].dump_monitor()
206 def test_persistent_group_invite_removed_client(dev):
207 """P2P persistent group client removal and re-invitation"""
208 addr0 = dev[0].p2p_dev_addr()
209 addr1 = dev[1].p2p_dev_addr()
210 dev[0].request("P2P_SET per_sta_psk 1")
211 logger.info("Form a persistent group")
212 [i_res, r_res] = go_neg_pin_authorized_persistent(i_dev=dev[0], i_intent=15,
213 r_dev=dev[1], r_intent=0)
214 if not i_res['persistent'] or not r_res['persistent']:
215 raise Exception("Formed group was not persistent")
217 logger.info("Remove client from the group")
218 dev[0].global_request("P2P_REMOVE_CLIENT " + addr1)
219 dev[1].wait_go_ending_session()
221 logger.info("Re-invite the removed client to join the group")
223 if not dev[0].discover_peer(addr1, social=True):
224 raise Exception("Peer " + peer + " not found")
225 dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1)
226 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=10)
228 raise Exception("Timeout on invitation")
229 if "sa=" + addr0 + " persistent=" not in ev:
230 raise Exception("Unexpected invitation event")
231 [event,addr,persistent] = ev.split(' ', 2)
232 dev[1].global_request("P2P_GROUP_ADD " + persistent)
233 ev = dev[1].wait_global_event(["P2P-PERSISTENT-PSK-FAIL"], timeout=30)
235 raise Exception("Did not receive PSK failure report")
236 [tmp,id] = ev.split('=', 1)
237 ev = dev[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout=10)
239 raise Exception("Group removal event timed out")
240 if "reason=PSK_FAILURE" not in ev:
241 raise Exception("Unexpected group removal reason")
242 dev[1].global_request("REMOVE_NETWORK " + id)
244 logger.info("Re-invite after client removed persistent group info")
246 if not dev[0].discover_peer(addr1, social=True):
247 raise Exception("Peer " + peer + " not found")
248 dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1)
249 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=10)
251 raise Exception("Timeout on invitation")
252 if " persistent=" in ev:
253 raise Exception("Unexpected invitation event")
254 pin = dev[1].wps_read_pin()
255 dev[0].p2p_go_authorize_client(pin)
256 c_res = dev[1].p2p_connect_group(addr0, pin, timeout=60, social=True,
258 if not c_res['persistent']:
259 raise Exception("Joining client did not recognize persistent group")
260 if r_res['psk'] == c_res['psk']:
261 raise Exception("Same PSK assigned on both times")
262 hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
264 terminate_group(dev[0], dev[1])
267 def test_persistent_group_channel(dev):
268 """P2P persistent group re-invocation with channel selection"""
269 form(dev[0], dev[1], test_data=False)
271 logger.info("Re-invoke persistent group from client with forced channel")
272 invite(dev[1], dev[0], "freq=2427")
273 [go_res, cli_res] = check_result(dev[0], dev[1])
274 if go_res['freq'] != "2427":
275 raise Exception("Persistent group client forced channel not followed")
276 terminate_group(dev[0], dev[1])
278 logger.info("Re-invoke persistent group from GO with forced channel")
279 invite(dev[0], dev[1], "freq=2432")
280 [go_res, cli_res] = check_result(dev[0], dev[1])
281 if go_res['freq'] != "2432":
282 raise Exception("Persistent group GO channel preference not followed")
283 terminate_group(dev[0], dev[1])
285 logger.info("Re-invoke persistent group from client with channel preference")
286 invite(dev[1], dev[0], "pref=2417")
287 [go_res, cli_res] = check_result(dev[0], dev[1])
288 if go_res['freq'] != "2417":
289 raise Exception("Persistent group client channel preference not followed")
290 terminate_group(dev[0], dev[1])
293 def test_persistent_group_and_role_change(dev):
294 """P2P persistent group, auto GO in another role, and re-invocation"""
297 logger.info("Start and stop autonomous GO on previous P2P client device")
298 dev[1].p2p_start_go()
299 dev[1].remove_group()
300 dev[1].dump_monitor()
302 logger.info("Re-invoke the persistent group")
303 invite_from_go(dev[0], dev[1])
305 def test_persistent_go_client_list(dev):
306 """P2P GO and list of clients in persistent group"""
307 addr0 = dev[0].p2p_dev_addr()
308 addr1 = dev[1].p2p_dev_addr()
309 addr2 = dev[2].p2p_dev_addr()
311 res = dev[0].p2p_start_go(persistent=True)
313 for n in dev[0].list_networks(p2p=True):
314 if "[P2P-PERSISTENT]" in n['flags']:
318 raise Exception("Could not find persistent group entry")
320 connect_cli(dev[0], dev[1], social=True, freq=res['freq'])
321 clients = dev[0].global_request("GET_NETWORK " + id + " p2p_client_list").rstrip()
323 raise Exception("Unexpected p2p_client_list entry(2): " + clients)
324 connect_cli(dev[0], dev[2], social=True, freq=res['freq'])
325 clients = dev[0].global_request("GET_NETWORK " + id + " p2p_client_list").rstrip()
326 if clients != addr2 + " " + addr1:
327 raise Exception("Unexpected p2p_client_list entry(3): " + clients)
329 peer = dev[1].get_peer(res['go_dev_addr'])
330 dev[1].remove_group()
331 dev[1].global_request("P2P_GROUP_ADD persistent=" + peer['persistent'])
332 ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=30)
334 raise Exception("Timeout on group restart (on client)")
335 dev[1].group_form_result(ev)
336 clients = dev[0].global_request("GET_NETWORK " + id + " p2p_client_list").rstrip()
337 if clients != addr1 + " " + addr2:
338 raise Exception("Unexpected p2p_client_list entry(4): " + clients)
340 dev[2].remove_group()
341 dev[1].remove_group()
342 dev[0].remove_group()
344 clients = dev[0].global_request("GET_NETWORK " + id + " p2p_client_list").rstrip()
345 if clients != addr1 + " " + addr2:
346 raise Exception("Unexpected p2p_client_list entry(5): " + clients)
350 dev[0].request("P2P_FLUSH")
351 dev[0].discover_peer(addr1, social=True)
352 peer = dev[0].get_peer(addr1)
353 if 'persistent' not in peer or peer['persistent'] != id:
354 raise Exception("Persistent group client not recognized(1)")
356 dev[0].discover_peer(addr2, social=True)
357 peer = dev[0].get_peer(addr2)
358 if 'persistent' not in peer or peer['persistent'] != id:
359 raise Exception("Persistent group client not recognized(2)")
362 def test_persistent_group_in_grpform(dev):
363 """P2P persistent group parameters re-used in group formation"""
364 addr0 = dev[0].p2p_dev_addr()
365 addr1 = dev[1].p2p_dev_addr()
368 if not dev[0].discover_peer(addr1, social=True):
369 raise Exception("Could not discover peer")
370 peer = dev[0].get_peer(addr1)
371 if "persistent" not in peer:
372 raise Exception("Could not map peer to a persistent group")
374 pin = dev[1].wps_read_pin()
375 dev[1].p2p_go_neg_auth(addr0, pin, "display", go_intent=0)
376 i_res = dev[0].p2p_go_neg_init(addr1, pin, "enter", timeout=20,
378 persistent_id=peer['persistent'])
379 r_res = dev[1].p2p_go_neg_auth_result()
380 logger.debug("i_res: " + str(i_res))
381 logger.debug("r_res: " + str(r_res))
384 def test_persistent_group_without_persistent_reconnect(dev):
385 """P2P persistent group re-invocation without persistent reconnect"""
387 dev[0].dump_monitor()
388 dev[1].dump_monitor()
390 logger.info("Re-invoke persistent group from client")
391 invite(dev[1], dev[0], persistent_reconnect=False)
393 ev = dev[0].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=15)
395 raise Exception("No invitation request reported")
396 if "persistent=" not in ev:
397 raise Exception("Invalid invitation type reported: " + ev)
399 ev2 = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
401 raise Exception("No invitation response reported")
402 if "status=1" not in ev2:
403 raise Exception("Unexpected status: " + ev2)
406 exp = r'<.>(P2P-INVITATION-RECEIVED) sa=([0-9a-f:]*) persistent=([0-9]*) freq=([0-9]*)'
407 s = re.split(exp, ev)
409 raise Exception("Could not parse invitation event")
413 logger.info("Invalid P2P_INVITE test coverage")
414 if "FAIL" not in dev[0].global_request("P2P_INVITE persistent=" + id + " peer=" + sa + " freq=0"):
415 raise Exception("Invalid P2P_INVITE accepted")
416 if "FAIL" not in dev[0].global_request("P2P_INVITE persistent=" + id + " peer=" + sa + " pref=0"):
417 raise Exception("Invalid P2P_INVITE accepted")
418 logger.info("Re-initiate invitation based on upper layer acceptance")
419 if "OK" not in dev[0].global_request("P2P_INVITE persistent=" + id + " peer=" + sa + " freq=" + freq):
420 raise Exception("Invitation command failed")
421 [go_res, cli_res] = check_result(dev[0], dev[1])
422 if go_res['freq'] != freq:
423 raise Exception("Unexpected channel on GO: {} MHz, expected {} MHz".format(go_res['freq'], freq))
424 if cli_res['freq'] != freq:
425 raise Exception("Unexpected channel on CLI: {} MHz, expected {} MHz".format(cli_res['freq'], freq))
426 terminate_group(dev[0], dev[1])
427 dev[0].dump_monitor()
428 dev[1].dump_monitor()
430 logger.info("Re-invoke persistent group from GO")
431 invite(dev[0], dev[1], persistent_reconnect=False)
433 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=15)
435 raise Exception("No invitation request reported")
436 if "persistent=" not in ev:
437 raise Exception("Invalid invitation type reported: " + ev)
439 ev2 = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
441 raise Exception("No invitation response reported")
442 if "status=1" not in ev2:
443 raise Exception("Unexpected status: " + ev2)
446 exp = r'<.>(P2P-INVITATION-RECEIVED) sa=([0-9a-f:]*) persistent=([0-9]*)'
447 s = re.split(exp, ev)
449 raise Exception("Could not parse invitation event")
452 logger.info("Re-initiate invitation based on upper layer acceptance")
453 if "OK" not in dev[1].global_request("P2P_INVITE persistent=" + id + " peer=" + sa + " freq=" + freq):
454 raise Exception("Invitation command failed")
455 [go_res, cli_res] = check_result(dev[0], dev[1])
456 terminate_group(dev[0], dev[1])
459 def test_persistent_group_already_running(dev):
460 """P2P persistent group formation and invitation while GO already running"""
462 peer = dev[1].get_peer(dev[0].p2p_dev_addr())
463 listen_freq = peer['listen_freq']
464 dev[0].dump_monitor()
465 dev[1].dump_monitor()
466 networks = dev[0].list_networks(p2p=True)
467 if len(networks) != 1:
468 raise Exception("Unexpected number of networks")
469 if "[P2P-PERSISTENT]" not in networks[0]['flags']:
470 raise Exception("Not the persistent group data")
471 if "OK" not in dev[0].global_request("P2P_GROUP_ADD persistent=" + networks[0]['id'] + " freq=" + listen_freq):
472 raise Exception("Could not state GO")
473 invite_from_cli(dev[0], dev[1])
476 def test_persistent_group_add_cli_chan(dev):
477 """P2P persistent group formation and re-invocation with p2p_add_cli_chan=1"""
479 dev[0].request("SET p2p_add_cli_chan 1")
480 dev[1].request("SET p2p_add_cli_chan 1")
482 dev[1].request("BSS_FLUSH 0")
483 dev[1].scan(freq="2412", only_new=True)
484 dev[1].scan(freq="2437", only_new=True)
485 dev[1].scan(freq="2462", only_new=True)
486 dev[1].request("BSS_FLUSH 0")
487 invite_from_cli(dev[0], dev[1])
488 invite_from_go(dev[0], dev[1])
490 dev[0].request("SET p2p_add_cli_chan 0")
491 dev[1].request("SET p2p_add_cli_chan 0")
494 def test_persistent_invalid_group_add(dev):
495 """Invalid P2P_GROUP_ADD command"""
496 id = dev[0].add_network()
497 if "FAIL" not in dev[0].global_request("P2P_GROUP_ADD persistent=12345"):
498 raise Exception("Invalid P2P_GROUP_ADD accepted")
499 if "FAIL" not in dev[0].global_request("P2P_GROUP_ADD persistent=%d" % id):
500 raise Exception("Invalid P2P_GROUP_ADD accepted")
501 if "FAIL" not in dev[0].global_request("P2P_GROUP_ADD foo"):
502 raise Exception("Invalid P2P_GROUP_ADD accepted")
504 def test_persistent_group_missed_inv_resp(dev):
505 """P2P persistent group re-invocation with invitation response getting lost"""
507 addr = dev[1].p2p_dev_addr()
508 dev[1].global_request("SET persistent_reconnect 1")
510 if not dev[0].discover_peer(addr, social=True):
511 raise Exception("Peer " + addr + " not found")
512 dev[0].dump_monitor()
513 peer = dev[0].get_peer(addr)
514 # Drop the first Invitation Response frame
515 if "FAIL" in dev[0].request("SET ext_mgmt_frame_handling 1"):
516 raise Exception("Failed to enable external management frame handling")
517 cmd = "P2P_INVITE persistent=" + peer['persistent'] + " peer=" + addr
518 dev[0].global_request(cmd)
519 rx_msg = dev[0].mgmt_rx()
521 raise Exception("MGMT-RX timeout (no Invitation Response)")
523 # Allow following Invitation Response frame to go through
524 if "FAIL" in dev[0].request("SET ext_mgmt_frame_handling 0"):
525 raise Exception("Failed to disable external management frame handling")
527 # Force the P2P Client side to be on its Listen channel for retry
529 ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
531 raise Exception("Invitation result timed out")
532 # Allow P2P Client side to continue connection-to-GO attempts
533 dev[1].p2p_stop_find()
535 # Verify that group re-invocation goes through
536 ev = dev[1].wait_global_event([ "P2P-GROUP-STARTED",
537 "P2P-GROUP-FORMATION-FAILURE" ],
540 raise Exception("Group start event timed out")
541 if "P2P-GROUP-STARTED" not in ev:
542 raise Exception("Group re-invocation failed")
543 dev[0].group_form_result(ev)
545 ev = dev[0].wait_global_event([ "P2P-GROUP-STARTED" ], timeout=5)
547 raise Exception("Group start event timed out on GO")
548 dev[0].group_form_result(ev)
550 terminate_group(dev[0], dev[1])
553 def test_persistent_group_profile_add(dev):
554 """Create a P2P persistent group with ADD_NETWORK"""
555 passphrase="passphrase here"
556 id = dev[0].p2pdev_add_network()
557 dev[0].p2pdev_set_network_quoted(id, "ssid", "DIRECT-ab")
558 dev[0].p2pdev_set_network_quoted(id, "psk", passphrase)
559 dev[0].p2pdev_set_network(id, "mode", "3")
560 dev[0].p2pdev_set_network(id, "disabled", "2")
561 dev[0].p2p_start_go(persistent=id, freq=2412)
563 pin = dev[1].wps_read_pin()
564 dev[0].p2p_go_authorize_client(pin)
565 res = dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
566 social=True, freq=2412)
567 if res['result'] != 'success':
568 raise Exception("Joining the group did not succeed")
570 dev[0].remove_group()
571 dev[1].wait_go_ending_session()
574 def test_persistent_group_cancel_on_cli(dev):
575 """P2P persistent group formation, re-invocation, and cancel"""
576 dev[0].global_request("SET p2p_no_group_iface 0")
577 dev[1].global_request("SET p2p_no_group_iface 0")
580 invite_from_go(dev[0], dev[1], terminate=False)
581 if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
582 raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
583 if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
584 raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
585 terminate_group(dev[0], dev[1])
587 invite_from_cli(dev[0], dev[1], terminate=False)
588 if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
589 raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
590 if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
591 raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
592 terminate_group(dev[0], dev[1])
595 def test_persistent_group_cancel_on_cli2(dev):
596 """P2P persistent group formation, re-invocation, and cancel (2)"""
598 invite_from_go(dev[0], dev[1], terminate=False)
599 if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
600 raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
601 if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
602 raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
603 terminate_group(dev[0], dev[1])
605 invite_from_cli(dev[0], dev[1], terminate=False)
606 if "FAIL" not in dev[1].global_request("P2P_CANCEL"):
607 raise Exception("P2P_CANCEL succeeded unexpectedly on CLI")
608 if "FAIL" not in dev[0].global_request("P2P_CANCEL"):
609 raise Exception("P2P_CANCEL succeeded unexpectedly on GO")
610 terminate_group(dev[0], dev[1])
613 def test_persistent_group_peer_dropped(dev):
614 """P2P persistent group formation and re-invocation with peer having dropped group"""
615 form(dev[0], dev[1], reverse_init=True)
616 invite_from_cli(dev[0], dev[1])
618 logger.info("Remove group on the GO and try to invite from the client")
619 dev[0].global_request("REMOVE_NETWORK all")
620 invite(dev[1], dev[0])
621 ev = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
623 raise Exception("No invitation result seen")
624 if "status=8" not in ev:
625 raise Exception("Unexpected invitation result: " + ev)
626 networks = dev[1].list_networks(p2p=True)
627 if len(networks) > 0:
628 raise Exception("Unexpected network block on client")
630 logger.info("Verify that a new group can be formed")
631 form(dev[0], dev[1], reverse_init=True)
634 def test_persistent_group_peer_dropped2(dev):
635 """P2P persistent group formation and re-invocation with peer having dropped group (2)"""
637 invite_from_go(dev[0], dev[1])
639 logger.info("Remove group on the client and try to invite from the GO")
640 dev[1].global_request("REMOVE_NETWORK all")
641 invite(dev[0], dev[1])
642 ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
644 raise Exception("No invitation result seen")
645 if "status=8" not in ev:
646 raise Exception("Unexpected invitation result: " + ev)
647 networks = dev[1].list_networks(p2p=True)
648 if len(networks) > 0:
649 raise Exception("Unexpected network block on client")
651 logger.info("Verify that a new group can be formed")
654 def test_persistent_group_peer_dropped3(dev):
655 """P2P persistent group formation and re-invocation with peer having dropped group (3)"""
656 form(dev[0], dev[1], reverse_init=True)
657 invite_from_cli(dev[0], dev[1])
659 logger.info("Remove group on the GO and try to invite from the client")
660 dev[0].global_request("REMOVE_NETWORK all")
661 invite(dev[1], dev[0], use_listen=False)
662 ev = dev[1].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
664 raise Exception("No invitation result seen")
665 if "status=8" not in ev:
666 raise Exception("Unexpected invitation result: " + ev)
667 networks = dev[1].list_networks(p2p=True)
668 if len(networks) > 0:
669 raise Exception("Unexpected network block on client")
672 logger.info("Verify that a new group can be formed")
673 form(dev[0], dev[1], reverse_init=True, r_listen=False)