Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx> --- tests/hwsim/test_wmediumd.py | 146 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py index 8aeacbb..4b4dcd1 100644 --- a/tests/hwsim/test_wmediumd.py +++ b/tests/hwsim/test_wmediumd.py @@ -4,7 +4,7 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. -import tempfile, os, subprocess, errno, hwsim_utils +import tempfile, os, subprocess, errno, hwsim_utils, time from utils import HwsimSkip from wpasupplicant import WpaSupplicant from test_ap_open import _test_ap_open @@ -63,6 +63,35 @@ model: }; """ +CFG4 = """ +ifaces : +{ + ids = ["%s", "%s", "%s", "%s" ]; +}; + +model : +{ + type = "path_loss"; + positions = ( + (-30.0, 0.0), + ( 0.0, 0.0), + ( 0.0, -40.0), + ( 30.0, 0.0) + ); + directions = ( + ( 0.0, 0.0), + ( 0.0, 10.0), + ( 0.0, 10.0), + ( 0.0, 0.0) + ); + tx_powers = (14.0, 14.0, 14.0, 14.0); + + model_name = "log_distance"; + path_loss_exp = 3.5; + xg = 0.0; +}; +""" + def get_wmediumd_version(): if len(LocalVariables.revs) > 0: return LocalVariables.revs; @@ -317,3 +346,118 @@ def _test_wmediumd_path_ttl(dev, ok): dev[i].mesh_group_remove() check_mesh_group_removed(dev[i]) dev[i].dump_monitor() + +def test_wmediumd_path_movement(dev, apdev, params): + """test a mesh path movement""" + # At the start position, 0 and 3 could communicate via 1. + # 0 --- 1 --- 3 + # + # 2 + # + # After 3 sec. 1 and 2 move to y direction by 10meter. + # 0 and 3 could communicate via 1 still. + # + --- 1 --- + + # 0 3 + # + # 2 + # + # After 6 sec. 1 and 2 move to y direction by 20meter. + # 0 and 3 could not communicate with each other. + # 1 + # + # 0 3 + # + # 2 + # + # After 9 sec. 1 and 2 move to y direction by 30meter. + # 0 and 3 could communicate via 2. + # 1 + # + # 0 3 + # + --- 2 --- + + require_wmediumd_version(0, 3, 1) + + local_dev = [] + for i in range(0, 3): + local_dev.append(dev[i]) + + for i in range(5, 6): + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan" + str(i)) + temp_dev = wpas.request("MESH_INTERFACE_ADD ifname=mesh" + str(i)) + if "FAIL" in temp_dev: + raise Exception("MESH_INTERFACE_ADD failed") + local_dev.append(WpaSupplicant(ifname=temp_dev)) + + fd, fn = tempfile.mkstemp() + try: + f = os.fdopen(fd, 'w') + f.write(CFG4 % (local_dev[0].own_addr(), local_dev[1].own_addr(), + local_dev[2].own_addr(), local_dev[3].own_addr())) + f.close() + p = start_wmediumd(fn, params) + try: + _test_wmediumd_path_movement(local_dev, apdev) + finally: + stop_wmediumd(p, params) + finally: + os.unlink(fn) + + for i in range(5, 6): + wpas.interface_remove("wlan" + str(i)) + +def _test_wmediumd_path_movement(dev, apdev): + for i in range(0, 4): + 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, 4): + 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[3]) + + # Test connectivity 0->3 and 3->0 + for i in range(0, 2): + hwsim_utils.test_connectivity(dev[0], dev[3], success_expected=True) + # 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[3].own_addr() + ' ' + dev[1].own_addr()) == -1: + raise Exception("mpath not found on dev0:\n" + data) + if data.find(dev[0].own_addr()) > -1 or \ + data.find(dev[2].own_addr()) > -1: + raise Exception("invalid mpath found on dev0:\n" + data) + time.sleep(3) + + hwsim_utils.test_connectivity(dev[0], dev[3], success_expected=False) + time.sleep(3) + + hwsim_utils.test_connectivity(dev[0], dev[3], success_expected=True) + # 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[2].own_addr() + ' ' + dev[2].own_addr()) == -1 or \ + data.find(dev[3].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) + + # remove mesh groups + for i in range(0, 3): + dev[i].mesh_group_remove() + check_mesh_group_removed(dev[i]) + dev[i].dump_monitor() -- 2.7.4 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap