Skip to content

Commit 3555323

Browse files
committed
gh-98894: Check readelf failures in test_dtrace
Report readelf command failures directly instead of later failing with missing-probe assertions.
1 parent 9626ef8 commit 3555323

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/test_dtrace.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def get_readelf_version():
423423
version, stderr = proc.communicate()
424424

425425
if proc.returncode:
426-
raise Exception(
426+
raise AssertionError(
427427
f"Command {' '.join(cmd)!r} failed "
428428
f"with exit code {proc.returncode}: "
429429
f"stdout={version!r} stderr={stderr!r}"
@@ -464,13 +464,21 @@ def get_readelf_output(self):
464464
command = ["readelf", "-n", binary]
465465
# Force the C locale to disable localization.
466466
env = dict(os.environ, LC_ALL="C")
467-
stdout, _ = subprocess.Popen(
467+
proc = subprocess.Popen(
468468
command,
469469
stdout=subprocess.PIPE,
470470
stderr=subprocess.STDOUT,
471471
universal_newlines=True,
472472
env=env,
473-
).communicate()
473+
)
474+
with proc:
475+
stdout, _ = proc.communicate()
476+
477+
if proc.returncode:
478+
raise AssertionError(
479+
f"Command {' '.join(command)!r} failed "
480+
f"with exit code {proc.returncode}: stdout={stdout!r}"
481+
)
474482
return stdout
475483

476484
def test_check_probes(self):

0 commit comments

Comments
 (0)