[PATCH v2] Makefile: Fix elf/tst-trace tests

Yury Khrustalev yury.khrustalev@arm.com
Mon Nov 2 13:48:39 GMT 2026


The elf/tst-trace tests used

  ${ ... } $$@; $$(evaluate-test)

that ignored any errors inside ${ ... }. These braces seem to be
redundant and only mask any issues in the enclosed command.

Also fix underlying issue in tst-ld-trace.py that parsed command
line arguments incorrectly.

Suggested-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
---
 elf/Makefile            |  7 ++++---
 scripts/tst-ld-trace.py | 24 ++++++------------------
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/elf/Makefile b/elf/Makefile
index 2c74e11946..058c5957b5 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -3478,11 +3478,12 @@ $(objpfx)tst-trace$(1).out: $(objpfx)libtracemod1/libtracemod1.so \
 			    $(objpfx)libtracemod5/libtracemod5.so \
 			    $(..)scripts/tst-ld-trace.py \
 			    tst-trace$(1).exp
-	${ $(PYTHON) $(..)scripts/tst-ld-trace.py \
-	    "$(test-wrapper-env) $(elf-objpfx)$(rtld-installed-name) \
+	$(PYTHON) $(..)scripts/tst-ld-trace.py \
+	    "$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
+	    $(elf-objpfx)$(rtld-installed-name) \
 	    --library-path $(common-objpfx):$(strip $(2)) \
 	    $(objpfx)libtracemod1/libtracemod1.so" tst-trace$(1).exp \
-	} > $$@; $$(evaluate-test)
+	> $$@; $$(evaluate-test)
 endef
 
 $(eval $(call tst-trace-skeleton,1,))
diff --git a/scripts/tst-ld-trace.py b/scripts/tst-ld-trace.py
index 92c5b35bfc..d621207b79 100755
--- a/scripts/tst-ld-trace.py
+++ b/scripts/tst-ld-trace.py
@@ -22,6 +22,7 @@ import argparse
 import os
 import subprocess
 import sys
+import shlex
 
 try:
     subprocess.run
@@ -54,10 +55,8 @@ def is_vdso(lib):
 
 
 def parse_trace(cmd, fref):
-    new_env = os.environ.copy()
-    new_env['LD_TRACE_LOADED_OBJECTS'] = '1'
-    trace_out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True,
-                               universal_newlines=True, env=new_env).stdout
+    trace_out = subprocess.run(shlex.split(cmd), stdout=subprocess.PIPE, check=True,
+                               universal_newlines=True).stdout
     trace = []
     for line in trace_out.splitlines():
         line = line.strip()
@@ -87,21 +86,10 @@ def parse_trace(cmd, fref):
     sys.exit(ret)
 
 
-def get_parser():
-    parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument('command',
-                        help='command to run')
-    parser.add_argument('reference',
-                        help='reference file to compare')
-    return parser
-
-
 def main(argv):
-    parser = get_parser()
-    opts = parser.parse_args(argv)
-    with open(opts.reference, 'r') as fref:
-        # Remove the initial 'env' command.
-        parse_trace(opts.command.split()[1:], fref)
+    command, reference = argv
+    with open(reference, 'r') as fref:
+        parse_trace(command, fref)
 
 
 if __name__ == '__main__':
-- 
2.47.3



More information about the Libc-alpha mailing list