diff mbox series

[2/2] auto-t: fix unpredictability/pointless test from testAgent

Message ID 20220629173113.2442455-2-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] auto-t: allow multiple PSKAgent's to be registered | expand

Commit Message

James Prestwood June 29, 2022, 5:31 p.m. UTC
testAgent had a few tests which weren't reliable, and one was not actually
testing anything, or at least not what the name implied it should be testing.

The first issue was using iwctl in the first place. There is not a reliable
way to know when iwctl has registered its agent so relying on that with a sleep,
or waiting for the service to become available isn't 100% fool proof. To fix
this use the updated PSKAgent which allows multiple to be registered. This ensures
the agent is ready for requests. This test was also renamed to be consistent with
what its actually testing: that IWD uses the first agent registered.

This removes test_connection_with_other_agent as well because this test case is
covered by the client test itself. There is no need to re-test iwctl's agent
functionality here.
---
 autotests/testAgent/agent_test.py | 40 ++++---------------------------
 1 file changed, 4 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/autotests/testAgent/agent_test.py b/autotests/testAgent/agent_test.py
index c1dc8c7c..fc988f21 100644
--- a/autotests/testAgent/agent_test.py
+++ b/autotests/testAgent/agent_test.py
@@ -56,51 +56,19 @@  class Test(unittest.TestCase):
 
         IWD.clear_storage()
 
-    def test_connection_with_other_agent(self):
-        def wait_for_service_pid(pid):
-            dbus_object = ctx._bus.get_object('org.freedesktop.DBus',
-                                 '/org/freedesktop/DBus')
-            dbus_iface = dbus.Interface(dbus_object, 'org.freedesktop.DBus')
-
-            services = dbus_iface.ListNames()
-
-            for service in services:
-                bus_iface = dbus.Interface(dbus_object, "org.freedesktop.DBus")
-                if pid == int(bus_iface.GetConnectionUnixProcessID(service)):
-                    return True
-
-            return False
-
+    def test_connection_use_first_from_multiple_registered(self):
         wd = IWD()
 
-        iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2'])
-
-        # Let iwctl to start and register its agent.
-        ctx.non_block_wait(wait_for_service_pid, 10, iwctl.pid)
-
-        self.check_connection(wd, 'ssid2')
-
-        iwctl.kill()
-
-        IWD.clear_storage()
-
-    def test_connection_use_own_agent_from_multiple_registered(self):
-
-        wd = IWD()
-
-        iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2'])
-        # Let iwctl to start and register its agent.
-        wd.wait(2)
-
         psk_agent = PSKAgent("secret_ssid1")
         wd.register_psk_agent(psk_agent)
 
+        psk_agent = PSKAgent("secret_ssid2")
+        wd.register_psk_agent(psk_agent)
+
         self.check_connection(wd, 'ssid1')
 
         wd.unregister_psk_agent(psk_agent)
 
-        iwctl.kill()
-
         IWD.clear_storage()
 
     @classmethod