Re: [PATCH bpf-next v5 07/11] selftests/bpf: Allow test_progs to link with a partial object set

sashiko-bot
2026-04-15T21:19:05Z

Sashiko AI review found 2 potential issue(s):
- [Medium] Moving `$(TRUNNER_TEST_OBJS)` to order-only prerequisites silently breaks incremental linking for BPF programs and headers.
- [Medium] Linking with a partial object set introduces a regression that causes the test runner to unconditionally abort at runtime.
--

commit 26b01d6050c56240db40d2043c1d68b4a725414c
Author: Ricardo B. Marlière <rbm@suse.com>

selftests/bpf: Allow test_progs to link with a partial object set

This commit modifies the Makefile to move test objects to the order-only
prerequisite list and uses wildcard expansion to only link built test
objects. This allows the test suite to link even if some test objects
fail to compile.

> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
[ ... ]
> -$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \
> - $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \
> +$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \
> $(TRUNNER_LIB_OBJS) \
> $(TRUNNER_BPFTOOL) \
> $(OUTPUT)/veristat \
> - | $(TRUNNER_BINARY)-extras
> + | $(TRUNNER_BINARY)-extras \
> + $(TRUNNER_TEST_OBJS)

Will moving TRUNNER_TEST_OBJS to the order-only prerequisites break
incremental builds?

In GNU Make, order-only prerequisites ensure build order but do not trigger
a rebuild of the target when they are updated.

Modifying a BPF program correctly recompiles the BPF object and the test
object file. However, because TRUNNER_TEST_OBJS is no longer a normal
prerequisite, it appears the binary will not be relinked unless a manual
clean is performed, silently ignoring changes to BPF programs.

> $$(call msg,BINARY,,$$@)
> - $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@
> + $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$(if $(PERMISSIVE),$$(wildcard $(TRUNNER_TEST_OBJS)),$(TRUNNER_TEST_OBJS)) $$^) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@

Does linking with a partial object set cause the test framework to
unconditionally abort at runtime?

The test framework dynamically generates prog_tests/tests.h which expands
into weak symbols in test_progs.c. If a test object is omitted due to a build
failure, its weak symbols correctly resolve to NULL.

During initialization, the test_progs binary iterates over registered tests
and validates that every test has a valid function pointer. It prints an error
and immediately aborts via exit(EXIT_ERR_SETUP_INFRA) if it encounters a NULL
pointer.

While this is addressed later in the series by commit 6ad669628925e
("selftests/bpf: Skip tests whose objects were not built"), does this patch
introduce a temporary break in test infrastructure functionality?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260415-selftests-bpf_misconfig-v5-0-03d0a52a898a@suse.com?part=7