tests: INTERFACE_ADD/REMOVE with vif addition/removal

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2015-03-26 20:43:11 +02:00 committed by Jouni Malinen
parent efa232f915
commit 25f2cb618c
2 changed files with 25 additions and 2 deletions

View file

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

View file

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