From ec864ad39bc7a4ed46d2396871f89363dc209c5f Mon Sep 17 00:00:00 2001 From: crvi Date: Fri, 14 Aug 2020 02:52:59 +0530 Subject: test: fix incorrect process reporting reports the grep process rather than that of zeitgeist-daemon --- test/dbus/testutils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/dbus/testutils.py b/test/dbus/testutils.py index 84aee2d1..ad2fe25c 100644 --- a/test/dbus/testutils.py +++ b/test/dbus/testutils.py @@ -141,9 +141,14 @@ class RemoteTestCase (unittest.TestCase): @staticmethod def _get_pid(matching_string): - p1 = Popen(["ps", "aux"], stdout=PIPE, stderr=PIPE) - p2 = Popen(["grep", matching_string], stdin=p1.stdout, stderr=PIPE, stdout=PIPE) - return p2.communicate()[0].decode() + p1 = Popen(["pgrep", "-x", "zeitgeist-daemo"], stdout=PIPE, stderr=PIPE) + out = p1.communicate()[0] + pid = out.decode().split('\n')[0] + + p2 = Popen(["ps", "--no-headers", "-fp", pid], stderr=PIPE, stdout=PIPE) + pid_line = p2.communicate()[0].decode() + + return pid_line @staticmethod def _safe_start_subprocess(cmd, env, timeout=1, error_callback=None): -- cgit v1.2.1