Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-98894: Check tracer exit status in test_dtrace (GH-152893)
Fail functional dtrace and SystemTap cases directly when the tracer exits
non-zero.
(cherry picked from commit 311e7e7)

Co-authored-by: stratakis <cstratak@redhat.com>
  • Loading branch information
stratakis authored and miss-islington committed Jul 2, 2026
commit 4041ccc90b65d22ea54faa381870ce6f303a5870
11 changes: 9 additions & 2 deletions Lib/test/test_dtrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def generate_trace_command(self, script_file, subcommand=None):
command += ["-c", subcommand]
return command

def trace(self, script_file, subcommand=None, *, timeout=None):
def trace(self, script_file, subcommand=None, *, timeout=None,
check_returncode=False):
command = self.generate_trace_command(script_file, subcommand)
proc = create_process_group(command,
stdout=subprocess.PIPE,
Expand All @@ -136,14 +137,20 @@ def trace(self, script_file, subcommand=None, *, timeout=None):
except subprocess.TimeoutExpired:
kill_process_group(proc)
raise
if check_returncode and proc.returncode:
raise AssertionError(
f"Command {' '.join(command)!r} failed "
f"with exit code {proc.returncode}: output={stdout!r}"
)
return stdout

def trace_python(self, script_file, python_file, optimize_python=None):
python_flags = []
if optimize_python:
python_flags.extend(["-O"] * optimize_python)
subcommand = " ".join([sys.executable] + python_flags + [python_file])
return self.trace(script_file, subcommand, timeout=60)
return self.trace(script_file, subcommand, timeout=60,
check_returncode=True)

def assert_usable(self):
try:
Expand Down
Loading