tests: TDLS link status test

Add a test case for checking TDLS link status.

Signed-off-by: Oren Givon <oren.givon@intel.com>
This commit is contained in:
Oren Givon 2015-04-28 14:00:51 +03:00 committed by Jouni Malinen
parent 4504621f9c
commit 2380d80493
2 changed files with 36 additions and 0 deletions

View file

@ -147,6 +147,22 @@ def teardown_tdls(sta0, sta1, ap, responder=False, wildcard=False):
tdls_check_ap(sta0, sta1, bssid, addr0, addr1) tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
check_connectivity(sta0, sta1, hapd) check_connectivity(sta0, sta1, hapd)
def check_tdls_link(sta0, sta1, connected=True):
addr0 = sta0.own_addr()
addr1 = sta1.own_addr()
status0 = sta0.tdls_link_status(addr1).rstrip()
status1 = sta1.tdls_link_status(addr0).rstrip()
logger.info("%s: %s" % (sta0.ifname, status0))
logger.info("%s: %s" % (sta1.ifname, status1))
if status0 != status1:
raise Exception("TDLS link status differs between stations")
if "status: connected" in status0:
if not connected:
raise Exception("Expected TDLS link status NOT to be connected")
else:
if connected:
raise Exception("Expected TDLS link status to be connected")
def test_ap_tdls_discovery(dev, apdev): def test_ap_tdls_discovery(dev, apdev):
"""WPA2-PSK AP and two stations using TDLS discovery""" """WPA2-PSK AP and two stations using TDLS discovery"""
hapd = start_ap_wpa2_psk(apdev[0]['ifname']) hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
@ -375,3 +391,16 @@ def test_tdls_chan_switch(dev, apdev):
raise Exception("Could not disable TDLS channel switching") raise Exception("Could not disable TDLS channel switching")
if "FAIL" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + dev[1].own_addr()): if "FAIL" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + dev[1].own_addr()):
raise Exception("TDLS_CANCEL_CHAN_SWITCH accepted even though channel switching was already disabled") raise Exception("TDLS_CANCEL_CHAN_SWITCH accepted even though channel switching was already disabled")
def test_ap_tdls_link_status(dev, apdev):
"""Check TDLS link status between two stations"""
hapd = start_ap_wpa2_psk(apdev[0]['ifname'])
wlantest_setup()
connect_2sta_wpa2_psk(dev, hapd)
check_tdls_link(dev[0], dev[1], connected=False)
setup_tdls(dev[0], dev[1], apdev[0])
check_tdls_link(dev[0], dev[1], connected=True)
teardown_tdls(dev[0], dev[1], apdev[0])
check_tdls_link(dev[0], dev[1], connected=False)
if "FAIL" not in dev[0].request("TDLS_LINK_STATUS foo"):
raise Exception("Unexpected TDLS_LINK_STATUS response for invalid argument")

View file

@ -760,6 +760,13 @@ class WpaSupplicant:
raise Exception("Failed to request TDLS teardown") raise Exception("Failed to request TDLS teardown")
return None return None
def tdls_link_status(self, peer):
cmd = "TDLS_LINK_STATUS " + peer
ret = self.group_request(cmd)
if "FAIL" in ret:
raise Exception("Failed to request TDLS link status")
return ret
def tspecs(self): def tspecs(self):
"""Return (tsid, up) tuples representing current tspecs""" """Return (tsid, up) tuples representing current tspecs"""
res = self.request("WMM_AC_STATUS") res = self.request("WMM_AC_STATUS")