forked from rpms/fprintd
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
5.1 KiB
154 lines
5.1 KiB
3 years ago
|
From 5d7422e17aaaf3a0c09fc4a3c8f6fa67371d3130 Mon Sep 17 00:00:00 2001
|
||
|
From: Benjamin Berg <bberg@redhat.com>
|
||
|
Date: Wed, 25 Aug 2021 13:43:30 +0200
|
||
|
Subject: [PATCH 1/4] tests: Cleanup inhibitor fifo properly
|
||
|
|
||
|
Unlink the fifo itself and use addCleanup to close it.
|
||
|
---
|
||
|
tests/fprintd.py | 4 ++--
|
||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/tests/fprintd.py b/tests/fprintd.py
|
||
|
index a274793..f0dbc7b 100644
|
||
|
--- a/tests/fprintd.py
|
||
|
+++ b/tests/fprintd.py
|
||
|
@@ -601,7 +601,9 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||
|
|
||
|
fifo_path = os.path.join(self.tmpdir, 'logind_inhibit_fifo')
|
||
|
os.mkfifo(fifo_path)
|
||
|
+ self.addCleanup(os.unlink, fifo_path)
|
||
|
self.logind_inhibit_fifo = os.open(fifo_path, os.O_RDONLY | os.O_NONBLOCK | os.O_CLOEXEC)
|
||
|
+ self.addCleanup(os.close, self.logind_inhibit_fifo)
|
||
|
# EOF without a writer, BlockingIOError with a writer
|
||
|
self.assertFalse(self.holds_inhibitor())
|
||
|
|
||
|
@@ -662,8 +664,6 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||
|
self.device = None
|
||
|
self.manager = None
|
||
|
|
||
|
- os.close(self.logind_inhibit_fifo)
|
||
|
-
|
||
|
super().tearDown()
|
||
|
|
||
|
def try_release(self):
|
||
|
--
|
||
|
GitLab
|
||
|
|
||
|
|
||
|
From e6fc854a9ae3f640945ff621959cf9984e7d036a Mon Sep 17 00:00:00 2001
|
||
|
From: Benjamin Berg <bberg@redhat.com>
|
||
|
Date: Wed, 25 Aug 2021 15:19:43 +0200
|
||
|
Subject: [PATCH 2/4] tests: Use addCleanup to stop polkitd
|
||
|
|
||
|
---
|
||
|
tests/fprintd.py | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/tests/fprintd.py b/tests/fprintd.py
|
||
|
index f0dbc7b..0dea501 100644
|
||
|
--- a/tests/fprintd.py
|
||
|
+++ b/tests/fprintd.py
|
||
|
@@ -598,6 +598,7 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||
|
self.manager = None
|
||
|
self.device = None
|
||
|
self.polkitd_start()
|
||
|
+ self.addCleanup(self.polkitd_stop)
|
||
|
|
||
|
fifo_path = os.path.join(self.tmpdir, 'logind_inhibit_fifo')
|
||
|
os.mkfifo(fifo_path)
|
||
|
@@ -660,7 +661,6 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||
|
self._changed_properties = []
|
||
|
|
||
|
def tearDown(self):
|
||
|
- self.polkitd_stop()
|
||
|
self.device = None
|
||
|
self.manager = None
|
||
|
|
||
|
--
|
||
|
GitLab
|
||
|
|
||
|
|
||
|
From 717a9199963d1ea8c96f9208ecdca18a12247481 Mon Sep 17 00:00:00 2001
|
||
|
From: Benjamin Berg <bberg@redhat.com>
|
||
|
Date: Wed, 25 Aug 2021 15:22:42 +0200
|
||
|
Subject: [PATCH 3/4] tests: Make class cleanup more robust
|
||
|
|
||
|
Use addClassCleanup rather than doing cleanup in tearDownClass, which
|
||
|
may not be called in all cases.
|
||
|
---
|
||
|
tests/fprintd.py | 10 +++++-----
|
||
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/tests/fprintd.py b/tests/fprintd.py
|
||
|
index 0dea501..7d9eb4d 100644
|
||
|
--- a/tests/fprintd.py
|
||
|
+++ b/tests/fprintd.py
|
||
|
@@ -201,6 +201,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
||
|
|
||
|
|
||
|
cls.tmpdir = tempfile.mkdtemp(prefix='libfprint-')
|
||
|
+ cls.addClassCleanup(shutil.rmtree, cls.tmpdir)
|
||
|
|
||
|
cls.sockaddr = os.path.join(cls.tmpdir, 'virtual-image.socket')
|
||
|
os.environ[cls.socket_env] = cls.sockaddr
|
||
|
@@ -213,6 +214,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
||
|
|
||
|
cls.test_bus = Gio.TestDBus.new(Gio.TestDBusFlags.NONE)
|
||
|
cls.test_bus.up()
|
||
|
+ cls.addClassCleanup(cls.test_bus.down)
|
||
|
cls.test_bus.unset()
|
||
|
addr = cls.test_bus.get_bus_address()
|
||
|
os.environ['DBUS_SYSTEM_BUS_ADDRESS'] = addr
|
||
|
@@ -220,16 +222,14 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
||
|
Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION |
|
||
|
Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT, None, None)
|
||
|
assert cls.dbus.is_closed() == False
|
||
|
+ cls.addClassCleanup(cls.dbus.close)
|
||
|
|
||
|
@classmethod
|
||
|
def tearDownClass(cls):
|
||
|
- cls.dbus.close()
|
||
|
- cls.test_bus.down()
|
||
|
- del cls.dbus
|
||
|
- del cls.test_bus
|
||
|
- shutil.rmtree(cls.tmpdir)
|
||
|
dbusmock.DBusTestCase.tearDownClass()
|
||
|
|
||
|
+ del cls.dbus
|
||
|
+ del cls.test_bus
|
||
|
|
||
|
def daemon_start(self, driver='Virtual image device for debugging'):
|
||
|
timeout = get_timeout('daemon_start') # seconds
|
||
|
--
|
||
|
GitLab
|
||
|
|
||
|
|
||
|
From e4c155d5b8ea48e337e64c24170be023229bbb07 Mon Sep 17 00:00:00 2001
|
||
|
From: Benjamin Berg <bberg@redhat.com>
|
||
|
Date: Wed, 25 Aug 2021 15:27:26 +0200
|
||
|
Subject: [PATCH 4/4] tests: Give fprintd some more time to be ready
|
||
|
|
||
|
While the delay inhibitor is grabbed almost immediately, this can be
|
||
|
slow enough to not have happened immediately after the bus name has been
|
||
|
registered. Add a generous timeout to prevent issues.
|
||
|
---
|
||
|
tests/fprintd.py | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/tests/fprintd.py b/tests/fprintd.py
|
||
|
index 7d9eb4d..8fa615f 100644
|
||
|
--- a/tests/fprintd.py
|
||
|
+++ b/tests/fprintd.py
|
||
|
@@ -615,7 +615,7 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
||
|
'GLib.idle_add(lambda fd: os.close(fd), ret)')
|
||
|
self.daemon_start(self.driver_name)
|
||
|
|
||
|
- self.wait_got_delay_inhibitor()
|
||
|
+ self.wait_got_delay_inhibitor(timeout=5)
|
||
|
|
||
|
if self.device is None:
|
||
|
self.skipTest("Need {} device to run the test".format(self.device_driver))
|
||
|
--
|
||
|
GitLab
|
||
|
|