From: Jouni Malinen Date: Mon, 15 Apr 2019 17:13:28 +0000 (+0300) Subject: tests: Avoid confusing "DETACH failed" exception prints in D-Bus tests X-Git-Tag: hostap_2_8~63 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fhostap.git;a=commitdiff_plain;h=6541b9dbe759a23d5a80061bd294b205d36025a8;hp=c975c667f824ac27f4a6e8c5028ff5bee2a0929d 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 --- diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index 55d74bbf5..33a6b7609 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -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 diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 0aa0782f4..3b9fd2964 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -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