]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Fix dbus_probe_req_reporting_oom if already registered
authorJouni Malinen <j@w1.fi>
Sat, 17 Jan 2015 10:39:00 +0000 (12:39 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 17 Jan 2015 10:39:00 +0000 (12:39 +0200)
If dbus_probe_req_reporting was run before dbus_probe_req_reporting_oom,
the SubscribeProbeReq() method succeeded since the memory allocation
that was supposed to fail in the OOM test case was not even tried.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_dbus.py

index 34d669b91c88afb527593f01cf7b8fcf56bac346..0ba417f1977682b1e34b73576e21c0cd80b77de3 100644 (file)
@@ -2146,10 +2146,25 @@ def test_dbus_probe_req_reporting_oom(dev, apdev):
     (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
     iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
 
+    # Need to make sure this process has not already subscribed to avoid false
+    # failures due to the operation succeeding due to os_strdup() not even
+    # getting called.
+    try:
+        iface.UnsubscribeProbeReq()
+        was_subscribed = True
+    except dbus.exceptions.DBusException, e:
+        was_subscribed = False
+        pass
+
     with alloc_fail_dbus(dev[0], 1, "wpas_dbus_handler_subscribe_preq",
                          "SubscribeProbeReq"):
         iface.SubscribeProbeReq()
 
+    if was_subscribed:
+        # On purpose, leave ProbeReq subscription in place to test automatic
+        # cleanup.
+        iface.SubscribeProbeReq()
+
 def test_dbus_p2p_invalid(dev, apdev):
     """D-Bus invalid P2P operations"""
     (bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])