Browse Source

tests: INTERFACE_ADD/REMOVE with vif without creation/removal

This is also a regression test for INTERFACE_ADD parsing.

Signed-off-by: Jouni Malinen <j@w1.fi>
Jouni Malinen 10 years ago
parent
commit
138bf11852
2 changed files with 33 additions and 2 deletions
  1. 24 0
      tests/hwsim/test_wpas_ctrl.py
  2. 9 2
      tests/hwsim/wpasupplicant.py

+ 24 - 0
tests/hwsim/test_wpas_ctrl.py

@@ -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)

+ 9 - 2
tests/hwsim/wpasupplicant.py

@@ -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):