tests: Avoid confusing "DETACH failed" exception prints in D-Bus tests

dbus_p2p_go_neg_init, dbus_p2p_group_idle_timeout, and
dbus_p2p_group_termination_by_go could end up print a "DETACH failed"
exception as a warning from WpaSupplicant.__del__ for the dev1 instance
used within the TestDbusP2p class. This did not cause the test cases to
fail, but the output is a bit confusing, so clean this up be explicitly
closing the control interface monitor sockets and furthermore by
ignoring the "DETACH failed" exception within __del__.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-04-15 20:13:28 +03:00 committed by Jouni Malinen
parent c975c667f8
commit 6541b9dbe7
2 changed files with 23 additions and 3 deletions

View file

@ -4593,6 +4593,9 @@ def test_dbus_p2p_go_neg_init(dev, apdev):
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
dev1.close_monitor_global()
dev1.close_monitor_mon()
dev1 = None
def goNegotiationSuccess(self, properties):
logger.debug("goNegotiationSuccess: properties=%s" % str(properties))
@ -4603,9 +4606,10 @@ def test_dbus_p2p_go_neg_init(dev, apdev):
properties['interface_object'])
group_p2p = dbus.Interface(g_if_obj, WPAS_DBUS_IFACE_P2PDEVICE)
group_p2p.Disconnect()
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1', monitor=False)
dev1.group_form_result(self.sta_group_ev)
dev1.remove_group()
dev1 = None
def groupFinished(self, properties):
logger.debug("groupFinished: " + str(properties))
@ -4688,6 +4692,9 @@ def test_dbus_p2p_group_termination_by_go(dev, apdev):
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
dev1.close_monitor_global()
dev1.close_monitor_mon()
dev1 = None
def goNegotiationSuccess(self, properties):
logger.debug("goNegotiationSuccess: properties=%s" % str(properties))
@ -4696,7 +4703,7 @@ def test_dbus_p2p_group_termination_by_go(dev, apdev):
logger.debug("groupStarted: " + str(properties))
g_if_obj = bus.get_object(WPAS_DBUS_SERVICE,
properties['interface_object'])
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1', monitor=False)
dev1.group_form_result(self.sta_group_ev)
dev1.remove_group()
@ -4784,6 +4791,9 @@ def _test_dbus_p2p_group_idle_timeout(dev, apdev):
if ev is None:
raise Exception("Group formation timed out")
self.sta_group_ev = ev
dev1.close_monitor_global()
dev1.close_monitor_mon()
dev1 = None
def goNegotiationSuccess(self, properties):
logger.debug("goNegotiationSuccess: properties=%s" % str(properties))
@ -4793,7 +4803,7 @@ def _test_dbus_p2p_group_idle_timeout(dev, apdev):
self.group_started = True
g_if_obj = bus.get_object(WPAS_DBUS_SERVICE,
properties['interface_object'])
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1', monitor=False)
dev1.group_form_result(self.sta_group_ev)
ifaddr = dev1.group_request("STA-FIRST").splitlines()[0]
# Force disassociation with different reason code so that the

View file

@ -85,6 +85,11 @@ class WpaSupplicant:
self.mon.detach()
except ConnectionRefusedError:
pass
except Exception as e:
if str(e) == "DETACH failed":
pass
else:
raise
del self.mon
self.mon = None
@ -101,6 +106,11 @@ class WpaSupplicant:
self.global_mon.detach()
except ConnectionRefusedError:
pass
except Exception as e:
if str(e) == "DETACH failed":
pass
else:
raise
del self.global_mon
self.global_mon = None