]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make dbus_connect_oom more robust
authorJouni Malinen <jouni.malinen@oss.qualcomm.com>
Fri, 22 Aug 2025 09:47:48 +0000 (12:47 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 22 Aug 2025 09:49:49 +0000 (12:49 +0300)
Retry RemoveNetwork() and SelectNetwork() if they fail due to
InvalidArgs error. That error is returned if a memory allocation fails
and that is indeed what this test case is trying to trigger.

In addition, dump any potential hostapd event messages between each test
interation to keep the logs clearer and the socket buffer smaller.

Signed-off-by: Jouni Malinen <jouni.malinen@oss.qualcomm.com>
tests/hwsim/test_dbus.py

index dfc20db3a59f10ed34077fc12c8b8ad3871390ef..bc88c03af099ce576ace43b2bfd726968e35599d 100644 (file)
@@ -1614,11 +1614,27 @@ def test_dbus_connect_oom(dev, apdev):
                     if 'frequency' not in res or res['frequency'] != 2412:
                         self.state = -1
                         logger.info("Unexpected SignalPoll result")
-                    iface.RemoveNetwork(self.netw)
+                    try:
+                        iface.RemoveNetwork(self.netw)
+                    except dbus.exceptions.DBusException as e:
+                        # Work around known issues caused by OOM messing up with
+                        # D-Bus message processing.
+                        if "InvalidArgs" in str(e):
+                            iface.RemoveNetwork(self.netw)
+                        else:
+                            raise
             if 'State' in properties and properties['State'] == "disconnected":
                 if self.state == 1:
                     self.state = 2
-                    iface.SelectNetwork(self.netw)
+                    try:
+                        iface.SelectNetwork(self.netw)
+                    except dbus.exceptions.DBusException as e:
+                        # Work around known issues caused by OOM messing up with
+                        # D-Bus message processing.
+                        if "InvalidArgs" in str(e):
+                            iface.SelectNetwork(self.netw)
+                        else:
+                            raise
                 elif self.state == 3:
                     self.state = 4
                     iface.Reassociate()
@@ -1656,6 +1672,7 @@ def test_dbus_connect_oom(dev, apdev):
 
     count = 0
     for i in range(1, 1000):
+        hapd.dump_monitor()
         for j in range(3):
             dev[j].dump_monitor()
         dev[0].request("TEST_ALLOC_FAIL %d:main" % i)