Re: [PATCH bpf-next v4] selftests/bpf: use auto-dependencies for test objects

Eduard Zingerman
2024-07-23T01:49:29Z

On Mon, 2024-07-22 at 17:57 -0700, Eduard Zingerman wrote:
> On Mon, 2024-07-22 at 17:39 -0700, Alexei Starovoitov wrote:
>
> [...]
>
> > Andrii, Ihor,
> >
> > not sure what happened, but 'make clean' now takes forever.
> > Pls take a look.
>
> It happens under certain conditions, here is a scenario that behaves
> badly for me:
> - two branches:
> - 'master' at cca09a371fa7
> - 'tmp' with [0] applied on top of master
> - Steps to repro:
>
> # cd selftests directory
> $ git checkout tmp
> $ git clean -xfd . # be careful
> $ make -j test_progs
> $ git checkout master
> $ make clean
>
> After which output looks as follows:
>
> CLNG-BPF [test_maps] access_map_in_map.bpf.o
> GEN-SKEL [test_progs] access_map_in_map.skel.h
> CLNG-BPF [test_maps] arena_atomics.bpf.o
> GEN-SKEL [test_progs] arena_atomics.skel.h
> ...
>
> [0] https://lore.kernel.org/bpf/20240719110059.797546-1-xukuohai@huaweicloud.com/

Here is a funny part.
The switch from 'tmp' to 'master' touches a number of prog_tests/*.c files.
The output of 'make --debug=basic clean' is:

Reading makefiles...
Updating makefiles....
CLNG-BPF [test_maps] access_map_in_map.bpf.o
GEN-SKEL [test_progs] access_map_in_map.skel.h

There are .test.d files after test_progs build for tmp.
Because of the include directive:

include $(wildcard $(TRUNNER_TEST_OBJS:.o=.d))

and a dependency:

$(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \
$(TRUNNER_TESTS_DIR)/%.c \
...

make goes ahead and detects that these .test.d files are now outdated.
So, before executing 'clean' recipe it executes recipes to update
.test.d files.