From d2b84e430c08f98a7549d18a98a894b17d0f7683 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 8 Feb 2015 12:18:03 +0200 Subject: [PATCH] tests: P2P_CONNECT-auto not finding GO This is a regression test for an earlier bug that resulted in using freed memory after a P2P group interface was removed as part of fallback-to-GO-Negotiation in P2P_CONNECT-auto. Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_autogo.py | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index b35974143..a6d030e2e 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -476,3 +476,39 @@ def test_presence_req_on_group_interface(dev): raise Exception("Timeout while waiting for Presence Response") dev[0].remove_group() dev[1].wait_go_ending_session() + +def test_autogo_join_auto_go_not_found(dev): + """P2P_CONNECT-auto not finding GO""" + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5") + wpas.request("P2P_SET listen_channel 1") + wpas.global_request("SET p2p_no_group_iface 0") + autogo(wpas, freq=2412) + addr = wpas.p2p_dev_addr() + bssid = wpas.p2p_interface_addr() + + dev[1].global_request("SET p2p_no_group_iface 0") + dev[1].scan_for_bss(bssid, freq=2412) + # This makes the GO not show up in the scan iteration following the + # P2P_CONNECT command by stopping beaconing and handling Probe Request + # frames externally (but not really replying to them). P2P listen mode is + # needed to keep the GO listening on the operating channel for the PD + # exchange. + if "OK" not in wpas.group_request("STOP_AP"): + raise Exception("STOP_AP failed") + wpas.group_request("SET ext_mgmt_frame_handling 1") + wpas.p2p_listen() + time.sleep(0.02) + dev[1].global_request("P2P_CONNECT " + addr + " pbc auto") + + ev = dev[1].wait_group_event(["P2P-FALLBACK-TO-GO-NEG-ENABLED"], 15) + if ev is None: + raise Exception("Could not trigger old-scan-only case") + return + + ev = dev[1].wait_group_event(["P2P-FALLBACK-TO-GO-NEG"], 15) + wpas.remove_group() + if ev is None: + raise Exception("Fallback to GO Negotiation not seen") + if "reason=GO-not-found" not in ev: + raise Exception("Unexpected reason for fallback: " + ev)