Re: [PATCH v2] selftests: amd-pstate: Don't delete source files via Makefile

From: Guillaume Tucker
Date: Fri Feb 03 2023 - 10:19:07 EST


On 21/01/2023 17:41, Doug Smythies wrote:
> Revert the portion of a recent Makefile change that incorrectly
> deletes source files when doing "make clean".
>
> Fixes: ba2d788aa873 ("selftests: amd-pstate: Trigger tbench benchmark and test cpus")
> Reported-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
> Tested-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
> Reviewed-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
> Acked-by: Huang Rui <ray.huang@xxxxxxx>
> Signed-off-by: Doug Smythies <dsmythies@xxxxxxxxx>
> ---
> v2: fix address list.
> ---
> tools/testing/selftests/amd-pstate/Makefile | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile
> index 5f195ee756d6..5fd1424db37d 100644
> --- a/tools/testing/selftests/amd-pstate/Makefile
> +++ b/tools/testing/selftests/amd-pstate/Makefile
> @@ -7,11 +7,6 @@ all:
> 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/)
>
> -ifeq (x86,$(ARCH))
> -TEST_GEN_FILES += ../../../power/x86/amd_pstate_tracer/amd_pstate_trace.py
> -TEST_GEN_FILES += ../../../power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> -endif
> -


The two lines above should also be removed as they're only used
in the condition to include the Python files.

I've also hit this issue and independently came up with an
alternative solution, let me know if you want me to submit it as
a patch on top of the previous fix; see below.

The Python scripts appear to be used in gitsource.sh and
tbench.sh so I guess they are needed for these kselftests
although I haven't tried to run them or do anything with them.
This is just to fix make clean.



Author: Guillaume Tucker <guillaume.tucker@xxxxxxxxxxxxx>
Date: Fri Feb 3 11:23:50 2023 +0100

selftests: amd-pstate: fix TEST_FILES

Replace TEST_GEN_FILES with TEST_FILES to avoid having them deleted
when doing a clean. Also fix the way the architecture is being
determined as they should also be installed when ARCH=x86_64 is
provided explicitly. Then also append extra files to TEST_FILES and
TEST_PROGS with += so they don't get discarded.

Fixes: a2d788aa873 ("selftests: amd-pstate: Trigger tbench benchmark and test cpus")
Signed-off-by: Guillaume Tucker <guillaume.tucker@xxxxxxxxxxxxx>

diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile
index 5f195ee756d6..c382f579fe94 100644
--- a/tools/testing/selftests/amd-pstate/Makefile
+++ b/tools/testing/selftests/amd-pstate/Makefile
@@ -4,15 +4,15 @@
# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
all:

-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)
+ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)

ifeq (x86,$(ARCH))
-TEST_GEN_FILES += ../../../power/x86/amd_pstate_tracer/amd_pstate_trace.py
-TEST_GEN_FILES += ../../../power/x86/intel_pstate_tracer/intel_pstate_tracer.py
+TEST_FILES += ../../../power/x86/amd_pstate_tracer/amd_pstate_trace.py
+TEST_FILES += ../../../power/x86/intel_pstate_tracer/intel_pstate_tracer.py
endif

-TEST_PROGS := run.sh
-TEST_FILES := basic.sh tbench.sh gitsource.sh
+TEST_PROGS += run.sh
+TEST_FILES += basic.sh tbench.sh gitsource.sh

include ../lib.mk