From 7cb08cdbd6441172b79e0de116d8d8158ea87041 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 9 Mar 2013 18:24:32 +0200 Subject: [PATCH] tests: Add a test case for using TDLS in a P2P group Signed-hostap: Jouni Malinen --- tests/hwsim/test_p2p_autogo.py | 18 ++++++++++++++++++ tests/hwsim/wpasupplicant.py | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index 5272934b4..da568e19c 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -6,6 +6,7 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +import time import logging logger = logging.getLogger(__name__) @@ -42,6 +43,23 @@ def test_autogo_2cli(dev): dev[1].remove_group() dev[0].remove_group() +def test_autogo_tdls(dev): + autogo(dev[0]) + connect_cli(dev[0], dev[1]) + connect_cli(dev[0], dev[2]) + hwsim_utils.test_connectivity_p2p(dev[1], dev[2]) + addr2 = dev[2].p2p_interface_addr() + dev[1].tdls_setup(addr2) + time.sleep(1) + hwsim_utils.test_connectivity_p2p(dev[1], dev[2]) + dev[1].tdls_teardown(addr2) + time.sleep(1) + hwsim_utils.test_connectivity_p2p(dev[1], dev[2]) + dev[2].remove_group() + dev[1].remove_group() + dev[0].remove_group() + def add_tests(tests): tests.append(test_autogo) tests.append(test_autogo_2cli) + tests.append(test_autogo_tdls) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index abb87c3c8..8a93f9eac 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -54,9 +54,21 @@ class WpaSupplicant: return value return None + def get_group_status(self, field): + res = self.group_request("STATUS") + lines = res.splitlines() + for l in lines: + [name,value] = l.split('=', 1) + if name == field: + return value + return None + def p2p_dev_addr(self): return self.get_status("p2p_device_address") + def p2p_interface_addr(self): + return self.get_group_status("address") + def p2p_listen(self): return self.request("P2P_LISTEN") @@ -225,3 +237,15 @@ class WpaSupplicant: self.dump_monitor() return self.group_form_result(ev) raise Exception("P2P_CONNECT(join) failed") + + def tdls_setup(self, peer): + cmd = "TDLS_SETUP " + peer + if "FAIL" in self.group_request(cmd): + raise Exception("Failed to request TDLS setup") + return None + + def tdls_teardown(self, peer): + cmd = "TDLS_TEARDOWN " + peer + if "FAIL" in self.group_request(cmd): + raise Exception("Failed to request TDLS teardown") + return None