From 32bf9f29909015a6fbec4252a0aea2151ccb0272 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 5 Apr 2019 11:02:46 +1000 Subject: [PATCH] tools: fix waiting for the tool to quit in the options test Just use the wait() timeout directly instead of sleep and kill. This allows us to have a longer timeout and still get fast handling where the tool immediately exits, but less failure when running on busy machines. Signed-off-by: Peter Hutterer --- meson.build | 2 +- tools/test-tool-option-parsing.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 6a6dad2b..03e4394b 100644 --- a/meson.build +++ b/meson.build @@ -610,7 +610,7 @@ if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimi test('tool-option-parsing', find_program('tools/test-tool-option-parsing.py'), args : ['--tool-path', libinput_tool.full_path()], - timeout : 120) + timeout : 240) endif # the libinput tools check whether we execute from the builddir, this is diff --git a/tools/test-tool-option-parsing.py b/tools/test-tool-option-parsing.py index 1ea3a47b..6cdcf658 100755 --- a/tools/test-tool-option-parsing.py +++ b/tools/test-tool-option-parsing.py @@ -41,12 +41,14 @@ class TestLibinputTool(unittest.TestCase): args.insert(1, self.subtool) with subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: - time.sleep(0.1) - p.send_signal(3) # SIGQUIT - p.wait() + try: + p.wait(0.7) + except subprocess.TimeoutExpired: + p.send_signal(3) # SIGQUIT + stdout, stderr = p.communicate(timeout=2) if p.returncode == -3: p.returncode = 0 - return p.returncode, p.stdout.read().decode('UTF-8'), p.stderr.read().decode('UTF-8') + return p.returncode, stdout.decode('UTF-8'), stderr.decode('UTF-8') def run_command_success(self, args): rc, stdout, stderr = self.run_command(args)