diff mbox

[v2] tests: add a simple wmediumd test

Message ID 1448635297-26272-1-git-send-email-johannes@sipsolutions.net
State Accepted
Headers show

Commit Message

Johannes Berg Nov. 27, 2015, 2:41 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

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_wmediumd.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 tests/hwsim/test_wmediumd.py

Comments

Jouni Malinen Nov. 27, 2015, 9:26 p.m. UTC | #1
On Fri, Nov 27, 2015 at 03:41:37PM +0100, Johannes Berg wrote:
> 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.

Thanks, applied with a small fix:

> diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
> @@ -0,0 +1,44 @@
> +from test_ap_open import test_ap_open

This is problematic due to the way the list of test cases is generated.
'ap_open' ends up in that list twice with this and that test case ends
up getting executed twice. I replaced this with a helper function that
does not start with the magic 'test_' prefix.
diff mbox

Patch

diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
new file mode 100644
index 000000000000..dd52f672ba7d
--- /dev/null
+++ b/tests/hwsim/test_wmediumd.py
@@ -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)