From acd0a10e76f354dfac6c2d82a92bc526359381e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 28 Jan 2021 03:32:09 +0100 Subject: [PATCH] virtual-device: Add test that open fails with a busy error if is still ongoing The idea of the test was just checking what happens when we're opening a device multiple times while a first request is still going. However, it actually ends up also checking the previous commit change because without it we'd stop the close iteration before the device is actually closed and stop the open iteration before the device is actually opened, leading to an infinite loop. --- tests/virtual-device.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/virtual-device.py b/tests/virtual-device.py index 10684e6..414370b 100644 --- a/tests/virtual-device.py +++ b/tests/virtual-device.py @@ -730,6 +730,28 @@ class VirtualDeviceBusyDeviceOperations(VirtualDeviceBase): ctx.iteration(True) super().tearDown() + def test_open(self): + self.send_command('IGNORED_COMMAND') + self.send_sleep(100) + + with GLibErrorMessage('libfprint-virtual_device', + GLib.LogLevelFlags.LEVEL_WARNING, 'Could not process command: *'): + while self.dev.is_open(): + ctx.iteration(True) + + self.assertFalse(self.dev.is_open()) + self.dev.open() + with self.assertRaises(GLib.Error) as error: + self.dev.open_sync() + self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(), + FPrint.DeviceError.BUSY)) + + self.assertFalse(self.dev.is_open()) + while not self.dev.is_open(): + ctx.iteration(True) + + self.dev.close_sync() + def test_close(self): with self.assertRaises(GLib.Error) as error: self.dev.close_sync()