From 8ed77829a7b84da00767d1c3f7c1280d6dad3601 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Tue, 12 May 2020 17:44:13 +0200 Subject: [PATCH] tests: Add test for a client vanishing during claim Note that this test only works if the virtual_image driver opens up a window for race condition by delaying the open callback. --- tests/fprintd.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/fprintd.py b/tests/fprintd.py index 65ec232..8b297b8 100644 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -650,6 +650,37 @@ class FPrintdVirtualDeviceTest(FPrintdVirtualDeviceBaseTest): self.device.Claim('(s)', 'testuser') self.device.Release() + def test_claim_disconnect(self): + addr = os.environ['DBUS_SYSTEM_BUS_ADDRESS'] + + # Get a separat bus connection + dbus = Gio.DBusConnection.new_for_address_sync(addr, + Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION | + Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT, None, None) + assert dbus.is_closed() == False + + + dev_path = self.device.get_object_path() + dev = Gio.DBusProxy.new_sync(dbus, + Gio.DBusProxyFlags.DO_NOT_AUTO_START, + None, + 'net.reactivated.Fprint', + dev_path, + 'net.reactivated.Fprint.Device', + None) + + def call_done(obj, result, user_data): + # Ignore the callback (should be an error) + pass + + # Do an async call to claim and immediately close + dev.Claim('(s)', 'testuser', result_handler=call_done) + + # Ensure the call is on the wire, then close immediately + dbus.flush_sync() + dbus.close_sync() + + time.sleep(1) class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):