]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: INTERFACE_ADD/REMOVE with vif without creation/removal
authorJouni Malinen <j@w1.fi>
Sat, 4 Apr 2015 08:02:22 +0000 (11:02 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 4 Apr 2015 08:02:22 +0000 (11:02 +0300)
This is also a regression test for INTERFACE_ADD parsing.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_wpas_ctrl.py
tests/hwsim/wpasupplicant.py

index 68bd0b1ef0d27bbe5db0e4b323c92c6a55931dd3..1c84eb064621c9635a2f42ebfb517b97332d5eec 100644 (file)
@@ -1363,3 +1363,27 @@ def test_wpas_ctrl_interface_add(dev, apdev):
     hwsim_utils.test_connectivity(dev[0], hapd)
     dev[0].global_request("INTERFACE_REMOVE " + ifname)
     hwsim_utils.test_connectivity(dev[0], hapd)
+
+def test_wpas_ctrl_interface_add2(dev, apdev):
+    """wpa_supplicant INTERFACE_ADD/REMOVE with vif without creation/removal"""
+    ifname = "test-ext-" + dev[0].ifname
+    try:
+        _test_wpas_ctrl_interface_add2(dev, apdev, ifname)
+    finally:
+        subprocess.call(['iw', 'dev', ifname, 'del'])
+
+def _test_wpas_ctrl_interface_add2(dev, apdev, ifname):
+    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
+    dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
+    hwsim_utils.test_connectivity(dev[0], hapd)
+
+    subprocess.call(['iw', 'dev', dev[0].ifname, 'interface', 'add', ifname,
+                     'type', 'station'])
+    dev[0].interface_add(ifname, set_ifname=False, all_params=True)
+    wpas = WpaSupplicant(ifname=ifname)
+    wpas.connect("open", key_mgmt="NONE", scan_freq="2412")
+    hwsim_utils.test_connectivity(wpas, hapd)
+    hwsim_utils.test_connectivity(dev[0], hapd)
+    del wpas
+    dev[0].global_request("INTERFACE_REMOVE " + ifname)
+    hwsim_utils.test_connectivity(dev[0], hapd)
index 45a813fb26a6ce3819654db4cc2031ef8109e69e..e29b3fc3bd63d89a0673b565dfbb1e19fff1048d 100644 (file)
@@ -54,7 +54,8 @@ class WpaSupplicant:
             self.ifname = None
 
     def interface_add(self, ifname, config="", driver="nl80211",
-                      drv_params=None, br_ifname=None, create=False):
+                      drv_params=None, br_ifname=None, create=False,
+                      set_ifname=True, all_params=False):
         try:
             groups = subprocess.check_output(["id"])
             group = "admin" if "(admin)" in groups else "adm"
@@ -73,9 +74,15 @@ class WpaSupplicant:
                 if not drv_params:
                     cmd += '\t'
             cmd += '\tcreate'
+        if all_params and not create:
+            if not br_ifname:
+                cmd += '\t'
+                if not drv_params:
+                    cmd += '\t'
+            cmd += '\t'
         if "FAIL" in self.global_request(cmd):
             raise Exception("Failed to add a dynamic wpa_supplicant interface")
-        if not create:
+        if not create and set_ifname:
             self.set_ifname(ifname)
 
     def interface_remove(self, ifname):