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

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Nov 2 19:05:00 GMT 2026



On 02/11/26 10:48, Yury Khrustalev wrote:
> 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>

This patch looks ok, two minor points below.

Reviewed-by: Adhemerval Zanella  <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

A test-wrapper="WRAPPER_DEBUG=1 /path/wrap" now fails with 
FileNotFoundError: 'WRAPPER_DEBUG=1', while the same string with shell=True
passes.

The manual/install.texi only documents 'cross-test-ssh.sh HOST', so this
isn't a blocker. But other tests uses shell=True (like 
elf/tst-rtld-list-diagnostics.py).

>      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)

The 'import argparse' is now unused, I think it should be removed.  A
wrong argument count or invalid option now ends in a 'ValueError', but
it should be ok (make check will fail anyway).

>  
>  
>  if __name__ == '__main__':



More information about the Libc-alpha mailing list