]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-98894: Check tracer exit status in test_dtrace (#152893)
authorstratakis <cstratak@redhat.com>
Thu, 2 Jul 2026 15:07:24 +0000 (17:07 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Jul 2026 15:07:24 +0000 (17:07 +0200)
Fail functional dtrace and SystemTap cases directly when the tracer exits
non-zero.

Lib/test/test_dtrace.py

index 788d31c60f4d9784831b20d6aa335fec3ba953b9..e1662a70b26d3e34a67a78eee466f9f597655b2a 100644 (file)
@@ -125,7 +125,8 @@ class TraceBackend:
             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,
@@ -136,6 +137,11 @@ class TraceBackend:
         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):
@@ -143,7 +149,8 @@ class TraceBackend:
         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: