tests: Add test_wpas_mesh test cases
This wpa_supplicant tests include basic tests for: - Mesh scan - Mesh group add/remove - Mesh peer connected/disconnected - Add/Set/Remove to test mesh mode network - Open mesh connectivity test - Secure mesh connectivity test - no_auto_peer Signed-off-by: Jason Mobarak <x@jason.mobarak.name> [no_auto_peer test by: Javier Cardona <javier@cozybit.com> Signed-off-by: Javier Lopez <jlopex@gmail.com>
This commit is contained in:
parent
9e5e03d77e
commit
68157c0674
4 changed files with 352 additions and 1 deletions
|
@ -76,6 +76,7 @@ CONFIG_LIBNL32=y
|
|||
CONFIG_IBSS_RSN=y
|
||||
|
||||
CONFIG_AP=y
|
||||
CONFIG_MESH=y
|
||||
CONFIG_P2P=y
|
||||
CONFIG_WIFI_DISPLAY=y
|
||||
|
||||
|
|
332
tests/hwsim/test_wpas_mesh.py
Normal file
332
tests/hwsim/test_wpas_mesh.py
Normal file
|
@ -0,0 +1,332 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# wpa_supplicant mesh mode tests
|
||||
# Copyright (c) 2014, cozybit Inc.
|
||||
#
|
||||
# This software may be distributed under the terms of the BSD license.
|
||||
# See README for more details.
|
||||
|
||||
|
||||
def check_mesh_scan(dev, params, other_started=False):
|
||||
if not other_started:
|
||||
dev.dump_monitor()
|
||||
id = dev.request("SCAN " + params)
|
||||
if "FAIL" in id:
|
||||
raise Exception("Failed to start scan")
|
||||
id = int(id)
|
||||
|
||||
if other_started:
|
||||
ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
|
||||
if ev is None:
|
||||
raise Exception("Other scan did not start")
|
||||
if "id=" + str(id) in ev:
|
||||
raise Exception("Own scan id unexpectedly included in start event")
|
||||
|
||||
ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
|
||||
if ev is None:
|
||||
raise Exception("Other scan did not complete")
|
||||
if "id=" + str(id) in ev:
|
||||
raise Exception(
|
||||
"Own scan id unexpectedly included in completed event")
|
||||
|
||||
ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
|
||||
if ev is None:
|
||||
raise Exception("Scan did not start")
|
||||
if "id=" + str(id) not in ev:
|
||||
raise Exception("Scan id not included in start event")
|
||||
|
||||
ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
|
||||
if ev is None:
|
||||
raise Exception("Scan did not complete")
|
||||
if "id=" + str(id) not in ev:
|
||||
raise Exception("Scan id not included in completed event")
|
||||
|
||||
res = dev.request("SCAN_RESULTS")
|
||||
|
||||
if not res.find("[MESH]"):
|
||||
raise Exception("Scan did not contain a MESH network")
|
||||
|
||||
|
||||
def check_mesh_group_added(dev):
|
||||
ev = dev.wait_event(["MESH-GROUP-STARTED"])
|
||||
if ev is None:
|
||||
raise Exception("Test exception: Couldn't join mesh")
|
||||
|
||||
|
||||
def check_mesh_group_removed(dev):
|
||||
ev = dev.wait_event(["MESH-GROUP-REMOVED"])
|
||||
if ev is None:
|
||||
raise Exception("Test exception: Couldn't leave mesh")
|
||||
|
||||
|
||||
def check_mesh_peer_connected(dev):
|
||||
ev = dev.wait_event(["MESH-PEER-CONNECTED"])
|
||||
if ev is None:
|
||||
raise Exception("Test exception: Remote peer did not connect.")
|
||||
|
||||
|
||||
def check_mesh_peer_disconnected(dev):
|
||||
ev = dev.wait_event(["MESH-PEER-DISCONNECTED"])
|
||||
if ev is None:
|
||||
raise Exception("Test exception: Peer disconnect event not detected.")
|
||||
|
||||
|
||||
def test_wpas_add_set_remove_support(dev):
|
||||
"""wpa_supplicant MESH add/set/remove network support"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].remove_network(id)
|
||||
|
||||
|
||||
def test_wpas_mesh_group_added(dev):
|
||||
"""wpa_supplicant MESH group add"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
# Check for MESH-GROUP-STARTED event
|
||||
check_mesh_group_added(dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_group_remove(dev):
|
||||
"""wpa_supplicant MESH group remove"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
# Check for MESH-GROUP-STARTED event
|
||||
check_mesh_group_added(dev[0])
|
||||
dev[0].mesh_group_remove()
|
||||
# Check for MESH-GROUP-REMOVED event
|
||||
check_mesh_group_removed(dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_peer_connected(dev):
|
||||
"""wpa_supplicant MESH peer connected"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[1].set_network(id, "key_mgmt", "NONE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
|
||||
def test_wpas_mesh_peer_disconnected(dev):
|
||||
"""wpa_supplicant MESH peer disconnected"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[1].set_network(id, "key_mgmt", "NONE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
# Remove group on dev 1
|
||||
dev[1].mesh_group_remove()
|
||||
# Device 0 should get a disconnection event
|
||||
check_mesh_peer_disconnected(dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_mode_scan(dev):
|
||||
"""wpa_supplicant MESH scan support"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[1].set_network(id, "key_mgmt", "NONE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for Mesh scan
|
||||
check_mesh_scan(dev[0], "use_id=1")
|
||||
|
||||
|
||||
def wrap_wpas_mesh_test(test, dev, apdev):
|
||||
import hwsim_utils
|
||||
|
||||
def _test_connectivity(dev1, dev2):
|
||||
return hwsim_utils.test_connectivity(dev1, dev2)
|
||||
|
||||
return test(dev, apdev, _test_connectivity)
|
||||
|
||||
|
||||
def _test_wpas_mesh_open(dev, apdev, test_connectivity):
|
||||
"""wpa_supplicant open MESH network connectivity"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[1].set_network(id, "key_mgmt", "NONE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
# Test connectivity 0->1 and 1->0
|
||||
test_connectivity(dev[0], dev[1])
|
||||
test_connectivity(dev[1], dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_open(dev, apdev):
|
||||
return wrap_wpas_mesh_test(_test_wpas_mesh_open, dev, apdev)
|
||||
|
||||
|
||||
def _test_wpas_mesh_open_no_auto(dev, apdev, test_connectivity):
|
||||
"""wpa_supplicant open MESH network connectivity"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[0].set_network(id, "key_mgmt", "NONE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-open")
|
||||
dev[1].set_network(id, "key_mgmt", "NONE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].set_network(id, "no_auto_peer", "1")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
# Test connectivity 0->1 and 1->0
|
||||
test_connectivity(dev[0], dev[1])
|
||||
test_connectivity(dev[1], dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_open_no_auto(dev, apdev):
|
||||
return wrap_wpas_mesh_test(_test_wpas_mesh_open_no_auto, dev, apdev)
|
||||
|
||||
|
||||
def _test_wpas_mesh_secure(dev, apdev, test_connectivity):
|
||||
"""wpa_supplicant secure MESH network connectivity"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-sec")
|
||||
dev[0].set_network(id, "key_mgmt", "SAE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].set_network_quoted(id, "psk", "thisismypassphrase!")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-sec")
|
||||
dev[1].set_network(id, "key_mgmt", "SAE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].set_network_quoted(id, "psk", "thisismypassphrase!")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
# Test connectivity 0->1 and 1->0
|
||||
test_connectivity(dev[0], dev[1])
|
||||
test_connectivity(dev[1], dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_secure(dev, apdev):
|
||||
return wrap_wpas_mesh_test(_test_wpas_mesh_secure, dev, apdev)
|
||||
|
||||
|
||||
def _test_wpas_mesh_secure_no_auto(dev, apdev, test_connectivity):
|
||||
"""wpa_supplicant secure MESH network connectivity"""
|
||||
id = dev[0].add_network()
|
||||
dev[0].set_network(id, "mode", "5")
|
||||
dev[0].set_network_quoted(id, "ssid", "wpas-mesh-sec")
|
||||
dev[0].set_network(id, "key_mgmt", "SAE")
|
||||
dev[0].set_network(id, "frequency", "2412")
|
||||
dev[0].set_network_quoted(id, "psk", "thisismypassphrase!")
|
||||
dev[0].mesh_group_add(id)
|
||||
|
||||
id = dev[1].add_network()
|
||||
dev[1].set_network(id, "mode", "5")
|
||||
dev[1].set_network_quoted(id, "ssid", "wpas-mesh-sec")
|
||||
dev[1].set_network(id, "key_mgmt", "SAE")
|
||||
dev[1].set_network(id, "frequency", "2412")
|
||||
dev[1].set_network_quoted(id, "psk", "thisismypassphrase!")
|
||||
dev[1].set_network(id, "no_auto_peer", "1")
|
||||
dev[1].mesh_group_add(id)
|
||||
|
||||
# Check for mesh joined
|
||||
check_mesh_group_added(dev[0])
|
||||
check_mesh_group_added(dev[1])
|
||||
|
||||
# Check for peer connected
|
||||
check_mesh_peer_connected(dev[0])
|
||||
check_mesh_peer_connected(dev[1])
|
||||
|
||||
# Test connectivity 0->1 and 1->0
|
||||
test_connectivity(dev[0], dev[1])
|
||||
test_connectivity(dev[1], dev[0])
|
||||
|
||||
|
||||
def test_wpas_mesh_secure_no_auto(dev, apdev):
|
||||
return wrap_wpas_mesh_test(_test_wpas_mesh_secure_no_auto, dev, apdev)
|
|
@ -606,7 +606,7 @@ CONFIG_MAC80211_RC_MINSTREL=y
|
|||
CONFIG_MAC80211_RC_MINSTREL_HT=y
|
||||
CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
|
||||
CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
|
||||
# CONFIG_MAC80211_MESH is not set
|
||||
CONFIG_MAC80211_MESH=y
|
||||
CONFIG_MAC80211_DEBUGFS=y
|
||||
CONFIG_MAC80211_MESSAGE_TRACING=y
|
||||
CONFIG_MAC80211_DEBUG_MENU=y
|
||||
|
@ -617,6 +617,12 @@ CONFIG_MAC80211_STA_DEBUG=y
|
|||
CONFIG_MAC80211_HT_DEBUG=y
|
||||
CONFIG_MAC80211_IBSS_DEBUG=y
|
||||
CONFIG_MAC80211_PS_DEBUG=y
|
||||
# CONFIG_MAC80211_MPL_DEBUG is not set
|
||||
# CONFIG_MAC80211_MPATH_DEBUG is not set
|
||||
# CONFIG_MAC80211_MHWMP_DEBUG is not set
|
||||
# CONFIG_MAC80211_MESH_SYNC_DEBUG is not set
|
||||
# CONFIG_MAC80211_MESH_CSA_DEBUG is not set
|
||||
# CONFIG_MAC80211_MESH_PS_DEBUG is not set
|
||||
CONFIG_MAC80211_TDLS_DEBUG=y
|
||||
# CONFIG_MAC80211_DEBUG_COUNTERS is not set
|
||||
# CONFIG_WIMAX is not set
|
||||
|
|
|
@ -257,6 +257,18 @@ class WpaSupplicant:
|
|||
raise Exception("SELECT_NETWORK failed")
|
||||
return None
|
||||
|
||||
def mesh_group_add(self, id):
|
||||
id = self.request("MESH_GROUP_ADD " + str(id))
|
||||
if "FAIL" in id:
|
||||
raise Exception("MESH_GROUP_ADD failed")
|
||||
return None
|
||||
|
||||
def mesh_group_remove(self):
|
||||
id = self.request("MESH_GROUP_REMOVE " + str(self.ifname))
|
||||
if "FAIL" in id:
|
||||
raise Exception("MESH_GROUP_REMOVE failed")
|
||||
return None
|
||||
|
||||
def connect_network(self, id, timeout=10):
|
||||
self.dump_monitor()
|
||||
self.select_network(id)
|
||||
|
|
Loading…
Reference in a new issue