nptl: Skip pretty-printer tests without python3 [BZ #34507]

Message ID 20260901115827.1047272-1-Hemanth.KumarMD@windriver.com (mailing list archive)
State Changes Requested
Headers
Series nptl: Skip pretty-printer tests without python3 [BZ #34507] |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Hemanth.KumarMD@windriver.com Sept. 1, 2026, 11:58 a.m. UTC
  From: Hemanth Kumar M D <Hemanth.KumarMD@windriver.com>

The tests-printers-out rule in Rules runs $(PYTHON) through
$(test-wrapper-env).  Unlike ordinary tests, which wrap a freshly
built target binary, this wraps python3, a build-host tool.  The
wrapping itself is intentional: the pretty-printer tests drive gdb
against the built test binaries, so they must run wherever those
binaries can execute.

When cross-testing with test-wrapper set (e.g. via
scripts/cross-test-ssh.sh) the whole command is forwarded to the
target.  If the target lacks python3, the remote shell exits with
status 127 and evaluate-test.sh reports the six nptl pretty-printer
tests as FAIL instead of UNSUPPORTED.

scripts/test_printers_common.py already exits with the UNSUPPORTED
status (77) when its dependencies (gdb, pexpect) are missing, but
that check is unreachable when the python3 interpreter itself is
absent.

Guard the invocation with a "command -v" check so the recipe exits
77 (UNSUPPORTED) when $(PYTHON) is not found in the test
environment.  Note that this checks for the interpreter configure
found on the build host, which may be an absolute path; if it is
not present at that location on the target, the test cannot run as
invoked, so UNSUPPORTED is the correct result.  Native builds are
unaffected, as configure requires python3.

Tested natively on x86_64-linux-gnu (make check; the pretty-printer
tests continue to PASS) and by cross-testing via
scripts/cross-test-ssh.sh to a target without python3 (the six
tests now report UNSUPPORTED instead of FAIL).

Signed-off-by: Hemanth Kumar M D <Hemanth.KumarMD@windriver.com>
---
 Rules | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Adhemerval Zanella Netto Sept. 3, 2026, 6:18 p.m. UTC | #1
On 01/09/26 08:58, Hemanth.KumarMD@windriver.com wrote:
> From: Hemanth Kumar M D <Hemanth.KumarMD@windriver.com>
> 
> The tests-printers-out rule in Rules runs $(PYTHON) through
> $(test-wrapper-env).  Unlike ordinary tests, which wrap a freshly
> built target binary, this wraps python3, a build-host tool.  The
> wrapping itself is intentional: the pretty-printer tests drive gdb
> against the built test binaries, so they must run wherever those
> binaries can execute.
> 
> When cross-testing with test-wrapper set (e.g. via
> scripts/cross-test-ssh.sh) the whole command is forwarded to the
> target.  If the target lacks python3, the remote shell exits with
> status 127 and evaluate-test.sh reports the six nptl pretty-printer
> tests as FAIL instead of UNSUPPORTED.
> 
> scripts/test_printers_common.py already exits with the UNSUPPORTED
> status (77) when its dependencies (gdb, pexpect) are missing, but
> that check is unreachable when the python3 interpreter itself is
> absent.
> 
> Guard the invocation with a "command -v" check so the recipe exits
> 77 (UNSUPPORTED) when $(PYTHON) is not found in the test
> environment.  Note that this checks for the interpreter configure
> found on the build host, which may be an absolute path; if it is
> not present at that location on the target, the test cannot run as
> invoked, so UNSUPPORTED is the correct result.  Native builds are
> unaffected, as configure requires python3.
> 
> Tested natively on x86_64-linux-gnu (make check; the pretty-printer
> tests continue to PASS) and by cross-testing via
> scripts/cross-test-ssh.sh to a target without python3 (the six
> tests now report UNSUPPORTED instead of FAIL).
> 
> Signed-off-by: Hemanth Kumar M D <Hemanth.KumarMD@windriver.com>
> ---
>  Rules | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Rules b/Rules
> index 71495028fb..06604b41a5 100644
> --- a/Rules
> +++ b/Rules
> @@ -467,8 +467,9 @@ py-env := PYTHONPATH=$(py-const-dir):$(..)scripts:$${PYTHONPATH}
>  # The pretty printer files and test_common_printers.py must be present for all.
>  $(tests-printers-out): $(objpfx)%.out: $(objpfx)% %.py %.c $(pretty-printers) \
>  		       $(..)scripts/test_printers_common.py
> -	$(test-wrapper-env) $(py-env) \
> -	    $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \
> +	$(test-wrapper-env) $(py-env) sh -c \
> +	    'command -v $(PYTHON) > /dev/null 2>&1 || exit 77; \

The configure expands $(PYTHON) to 'python -B' and command -v takes a single operand.
It seems work on most shell today, but I think it would be better ensure the command
existence test is done with $(firstword $(PYTHON)).

> +	     exec $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers)' > $@; \
>  	$(evaluate-test)
>  endif
>
  

Patch

diff --git a/Rules b/Rules
index 71495028fb..06604b41a5 100644
--- a/Rules
+++ b/Rules
@@ -467,8 +467,9 @@  py-env := PYTHONPATH=$(py-const-dir):$(..)scripts:$${PYTHONPATH}
 # The pretty printer files and test_common_printers.py must be present for all.
 $(tests-printers-out): $(objpfx)%.out: $(objpfx)% %.py %.c $(pretty-printers) \
 		       $(..)scripts/test_printers_common.py
-	$(test-wrapper-env) $(py-env) \
-	    $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers) > $@; \
+	$(test-wrapper-env) $(py-env) sh -c \
+	    'command -v $(PYTHON) > /dev/null 2>&1 || exit 77; \
+	     exec $(PYTHON) $*.py $*.c $(objpfx)$* $(pretty-printers)' > $@; \
 	$(evaluate-test)
 endif