tests: Do not attach wpa_supplicant monitor interface unnecessarily

There is no need to attach the monitor interface was events when issuing
only a single INTERFACES command.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2016-12-14 13:56:15 +02:00 committed by Jouni Malinen
parent 10f312d4a6
commit bb5d761c2e
2 changed files with 16 additions and 8 deletions

View file

@ -54,7 +54,7 @@ def reset_devs(dev, apdev):
wpas = None wpas = None
try: try:
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False)
ifaces = wpas.global_request("INTERFACES").splitlines() ifaces = wpas.global_request("INTERFACES").splitlines()
for iface in ifaces: for iface in ifaces:
if iface.startswith("wlan"): if iface.startswith("wlan"):

View file

@ -19,7 +19,8 @@ wpas_ctrl = '/var/run/wpa_supplicant'
class WpaSupplicant: class WpaSupplicant:
def __init__(self, ifname=None, global_iface=None, hostname=None, def __init__(self, ifname=None, global_iface=None, hostname=None,
port=9877, global_port=9878): port=9877, global_port=9878, monitor=True):
self.monitor = monitor
self.hostname = hostname self.hostname = hostname
self.group_ifname = None self.group_ifname = None
self.gctrl_mon = None self.gctrl_mon = None
@ -37,15 +38,19 @@ class WpaSupplicant:
self.global_iface = global_iface self.global_iface = global_iface
if global_iface: if global_iface:
self.global_mon = None
if hostname != None: if hostname != None:
self.global_ctrl = wpaspy.Ctrl(hostname, global_port) self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
self.global_mon = wpaspy.Ctrl(hostname, global_port) if self.monitor:
self.global_mon = wpaspy.Ctrl(hostname, global_port)
self.global_dbg = hostname + "/" + str(global_port) + "/" self.global_dbg = hostname + "/" + str(global_port) + "/"
else: else:
self.global_ctrl = wpaspy.Ctrl(global_iface) self.global_ctrl = wpaspy.Ctrl(global_iface)
self.global_mon = wpaspy.Ctrl(global_iface) if self.monitor:
self.global_mon = wpaspy.Ctrl(global_iface)
self.global_dbg = "" self.global_dbg = ""
self.global_mon.attach() if self.monitor:
self.global_mon.attach()
else: else:
self.global_mon = None self.global_mon = None
@ -81,14 +86,17 @@ class WpaSupplicant:
self.ifname = ifname self.ifname = ifname
if hostname != None: if hostname != None:
self.ctrl = wpaspy.Ctrl(hostname, port) self.ctrl = wpaspy.Ctrl(hostname, port)
self.mon = wpaspy.Ctrl(hostname, port) if self.monitor:
self.mon = wpaspy.Ctrl(hostname, port)
self.host = remotehost.Host(hostname, ifname) self.host = remotehost.Host(hostname, ifname)
self.dbg = hostname + "/" + ifname self.dbg = hostname + "/" + ifname
else: else:
self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname)) self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname)) if self.monitor:
self.mon = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))
self.dbg = ifname self.dbg = ifname
self.mon.attach() if self.monitor:
self.mon.attach()
def remove_ifname(self): def remove_ifname(self):
if self.ifname: if self.ifname: