test: dbus: Wait for connection before disconnect

The test here wants to connect and then disconnect again, but it's
driven only by the GO side, so the client may end up (with UML
time-travel) not fully connecting, and then it all fails. Wait for the
client to have connected first.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2024-01-28 20:59:09 +01:00 committed by Jouni Malinen
parent 9fe2970ff6
commit 44b7b9178b

View file

@ -3940,6 +3940,7 @@ def test_dbus_p2p_autogo_pbc(dev, apdev):
self.first = True self.first = True
self.waiting_end = False self.waiting_end = False
self.done = False self.done = False
self.dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
def __enter__(self): def __enter__(self):
gobject.timeout_add(1, self.run_test) gobject.timeout_add(1, self.run_test)
@ -3963,12 +3964,12 @@ def test_dbus_p2p_autogo_pbc(dev, apdev):
self.group = properties['group_object'] self.group = properties['group_object']
self.g_if_obj = bus.get_object(WPAS_DBUS_SERVICE, self.g_if_obj = bus.get_object(WPAS_DBUS_SERVICE,
properties['interface_object']) properties['interface_object'])
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1') self.dev1.global_request("P2P_CONNECT " + addr0 + " pbc join")
dev1.global_request("P2P_CONNECT " + addr0 + " pbc join")
def groupFinished(self, properties): def groupFinished(self, properties):
logger.debug("groupFinished: " + str(properties)) logger.debug("groupFinished: " + str(properties))
self.done = True self.done = True
self.dev1 = None
self.loop.quit() self.loop.quit()
def deviceFound(self, path): def deviceFound(self, path):
@ -3993,6 +3994,9 @@ def test_dbus_p2p_autogo_pbc(dev, apdev):
def staAuthorized(self, name): def staAuthorized(self, name):
logger.debug("staAuthorized: " + name) logger.debug("staAuthorized: " + name)
# wait for client to be fully connected
self.dev1.wait_connected()
# so we can cleanly disconnect it now
group_p2p = dbus.Interface(self.g_if_obj, group_p2p = dbus.Interface(self.g_if_obj,
WPAS_DBUS_IFACE_P2PDEVICE) WPAS_DBUS_IFACE_P2PDEVICE)
group_p2p.Disconnect() group_p2p.Disconnect()