X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Fust%2Fdaemon%2Ftest_daemon.py;h=0351f1d21c1a239cbb235db7b6f538bd666636f8;hp=c9a9bff2c9a7207836106d33231648f202eaa205;hb=9d16b343fb9e781fc8d8fa3c448a3f382306dd33;hpb=43c28d504aa8ff65609f915a04e212fb923cfeba diff --git a/tests/regression/ust/daemon/test_daemon.py b/tests/regression/ust/daemon/test_daemon.py index c9a9bff2c..0351f1d21 100644 --- a/tests/regression/ust/daemon/test_daemon.py +++ b/tests/regression/ust/daemon/test_daemon.py @@ -1,19 +1,8 @@ #!/usr/bin/env python3 # -# Copyright (C) - 2013 Jérémie Galarneau +# Copyright (C) 2013 Jérémie Galarneau # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# SPDX-License-Identifier: GPL-2.0-only import uuid import os @@ -43,33 +32,30 @@ session_info = create_session() enable_ust_tracepoint_event(session_info, "*") start_session(session_info) + +parent_pid = None +daemon_pid = None daemon_process = subprocess.Popen(test_path + "daemon", stdout=subprocess.PIPE) -if sys.version_info >= (3, 3): - try: - daemon_process_return_code = daemon_process.wait(5) - except TimeoutExpired: - daemon_process.kill() - daemon_process_return_code = -1 -else: - daemon_process_return_code = daemon_process.wait() - -daemon_process_output = daemon_process.communicate()[0] -daemon_process_output = daemon_process_output.decode('utf-8').splitlines() +for line in daemon_process.stdout: + name, pid = line.decode('utf-8').split() + if name == "child_pid": + daemon_pid = int(pid) + if name == "parent_pid": + parent_pid = int(pid) + +daemon_process_return_code = daemon_process.wait() + +if parent_pid is None or daemon_pid is None: + bail("Unexpected output received from daemon test executable." + str(daemon_process_output)) print_test_result(daemon_process_return_code == 0, current_test, "Successful call to daemon() and normal exit") current_test += 1 if daemon_process_return_code != 0: - bail("Could not trigger tracepoints successfully. Abondoning test.") + bail("Could not trigger tracepoints successfully. Abandoning test.") stop_session(session_info) -if len(daemon_process_output) != 2: - bail("Unexpected output received from daemon test executable." + str(daemon_process_output)) - -parent_pid = re.search(r"\d+", daemon_process_output[0]).group(0) -daemon_pid = re.search(r"\d+", daemon_process_output[1]).group(0) - try: babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE) except FileNotFoundError: @@ -90,7 +76,7 @@ for event_line in babeltrace_process.stdout: match = re.search(r"(?<=pid = )\d+", event_line) if match is not None: - before_daemon_event_pid = match.group(0) + before_daemon_event_pid = int(match.group(0)) if re.search(r"after_daemon", event_line) is not None: if after_daemon_event_found: @@ -99,7 +85,7 @@ for event_line in babeltrace_process.stdout: match = re.search(r"(?<=pid = )\d+", event_line) if match is not None: - after_daemon_event_pid = match.group(0) + after_daemon_event_pid = int(match.group(0)) babeltrace_process.wait() print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable")