On Fri, Jul 12, 2024 at 12:06 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Fri, 2024-07-12 at 17:48 +0000, Ihor Solodrai wrote: > > [...] > > > I've made a mistake when I removed $(TRUNNER_BPF_OBJS) as a > > prerequisite for $(TRUNNER_TEST_OBJS:.o=.d) > > > > I assumed it is covered by: > > > > $(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT) > > > > Apparently there are .bpf.o files for which skels are not generated, > > yet they are used in tests. > > > > Fixed in v3. > > So, bear with me for a moment please. > We have 3 test_progs/smth.c files that depend on a few .bpf.o files at runtime, > but do not include skel files for those .bpf.o, namely: > - core_reloc.c > - verifier_bitfield_write.c > - pinning.c > > And we fix this by adding a dependency: > > $(TRUNNER_TEST_OBJS:.o=.d): ... $(TRUNNER_BPF_OBJS) > > Which makes all *.test.d files depend on .bpf.o files. > Thus, if progs/some.c file is changed and `make test_progs` is requested: > - because *.test.d files are included into current makefile [1], > make invokes targets for *.test.d files; > - *.test.d targets depend on *.bpf.o, thus some.bpf.o is rebuilt > (but only some.bpf.o, dependencies for other *.bpf.o are up to date); > - case A, skel for some.c is not included anywhere (CI failure for v2): > - nothing happens further, as *.test.d files are unchanged *.test.o > files are not rebuilt and test_progs is up to date > - case B, skel for some.c is included in prog_tests/other.c: > - existing other.test.d lists some.skel.h as a dependency; > - this dependency is not up to date, so other.test.o is rebuilt; > - test_progs is rebuilt. > > Do I understand the above correctly? > > An alternative fix would be to specify additional dependencies for > core_reloc.test.o (and others) directly, e.g.: > > core_reloc.test.o: test_core_reloc_module.bpf.o ... > > (with correct trunner prefix) I was about to say that not all tests use BPF skeleton headers just yet, so we have to have a way to explicitly specify dependencies. I think a separate list should be good enough for now, and in parallel we should try to switch remaining tests to skeleton headers. Even if we don't want to convert tests themselves to using skeleton structs, we can convert them to use elf_bytes from skeleton headers instead of loading .bpf.o files from disk. That should eliminate the need for extra dependencies. > > What are pros and cons between these two approaches? > > [1] https://make.mad-scientist.net/constructed-include-files/ >