diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index 00bde0a8a..68bd0b1ef 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -10,6 +10,7 @@ import subprocess import time import hostapd +import hwsim_utils from wpasupplicant import WpaSupplicant from utils import alloc_fail @@ -1347,3 +1348,18 @@ def test_wpas_ctrl_dump(dev, apdev): raise Exception("Mismatch in config field " + field) if "beacon_int" not in vals: raise Exception("Missing config field") + +def test_wpas_ctrl_interface_add(dev, apdev): + """wpa_supplicant INTERFACE_ADD/REMOVE with vif creation/removal""" + 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) + + ifname = "test-" + dev[0].ifname + dev[0].interface_add(ifname, create=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) + dev[0].global_request("INTERFACE_REMOVE " + ifname) + hwsim_utils.test_connectivity(dev[0], hapd) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 9565b9d4f..6481b0719 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -54,7 +54,7 @@ class WpaSupplicant: self.ifname = None def interface_add(self, ifname, config="", driver="nl80211", - drv_params=None, br_ifname=None): + drv_params=None, br_ifname=None, create=False): try: groups = subprocess.check_output(["id"]) group = "admin" if "(admin)" in groups else "adm" @@ -67,9 +67,16 @@ class WpaSupplicant: if not drv_params: cmd += '\t' cmd += '\t' + br_ifname + if create: + if not br_ifname: + cmd += '\t' + if not drv_params: + cmd += '\t' + cmd += '\tcreate' if "FAIL" in self.global_request(cmd): raise Exception("Failed to add a dynamic wpa_supplicant interface") - self.set_ifname(ifname) + if not create: + self.set_ifname(ifname) def interface_remove(self, ifname): self.remove_ifname()