* [PATCH] selftests: fix ARCH normalization to handle command-line argument
@ 2026-03-09 20:51 Aleksei Oladko
2026-03-09 21:06 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Aleksei Oladko @ 2026-03-09 20:51 UTC (permalink / raw)
To: Shuah Khan, Andrew Morton, Wei Yang, Bala-Vignesh-Reddy,
Chelsy Ratnawat
Cc: linux-kselftest, linux-kernel, Aleksei Oladko
Several selftests Makefiles (e.g. prctl, breakpoints, etc) attempt to
normalize the ARCH variable by converting x86_64 and i.86 to x86.
However, it uses the conditional assignment operator '?='.
When ARCH is passed as a command-line argument (e.g., during an rpmbuild
process), the '?=' operator ignores the shell command and the sed
transformation. This leads to an incorrect ARCH value being used, which
causes build failures
# make -C tools/testing/selftests TARGETS=prctl ARCH=x86_64
make: Entering directory '/build/tools/testing/selftests'
make[1]: Entering directory '/build/tools/testing/selftests/prctl'
make[1]: *** No targets. Stop.
make[1]: Leaving directory '/build/tools/testing/selftests/prctl'
make: *** [Makefile:197: all] Error 2
Change the assignment to use 'override' and ':=' to ensure the
normalization logic is applied regardless of how the ARCH variable
was initially defined.
Signed-off-by: Aleksei Oladko <aleksey.oladko@virtuozzo.com>
---
tools/testing/selftests/breakpoints/Makefile | 4 ++--
tools/testing/selftests/ipc/Makefile | 8 ++++----
tools/testing/selftests/prctl/Makefile | 4 ++--
tools/testing/selftests/sparc64/Makefile | 4 ++--
.../testing/selftests/thermal/intel/power_floor/Makefile | 4 ++--
.../selftests/thermal/intel/workload_hint/Makefile | 4 ++--
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 9ec2c78de8ca..0b8f5acf7c78 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
# Taken from perf makefile
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
TEST_GEN_PROGS := step_after_suspend_test
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 50e9c299fc4a..fad10f2bb57b 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -1,12 +1,12 @@
# SPDX-License-Identifier: GPL-2.0
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/i386/)
ifeq ($(ARCH),i386)
- ARCH := x86
+ override ARCH := x86
CFLAGS := -DCONFIG_X86_32 -D__i386__
endif
ifeq ($(ARCH),x86_64)
- ARCH := x86
+ override ARCH := x86
CFLAGS := -DCONFIG_X86_64 -D__x86_64__
endif
diff --git a/tools/testing/selftests/prctl/Makefile b/tools/testing/selftests/prctl/Makefile
index 01dc90fbb509..e770e86fad9a 100644
--- a/tools/testing/selftests/prctl/Makefile
+++ b/tools/testing/selftests/prctl/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
ifndef CROSS_COMPILE
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
ifeq ($(ARCH),x86)
TEST_PROGS := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test \
diff --git a/tools/testing/selftests/sparc64/Makefile b/tools/testing/selftests/sparc64/Makefile
index a19531dba4dc..88f7be76f962 100644
--- a/tools/testing/selftests/sparc64/Makefile
+++ b/tools/testing/selftests/sparc64/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/x86_64/x86/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/x86_64/x86/)
ifneq ($(ARCH),sparc64)
nothing:
diff --git a/tools/testing/selftests/thermal/intel/power_floor/Makefile b/tools/testing/selftests/thermal/intel/power_floor/Makefile
index 9b88e57dbba5..07463c2160e0 100644
--- a/tools/testing/selftests/thermal/intel/power_floor/Makefile
+++ b/tools/testing/selftests/thermal/intel/power_floor/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
ifndef CROSS_COMPILE
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
ifeq ($(ARCH),x86)
TEST_GEN_PROGS := power_floor_test
diff --git a/tools/testing/selftests/thermal/intel/workload_hint/Makefile b/tools/testing/selftests/thermal/intel/workload_hint/Makefile
index 37ff3286283b..49e3bc2b20f9 100644
--- a/tools/testing/selftests/thermal/intel/workload_hint/Makefile
+++ b/tools/testing/selftests/thermal/intel/workload_hint/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
ifndef CROSS_COMPILE
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
ifeq ($(ARCH),x86)
TEST_GEN_PROGS := workload_hint_test
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: fix ARCH normalization to handle command-line argument
2026-03-09 20:51 [PATCH] selftests: fix ARCH normalization to handle command-line argument Aleksei Oladko
@ 2026-03-09 21:06 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-03-09 21:06 UTC (permalink / raw)
To: Aleksei Oladko
Cc: Shuah Khan, Wei Yang, Bala-Vignesh-Reddy, Chelsy Ratnawat,
linux-kselftest, linux-kernel
On Mon, 9 Mar 2026 20:51:45 +0000 Aleksei Oladko <aleksey.oladko@virtuozzo.com> wrote:
> Several selftests Makefiles (e.g. prctl, breakpoints, etc) attempt to
> normalize the ARCH variable by converting x86_64 and i.86 to x86.
> However, it uses the conditional assignment operator '?='.
>
> When ARCH is passed as a command-line argument (e.g., during an rpmbuild
> process), the '?=' operator ignores the shell command and the sed
> transformation. This leads to an incorrect ARCH value being used, which
> causes build failures
>
> # make -C tools/testing/selftests TARGETS=prctl ARCH=x86_64
> make: Entering directory '/build/tools/testing/selftests'
> make[1]: Entering directory '/build/tools/testing/selftests/prctl'
> make[1]: *** No targets. Stop.
> make[1]: Leaving directory '/build/tools/testing/selftests/prctl'
> make: *** [Makefile:197: all] Error 2
>
> Change the assignment to use 'override' and ':=' to ensure the
> normalization logic is applied regardless of how the ARCH variable
> was initially defined.
lgtm, thanks.
> --- a/tools/testing/selftests/ipc/Makefile
> +++ b/tools/testing/selftests/ipc/Makefile
> @@ -1,12 +1,12 @@
> # SPDX-License-Identifier: GPL-2.0
> -uname_M := $(shell uname -m 2>/dev/null || echo not)
> -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
> +ARCH ?= $(shell uname -m 2>/dev/null || echo not)
What does this `echo not' do? ARCH=not if uname failed?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-09 21:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 20:51 [PATCH] selftests: fix ARCH normalization to handle command-line argument Aleksei Oladko
2026-03-09 21:06 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox