]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Avoid confusing "DETACH failed" exception prints in D-Bus tests
authorJouni Malinen <jouni@codeaurora.org>
Mon, 15 Apr 2019 17:13:28 +0000 (20:13 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 15 Apr 2019 17:13:28 +0000 (20:13 +0300)
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>
tests/hwsim/test_dbus.py
tests/hwsim/wpasupplicant.py

index 55d74bbf5837a67b5f6ecfc72ef80354e7059f93..33a6b76098ea13347ddd7fad2ae468bc6b85d22a 100644 (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
index 0aa0782f43404b7dbc083b69949be8a6707d8c4a..3b9fd29642c034f05cbaf49b50ab280e7533ddf7 100644 (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