tests: Add mesh path test
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
parent
d760db19b1
commit
b80130c60b
1 changed files with 104 additions and 1 deletions
|
@ -4,9 +4,12 @@
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
|
||||||
import tempfile, os, subprocess, errno
|
import tempfile, os, subprocess, errno, hwsim_utils
|
||||||
from utils import HwsimSkip
|
from utils import HwsimSkip
|
||||||
from test_ap_open import _test_ap_open
|
from test_ap_open import _test_ap_open
|
||||||
|
from test_wpas_mesh import check_mesh_support, check_mesh_group_added
|
||||||
|
from test_wpas_mesh import check_mesh_peer_connected, add_open_mesh_network
|
||||||
|
from test_wpas_mesh import check_mesh_group_removed
|
||||||
|
|
||||||
CFG = """
|
CFG = """
|
||||||
ifaces :
|
ifaces :
|
||||||
|
@ -18,6 +21,19 @@ ifaces :
|
||||||
};
|
};
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
CFG2 = """
|
||||||
|
ifaces :
|
||||||
|
{
|
||||||
|
ids = ["%s", "%s", "%s"];
|
||||||
|
|
||||||
|
links = (
|
||||||
|
(0, 1, 50),
|
||||||
|
(0, 2, 50),
|
||||||
|
(1, 2, -10)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
"""
|
||||||
|
|
||||||
def output_wmediumd_log(p, params, data):
|
def output_wmediumd_log(p, params, data):
|
||||||
log_file = open(os.path.abspath(os.path.join(params['logdir'],
|
log_file = open(os.path.abspath(os.path.join(params['logdir'],
|
||||||
'wmediumd.log')), 'a')
|
'wmediumd.log')), 'a')
|
||||||
|
@ -67,3 +83,90 @@ def test_wmediumd_simple(dev, apdev, params):
|
||||||
_test_ap_open(dev, apdev)
|
_test_ap_open(dev, apdev)
|
||||||
finally:
|
finally:
|
||||||
os.unlink(fn)
|
os.unlink(fn)
|
||||||
|
|
||||||
|
def test_wmediumd_path_simple(dev, apdev, params):
|
||||||
|
"""test a mesh path"""
|
||||||
|
# 0 and 1 is connected
|
||||||
|
# 0 and 2 is connected
|
||||||
|
# 1 and 2 is not connected
|
||||||
|
# 1 --- 0 --- 2
|
||||||
|
# | |
|
||||||
|
# +-----X-----+
|
||||||
|
# This tests if 1 and 2 can communicate each other via 0.
|
||||||
|
fd, fn = tempfile.mkstemp()
|
||||||
|
try:
|
||||||
|
f = os.fdopen(fd, 'w')
|
||||||
|
f.write(CFG2 % (dev[0].own_addr(), dev[1].own_addr(),
|
||||||
|
dev[2].own_addr()))
|
||||||
|
f.close()
|
||||||
|
p = start_wmediumd(fn, params)
|
||||||
|
try:
|
||||||
|
_test_wmediumd_path_simple(dev, apdev)
|
||||||
|
finally:
|
||||||
|
stop_wmediumd(p, params)
|
||||||
|
finally:
|
||||||
|
os.unlink(fn)
|
||||||
|
|
||||||
|
def _test_wmediumd_path_simple(dev, apdev):
|
||||||
|
for i in range(0, 3):
|
||||||
|
check_mesh_support(dev[i])
|
||||||
|
add_open_mesh_network(dev[i], freq="2462", basic_rates="60 120 240")
|
||||||
|
|
||||||
|
# Check for mesh joined
|
||||||
|
for i in range(0, 3):
|
||||||
|
check_mesh_group_added(dev[i])
|
||||||
|
|
||||||
|
state = dev[i].get_status_field("wpa_state")
|
||||||
|
if state != "COMPLETED":
|
||||||
|
raise Exception("Unexpected wpa_state on dev" + str(i) + ": " + state)
|
||||||
|
|
||||||
|
mode = dev[i].get_status_field("mode")
|
||||||
|
if mode != "mesh":
|
||||||
|
raise Exception("Unexpected mode: " + mode)
|
||||||
|
|
||||||
|
# Check for peer connected
|
||||||
|
check_mesh_peer_connected(dev[0])
|
||||||
|
check_mesh_peer_connected(dev[0])
|
||||||
|
check_mesh_peer_connected(dev[1])
|
||||||
|
check_mesh_peer_connected(dev[2])
|
||||||
|
|
||||||
|
# Test connectivity 1->2 and 2->1
|
||||||
|
hwsim_utils.test_connectivity(dev[1], dev[2])
|
||||||
|
|
||||||
|
# Check mpath table on 0
|
||||||
|
res, data = dev[0].cmd_execute(['iw', dev[0].ifname, 'mpath', 'dump'])
|
||||||
|
if res != 0:
|
||||||
|
raise Exception("iw command failed on dev0")
|
||||||
|
if data.find(dev[1].own_addr() + ' ' + dev[1].own_addr()) == -1 or \
|
||||||
|
data.find(dev[2].own_addr() + ' ' + dev[2].own_addr()) == -1:
|
||||||
|
raise Exception("mpath not found on dev0:\n" + data)
|
||||||
|
if data.find(dev[0].own_addr()) > -1:
|
||||||
|
raise Exception("invalid mpath found on dev0:\n" + data)
|
||||||
|
|
||||||
|
# Check mpath table on 1
|
||||||
|
res, data = dev[1].cmd_execute(['iw', dev[1].ifname, 'mpath', 'dump'])
|
||||||
|
if res != 0:
|
||||||
|
raise Exception("iw command failed on dev1")
|
||||||
|
if data.find(dev[0].own_addr() + ' ' + dev[0].own_addr()) == -1 or \
|
||||||
|
data.find(dev[2].own_addr() + ' ' + dev[0].own_addr()) == -1:
|
||||||
|
raise Exception("mpath not found on dev1:\n" + data)
|
||||||
|
if data.find(dev[2].own_addr() + ' ' + dev[2].own_addr()) > -1 or \
|
||||||
|
data.find(dev[1].own_addr()) > -1:
|
||||||
|
raise Exception("invalid mpath found on dev1:\n" + data)
|
||||||
|
|
||||||
|
# Check mpath table on 2
|
||||||
|
res, data = dev[2].cmd_execute(['iw', dev[2].ifname, 'mpath', 'dump'])
|
||||||
|
if res != 0:
|
||||||
|
raise Exception("iw command failed on dev2")
|
||||||
|
if data.find(dev[0].own_addr() + ' ' + dev[0].own_addr()) == -1 or \
|
||||||
|
data.find(dev[1].own_addr() + ' ' + dev[0].own_addr()) == -1:
|
||||||
|
raise Exception("mpath not found on dev2:\n" + data)
|
||||||
|
if data.find(dev[1].own_addr() + ' ' + dev[1].own_addr()) > -1 or \
|
||||||
|
data.find(dev[2].own_addr()) > -1:
|
||||||
|
raise Exception("invalid mpath found on dev2:\n" + data)
|
||||||
|
|
||||||
|
# remove mesh groups
|
||||||
|
for i in range(0, 3):
|
||||||
|
dev[i].mesh_group_remove()
|
||||||
|
check_mesh_group_removed(dev[i])
|
||||||
|
dev[i].dump_monitor()
|
||||||
|
|
Loading…
Reference in a new issue