From ce8ca2f9a0bc75c034b20ee544a0f6914b2ed9e6 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 2 Jan 2015 22:12:38 +0200 Subject: [PATCH] tests: Make wpas_mesh_max_peering more robust The previous version was enabling all three stations at the same time and left dev[1] and dev[2] competing on getting connected with dev[0] that allowed only one pairing. This was not exactly robust and the pass criteria depended on an extra event from either dev[1] or dev[2]. Fix that by first connecting dev[0] and dev[1] and only after that, start dev[2]. This allows proper validation of both the peering limit on dev[0] and no extra event on dev[2]. Signed-off-by: Jouni Malinen --- tests/hwsim/test_wpas_mesh.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_wpas_mesh.py b/tests/hwsim/test_wpas_mesh.py index 06f4c2bb4..08baeb6ab 100644 --- a/tests/hwsim/test_wpas_mesh.py +++ b/tests/hwsim/test_wpas_mesh.py @@ -459,14 +459,18 @@ def test_wpas_mesh_max_peering(dev, apdev): return "skip" try: dev[0].request("SET max_peer_links 1") - for i in range(3): - add_open_mesh_network(dev[i]) - for i in range(3): + # first, connect dev[0] and dev[1] + add_open_mesh_network(dev[0]) + add_open_mesh_network(dev[1]) + for i in range(2): ev = dev[i].wait_event(["MESH-PEER-CONNECTED"]) if ev is None: raise Exception("dev%d did not connect with any peer" % i) + # add dev[2] which will try to connect with both dev[0] and dev[1], + # but can complete connection only with dev[1] + add_open_mesh_network(dev[2]) for i in range(1, 3): ev = dev[i].wait_event(["MESH-PEER-CONNECTED"]) if ev is None: @@ -476,6 +480,10 @@ def test_wpas_mesh_max_peering(dev, apdev): if ev is not None: raise Exception("dev0 connection beyond max peering limit") + ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1) + if ev is not None: + raise Exception("dev2 reported unexpected peering: " + ev) + for i in range(3): dev[i].mesh_group_remove() check_mesh_group_removed(dev[i])