From 926404a6b22dcd6e49067b85589185bcb2271565 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 5 Sep 2015 21:58:18 +0300 Subject: [PATCH] tests: WPS config method update for WPS and P2P Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_wps.py | 13 +++++++++++++ tests/hwsim/test_p2p_discovery.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 7dfc622f6..25ab2a3a7 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -5309,3 +5309,16 @@ def test_ap_wps_adv_oom(dev, apdev): with alloc_fail(hapd, 1, "ssdp_listener_start"): if "FAIL" not in hapd.request("ENABLE"): raise Exception("ENABLE succeeded during OOM") + +def test_wps_config_methods(dev): + """WPS config method update""" + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5") + if "OK" not in wpas.request("SET config_methods display label"): + raise Exception("Failed to set config_methods") + if wpas.request("GET config_methods").strip() != "display label": + raise Exception("config_methods were not updated") + if "OK" not in wpas.request("SET config_methods "): + raise Exception("Failed to clear config_methods") + if wpas.request("GET config_methods").strip() != "": + raise Exception("config_methods were not cleared") diff --git a/tests/hwsim/test_p2p_discovery.py b/tests/hwsim/test_p2p_discovery.py index 55d0f4d4a..fbd3f8356 100644 --- a/tests/hwsim/test_p2p_discovery.py +++ b/tests/hwsim/test_p2p_discovery.py @@ -444,3 +444,34 @@ def test_p2p_listen_and_scan(dev): ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15) if ev is None: raise Exception("Scan timed out") + +def test_p2p_config_methods(dev): + """P2P and WPS config method update""" + addr0 = dev[0].p2p_dev_addr() + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5") + addr1 = wpas.p2p_dev_addr() + + if "OK" not in wpas.request("SET config_methods keypad virtual_push_button"): + raise Exception("Failed to set config_methods") + + wpas.p2p_listen() + if not dev[0].discover_peer(addr1): + raise Exception("Device discovery timed out") + dev[0].p2p_stop_find() + peer = dev[0].get_peer(addr1) + if peer['config_methods'] != '0x180': + raise Exception("Unexpected peer config methods(1): " + peer['config_methods']) + dev[0].global_request("P2P_FLUSH") + + if "OK" not in wpas.request("SET config_methods virtual_display"): + raise Exception("Failed to set config_methods") + + if not dev[0].discover_peer(addr1): + raise Exception("Device discovery timed out") + dev[0].p2p_stop_find() + peer = dev[0].get_peer(addr1) + if peer['config_methods'] != '0x8': + raise Exception("Unexpected peer config methods(2): " + peer['config_methods']) + + wpas.p2p_stop_find()