Thread (88 messages) 88 messages, 2 authors, 4d ago

Re: [PATCH v2 02/58] objtool/klp: Check the klp test environment once, before any test

From: Song Liu <song@kernel.org>
Date: 2026-09-14 18:39:38
Also in: sashiko-reviews

On Sun, Sep 13, 2026 at 11:37 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Tool existence checks for READELF, OBJCOPY, and LD will fail if these variables contain CLI arguments, incorrectly aborting the test suite.
--

commit 2ddfaa45c9b45195802f915e9ca42e1e7b224f4b
Author: Song Liu [off-list ref]

objtool/klp: Check the klp test environment once, before any test

This commit adds a preflight check to evaluate the objtool test environment
once before the test suite runs. It exports the environment answers and fails
the entire run if prerequisites are missing, rather than skipping tests
individually.
quoted
diff --git a/tools/objtool/tests/lib.sh b/tools/objtool/tests/lib.sh
index 714371232fa30..6e4e54b108659 100644
--- a/tools/objtool/tests/lib.sh
+++ b/tools/objtool/tests/lib.sh
[ ... ]
quoted
+klp_preflight()
+{
+     local tmp tool cc_version host cc_arch
+
+     bail() { echo "Bail out! $*" >&2; exit 1; }
[ ... ]
quoted
+     command -v "${CC%% *}" >/dev/null || bail "compiler not found: $CC"
+
+     for tool in "$READELF" "$OBJCOPY" "$LD"; do
+             command -v "$tool" >/dev/null || bail "$tool not found"
+     done
[Severity: Low]
Will this check fail if the toolchain variables contain CLI arguments?

Unlike the compiler check just above it which correctly uses parameter
expansion to strip arguments (`${CC%% *}`), passing the full string to
`command -v` when it contains spaces (e.g., if a developer or CI system
overrides `OBJCOPY="llvm-objcopy --target=arm64"`) will cause `command -v`
to treat the entire string as a single binary name and fail.

Could this incorrectly abort the test suite under valid configurations?
Good catch, fixed in v3.

Thanks,
Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help