tests: Close wlan5 control interface monitor more explicitly

There were couple of common cases where the control interface for the
dynamic wpa_supplicant instance could have been left in attached state
until Python ends up cleaning up the instance. This could result in
issues if many monitor interface events were queued for that attached
socket. Make this less likely to cause issues by explicitly detaching
and closing control interfaces before moving to the next test case.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-18 17:13:55 +02:00
parent 0efcad2c30
commit a66d2248a0
3 changed files with 16 additions and 2 deletions

View file

@ -48,6 +48,7 @@ def reset_devs(dev, apdev):
print str(e) print str(e)
ok = False ok = False
wpas = None
try: try:
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
ifaces = wpas.global_request("INTERFACES").splitlines() ifaces = wpas.global_request("INTERFACES").splitlines()
@ -56,6 +57,8 @@ def reset_devs(dev, apdev):
wpas.interface_remove(iface) wpas.interface_remove(iface)
except Exception, e: except Exception, e:
pass pass
if wpas:
wpas.close_ctrl()
try: try:
hapd = HostapdGlobal() hapd = HostapdGlobal()
@ -455,14 +458,16 @@ def main():
logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname)) logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname))
logger.info(e) logger.info(e)
result = "FAIL" result = "FAIL"
wpas = None
try: try:
wpas = WpaSupplicant("/tmp/wpas-wlan5") wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
d.dump_monitor()
rename_log(args.logdir, 'log5', name, wpas) rename_log(args.logdir, 'log5', name, wpas)
if not args.no_reset: if not args.no_reset:
wpas.remove_ifname() wpas.remove_ifname()
except Exception, e: except Exception, e:
pass pass
if wpas:
wpas.close_ctrl()
if args.no_reset: if args.no_reset:
print "Leaving devices in current state" print "Leaving devices in current state"
else: else:

View file

@ -22,6 +22,7 @@ def get_wext_interface():
try: try:
wpas.interface_add("wlan5", driver="wext") wpas.interface_add("wlan5", driver="wext")
except Exception, e: except Exception, e:
wpas.close_ctrl()
raise HwsimSkip("WEXT driver support not included in wpa_supplicant") raise HwsimSkip("WEXT driver support not included in wpa_supplicant")
return wpas return wpas
@ -59,6 +60,7 @@ def test_wext_wpa_psk(dev, apdev):
hapd = hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.add_ap(apdev[0]['ifname'], params)
testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname'])
if not os.path.exists(testfile): if not os.path.exists(testfile):
wpas.close_ctrl()
raise HwsimSkip("tkip_mic_test not supported in mac80211") raise HwsimSkip("tkip_mic_test not supported in mac80211")
wpas.connect("wext-wpa-psk", psk="12345678") wpas.connect("wext-wpa-psk", psk="12345678")

View file

@ -33,6 +33,13 @@ class WpaSupplicant:
else: else:
self.global_mon = None self.global_mon = None
def close_ctrl(self):
if self.global_mon:
self.global_mon.detach()
self.global_mon = None
self.global_ctrl = None
self.remove_ifname()
def set_ifname(self, ifname): def set_ifname(self, ifname):
self.ifname = ifname self.ifname = ifname
self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname)) self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))