Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH bpf-next v1] selftests/bpf: avoid generating untracked files when running bpf selftests
@ 2024-12-18 10:52 Jiayuan Chen
  0 siblings, 0 replies; only message in thread
From: Jiayuan Chen @ 2024-12-18 10:52 UTC (permalink / raw)
  To: bpf, linux-kselftest
  Cc: martin.lau, ast, edumazet, jakub, davem, dsahern, kuba, pabeni,
	linux-kernel, song, john.fastabend, andrii, mhal, yonghong.song,
	daniel, xiyou.wangcong, horms, eddyz87, mykolal, kpsingh, sdf,
	haoluo, jolsa, shuah, Jiayuan Chen

Currently, when we run the BPF selftests with the following command:

'make -C tools/testing/selftests TARGETS=bpf SKIP_TARGETS=""'

The command generates untracked files and directories:
'''
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	tools/testing/selftests/bpfFEATURE-DUMP.selftests
	tools/testing/selftests/bpffeature/
'''

The core reason is our Makefile(tools/testing/selftests/bpf/Makefile)
was written like this:
'''
OUTPUT := $(OUTPUT)/
$(eval include ../../../build/Makefile.feature)
OUTPUT := $(patsubst %/,%,$(OUTPUT))
'''

This way of assigning values to OUTPUT will never be effective for the
variable OUTPUT provided via the command argument and sub makefile called
like this(tools/testing/selftests/Makefile):
'''
all:
    ...
	$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET
'''

As stated in the GNU make documentation:
'''
An argument that contains '=' specifies the value of a variable: 'v=x'
sets the value of the variable v to x. If you specify a value in this way,
all ordinary assignments of the same variable in the makefile are ignored;
we say they have been overridden by the command line argument.
'''

According to GNU make, we use override Directive to fix this issue:
'''
If you want to set the variable in the makefile even though it was set
with a command argument, you can use an override directive, which is a
line that looks like this:
override variable := value

Link: https://www.gnu.org/software/make/manual/make.html#Override-Directive
Fixes: dc3a8804d790 ("selftests/bpf: Adapt OUTPUT appending logic to lower versions of Make")

Signed-off-by: Jiayuan Chen <mrpre@163.com>
---
 tools/testing/selftests/bpf/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9e870e519c30..eb4d21651aa7 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -202,9 +202,9 @@ ifeq ($(shell expr $(MAKE_VERSION) \>= 4.4), 1)
 $(let OUTPUT,$(OUTPUT)/,\
 	$(eval include ../../../build/Makefile.feature))
 else
-OUTPUT := $(OUTPUT)/
+override OUTPUT := $(OUTPUT)/
 $(eval include ../../../build/Makefile.feature)
-OUTPUT := $(patsubst %/,%,$(OUTPUT))
+override OUTPUT := $(patsubst %/,%,$(OUTPUT))
 endif
 endif
 

base-commit: a7c205120d339b6ad2557fe3f33fdf20394f1a0f
-- 
2.43.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-18 10:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 10:52 [PATCH bpf-next v1] selftests/bpf: avoid generating untracked files when running bpf selftests Jiayuan Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox