From 4a3ae5ccaf37d73b8b608b96ff0cf07d17f937cd Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Thu, 19 Mar 2020 23:27:15 -0400 Subject: [PATCH] tests/fprintd: Allow tests to run even when virtual device is not available The test file calls self.daemon_start() in order to start fprintd and locate the virtual image device that's needed for the test to run. However, since the virtual image driver is not available on all libfprint installations, the test should be skipped if the driver is not available. The skipping mechanism used to work, by checking if self.device is None. This is based on the assumption that self.device would be set to None in cases where the driver is not available. However, even in the past self.device is only set to None in the tearDown method and not in setUp, so presumably in edge cases it didn't entirely work. However, since 0fb4f3b0217ac0fe2ac7a65a5ff2abed68d74a53 which consistently removes the self.device attribute rather than setting it to None, the "self.device is None" check no longer works. In particular, the following error message is shown: test_manager_get_default_device (__main__.FPrintdManagerTests) ... Did not find virtual device! Probably libfprint was build without the corresponding driver! ERROR After this patch, the following is shown: test_manager_get_default_device (__main__.FPrintdManagerTests) ... Did not find virtual device! Probably libfprint was build without the corresponding driver! skipped 'Need virtual_image device to run the test' We fix this bug by consistently setting self.device to None, in both the setUp method before daemon_start gets called, and in tearDown. We also make the same change to self.manager for consistency. The issue was not caught on CI, as the CI configuration always installs a libfprint version that has the virtual_image device explicitly enabled in the preparation phase. --- tests/fprintd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/fprintd.py b/tests/fprintd.py index 1bbc38b..1864aea 100755 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -315,6 +315,8 @@ class FPrintdVirtualDeviceBaseTest(FPrintdTest): def setUp(self): super().setUp() + self.manager = None + self.device = None self.polkitd_start() self.daemon_start() @@ -354,9 +356,8 @@ class FPrintdVirtualDeviceBaseTest(FPrintdTest): def tearDown(self): self.device.disconnect(self.g_signal_id) - - del self.manager - del self.device + self.device = None + self.manager = None super().tearDown()