diff mbox

[v2,2/2] tests: Add mesh path test

Message ID 1487732646-4481-2-git-send-email-masashi.honma@gmail.com
State Changes Requested
Headers show

Commit Message

Masashi Honma Feb. 22, 2017, 3:04 a.m. UTC
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 tests/hwsim/test_wmediumd.py | 82 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Feb. 25, 2017, 8:15 a.m. UTC | #1
On Wed, Feb 22, 2017 at 12:04:06PM +0900, Masashi Honma wrote:
> diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py

> +def test_wmediumd_path(dev, apdev, params):
> +    """test a mesh path"""

> +            p = subprocess.Popen(['wmediumd', '-l', '6', '-c', fn],
> +                                 stdout=open(os.path.abspath(os.path.join(params['logdir'], 'wmediumd.log')), 'a'),
> +                                 stderr=subprocess.STDOUT)

This has the same issue as the previous test case, i.e., it does not
work with older wmediumd versions and claims PASS even when wmediumd
could not actually be started.
Masashi Honma Feb. 27, 2017, 1:37 a.m. UTC | #2
On 2017/02/25 17:15, Jouni Malinen wrote:
> On Wed, Feb 22, 2017 at 12:04:06PM +0900, Masashi Honma wrote:
>> diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
>
>> +def test_wmediumd_path(dev, apdev, params):
>> +    """test a mesh path"""
>
>> +            p = subprocess.Popen(['wmediumd', '-l', '6', '-c', fn],
>> +                                 stdout=open(os.path.abspath(os.path.join(params['logdir'], 'wmediumd.log')), 'a'),
>> +                                 stderr=subprocess.STDOUT)
>
> This has the same issue as the previous test case, i.e., it does not
> work with older wmediumd versions and claims PASS even when wmediumd
> could not actually be started.

I see. I will fix both.

Masashi Honma.
diff mbox

Patch

diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
index 42cb9c9..75d6383 100644
--- a/tests/hwsim/test_wmediumd.py
+++ b/tests/hwsim/test_wmediumd.py
@@ -4,9 +4,11 @@ 
 # This software may be distributed under the terms of the BSD license.
 # See README for more details.
 
-import tempfile, os, subprocess, errno
+import tempfile, os, subprocess, errno, hwsim_utils
 from utils import HwsimSkip
 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
 
 CFG = """
 ifaces :
@@ -18,6 +20,23 @@  ifaces :
 };
 """
 
+CFG2 = """
+ifaces :
+{
+       ids = [
+               "02:00:00:00:00:00",
+               "02:00:00:00:01:00",
+               "02:00:00:00:02:00"
+       ];
+
+       links = (
+               (0, 1, 50),
+               (0, 2, 50),
+               (1, 2, -10)
+       );
+};
+"""
+
 def test_wmediumd_simple(dev, apdev, params):
     """test a simple wmediumd configuration"""
     fd, fn = tempfile.mkstemp()
@@ -42,3 +61,64 @@  def test_wmediumd_simple(dev, apdev, params):
         _test_ap_open(dev, apdev)
     finally:
         os.unlink(fn)
+
+def test_wmediumd_path(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)
+        f.close()
+        try:
+            p = subprocess.Popen(['wmediumd', '-l', '6', '-c', fn],
+                                 stdout=open(os.path.abspath(os.path.join(params['logdir'], 'wmediumd.log')), 'a'),
+                                 stderr=subprocess.STDOUT)
+        except OSError, e:
+            if e.errno == errno.ENOENT:
+                raise HwsimSkip("wmediumd not available")
+            raise
+        try:
+            _test_wmediumd_path(dev, apdev)
+        finally:
+            p.terminate()
+            p.wait()
+    finally:
+        os.unlink(fn)
+
+def _test_wmediumd_path(dev, apdev):
+    check_mesh_support(dev[0])
+    add_open_mesh_network(dev[0], freq="2462", basic_rates="60 120 240")
+    add_open_mesh_network(dev[1], freq="2462", basic_rates="60 120 240")
+    add_open_mesh_network(dev[2], freq="2462", basic_rates="60 120 240")
+
+    # Check for mesh joined
+    check_mesh_group_added(dev[0])
+    check_mesh_group_added(dev[1])
+    check_mesh_group_added(dev[2])
+
+    # 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])
+
+    state = dev[0].get_status_field("wpa_state")
+    if state != "COMPLETED":
+        raise Exception("Unexpected wpa_state on dev0: " + state)
+    state = dev[1].get_status_field("wpa_state")
+    if state != "COMPLETED":
+        raise Exception("Unexpected wpa_state on dev1: " + state)
+
+    mode = dev[0].get_status_field("mode")
+    if mode != "mesh":
+        raise Exception("Unexpected mode: " + mode)