From 5434f07c2047ce07dcee5f466a34c82bd515338f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 4 Jan 2015 21:45:18 +0200 Subject: [PATCH] tests: TDLS channel switching Verify correct behavior with invalid commands. In addition, allow minor mac80211_hwsim modifications to be used to enable testing of the driver interface to enable and disable channel switching. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_tdls.py | 17 +++++++++++++++++ tests/hwsim/test_wpas_ctrl.py | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index f4ba292d1..e1bb76e69 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -358,3 +358,20 @@ def test_ap_open_tdls_vht(dev, apdev): subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() dev[1].flush_scan_cache() + +def test_tdls_chan_switch(dev, apdev): + """Open AP and two stations using TDLS""" + flags = int(dev[0].get_driver_status_field('capa.flags'), 16) + if flags & 0x800000000 == 0: + logger.info("Driver does not support TDLS channel switching") + return "skip" + + hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) + connect_2sta_open(dev, hapd) + setup_tdls(dev[0], dev[1], apdev[0]) + if "OK" not in dev[0].request("TDLS_CHAN_SWITCH " + dev[1].own_addr() + " 81 2462"): + raise Exception("Failed to enable TDLS channel switching") + if "OK" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + dev[1].own_addr()): + raise Exception("Could not disable TDLS channel switching") + 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") diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index dbb2e8db2..12f14a505 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -496,6 +496,18 @@ def test_wpas_ctrl_tdls_discover(dev): if "FAIL" not in dev[0].request("TDLS_DISCOVER 00:11:22:33:44:55"): raise Exception("Unexpected success on TDLS_DISCOVER") +def test_wpas_ctrl_tdls_chan_switch(dev): + """wpa_supplicant ctrl_iface tdls_chan_switch error cases""" + for args in [ '', '00:11:22:33:44:55' ]: + if "FAIL" not in dev[0].request("TDLS_CANCEL_CHAN_SWITCH " + args): + raise Exception("Unexpected success on invalid TDLS_CANCEL_CHAN_SWITCH: " + args) + + for args in [ '', 'foo ', '00:11:22:33:44:55 ', '00:11:22:33:44:55 q', + '00:11:22:33:44:55 81', '00:11:22:33:44:55 81 1234', + '00:11:22:33:44:55 81 1234 center_freq1=234 center_freq2=345 bandwidth=456 sec_channel_offset=567 ht vht' ]: + if "FAIL" not in dev[0].request("TDLS_CHAN_SWITCH " + args): + raise Exception("Unexpected success on invalid TDLS_CHAN_SWITCH: " + args) + def test_wpas_ctrl_addr(dev): """wpa_supplicant ctrl_iface invalid address""" if "FAIL" not in dev[0].request("TDLS_SETUP "):