Skip to content

Commit 311e7e7

Browse files
authored
gh-98894: Check tracer exit status in test_dtrace (#152893)
Fail functional dtrace and SystemTap cases directly when the tracer exits non-zero.
1 parent 460fe13 commit 311e7e7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/test/test_dtrace.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def generate_trace_command(self, script_file, subcommand=None):
125125
command += ["-c", subcommand]
126126
return command
127127

128-
def trace(self, script_file, subcommand=None, *, timeout=None):
128+
def trace(self, script_file, subcommand=None, *, timeout=None,
129+
check_returncode=False):
129130
command = self.generate_trace_command(script_file, subcommand)
130131
proc = create_process_group(command,
131132
stdout=subprocess.PIPE,
@@ -136,14 +137,20 @@ def trace(self, script_file, subcommand=None, *, timeout=None):
136137
except subprocess.TimeoutExpired:
137138
kill_process_group(proc)
138139
raise
140+
if check_returncode and proc.returncode:
141+
raise AssertionError(
142+
f"Command {' '.join(command)!r} failed "
143+
f"with exit code {proc.returncode}: output={stdout!r}"
144+
)
139145
return stdout
140146

141147
def trace_python(self, script_file, python_file, optimize_python=None):
142148
python_flags = []
143149
if optimize_python:
144150
python_flags.extend(["-O"] * optimize_python)
145151
subcommand = " ".join([sys.executable] + python_flags + [python_file])
146-
return self.trace(script_file, subcommand, timeout=60)
152+
return self.trace(script_file, subcommand, timeout=60,
153+
check_returncode=True)
147154

148155
def assert_usable(self):
149156
try:

0 commit comments

Comments
 (0)