tests: Add a simple wmediumd test
authorJohannes Berg <johannes.berg@intel.com>
Fri, 27 Nov 2015 14:41:37 +0000 (15:41 +0100)
committerJouni Malinen <j@w1.fi>
Fri, 27 Nov 2015 19:11:53 +0000 (21:11 +0200)
If wmediumd is available on the path, test that it can forward
packets between two virtual nodes and that stopping it makes
the regular in-kernel datapath do the needed work again.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
tests/hwsim/test_ap_open.py
tests/hwsim/test_wmediumd.py [new file with mode: 0644]

index 1858475..8142426 100644 (file)
@@ -19,6 +19,9 @@ from wpasupplicant import WpaSupplicant
 
 def test_ap_open(dev, apdev):
     """AP with open mode (no security) configuration"""
+    _test_ap_open(dev, apdev)
+
+def _test_ap_open(dev, apdev):
     hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
                    bg_scan_period="0")
diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
new file mode 100644 (file)
index 0000000..fae0dcd
--- /dev/null
@@ -0,0 +1,44 @@
+# wmediumd sanity checks
+# Copyright (c) 2015, Intel Deutschland GmbH
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import tempfile, os, subprocess, errno
+from utils import HwsimSkip
+from test_ap_open import _test_ap_open
+
+CFG = """
+ifaces :
+{
+    ids = ["%s", "%s" ];
+    links = (
+        (0, 1, 30)
+    );
+};
+"""
+
+def test_wmediumd_simple(dev, apdev):
+    """test a simple wmediumd configuration"""
+    fd, fn = tempfile.mkstemp()
+    try:
+        f = os.fdopen(fd, 'w')
+        f.write(CFG % (apdev[0]['bssid'], dev[0].own_addr()))
+        f.close()
+        try:
+            p = subprocess.Popen(['wmediumd', '-c', fn],
+                                 stdout=open('/dev/null', 'a'),
+                                 stderr=subprocess.STDOUT)
+        except OSError, e:
+            if e.errno == errno.ENOENT:
+                raise HwsimSkip("wmediumd not available")
+            raise
+        try:
+            _test_ap_open(dev, apdev)
+        finally:
+            p.terminate()
+            p.wait()
+        # test that releasing hwsim works correctly
+        _test_ap_open(dev, apdev);
+    finally:
+        os.unlink(fn)