From 1deb1e20443d73b7ac6007469c117ab65c5add67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 27 Jan 2021 15:55:48 +0100 Subject: [PATCH] tests/fprintd: Add ability to force-kill the daemon if we're fine to hang --- tests/fprintd.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/fprintd.py b/tests/fprintd.py index 46203fd..2ef85c2 100644 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -227,6 +227,7 @@ class FPrintdTest(dbusmock.DBusTestCase): if os.path.exists(valgrind): argv.insert(2, '--suppressions=%s' % valgrind) self.valgrind = True + self.kill_daemon = False self.daemon = subprocess.Popen(argv, env=env, stdout=None, @@ -281,9 +282,18 @@ class FPrintdTest(dbusmock.DBusTestCase): self.daemon.terminate() except OSError: pass - self.daemon.wait(timeout=get_timeout('daemon_start')) - self.assertLess(self.daemon.returncode, 128) - self.assertGreaterEqual(self.daemon.returncode, 0) + + try: + self.daemon.wait(timeout=get_timeout('daemon_stop')) + except subprocess.TimeoutExpired as e: + if self.kill_daemon: + self.daemon.kill() + else: + raise(e) + + if not self.kill_daemon: + self.assertLess(self.daemon.returncode, 128) + self.assertGreaterEqual(self.daemon.returncode, 0) self.daemon = None