Re: [RFC PATCH bpf-next v3 2/2] selftests/bpf: add tests for selective kmod BTF loading

From: bot+bpf-ci

Date: Wed Aug 19 2026 - 05:50:49 EST


> diff --git a/tools/testing/selftests/bpf/prog_tests/kmod_btfs.c b/tools/testing/selftests/bpf/prog_tests/kmod_btfs.c
> new file mode 100644
> index 000000000000..61d2845a731f
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/kmod_btfs.c
> @@ -0,0 +1,196 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <test_progs.h>
> +#include "kmod_btfs.skel.h"
> +
> +static bool btf_skipped;
> +static bool dup_ignored;
> +
> +static const char btf_skip_fmt[] =
> + "libbpf: skipping module BTF '%s', not in kmod_btf_names\n";
> +static const char dup_ignore_fmt[] =
> + "libbpf: duplicate kmod BTF name '%s' ignored\n";
> +
> +static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt,
> + va_list args)
> +{
> + if (!strcmp(fmt, btf_skip_fmt)) {
> + if (!strcmp(va_arg(args, char *), "bpf_test_no_cfi"))
> + btf_skipped = true;
> + } else if (!strcmp(fmt, dup_ignore_fmt)) {
> + if (!strcmp(va_arg(args, char *), "bpf_testmod"))
> + dup_ignored = true;
> + }
> +
> + return 0;
> +}
> +
> +static void kmod_btfs_pass(void)
> +{
> + struct kmod_btfs *skel = NULL;
> + int ret;
> + static const char *kmods[] = { "bpf_testmod" };
> +
> + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts,
> + .kmod_btf_names = kmods,
> + .kmod_btf_names_cnt = 1,
> + );

This isn't a bug, but would LIBBPF_OPTS() read better here than
DECLARE_LIBBPF_OPTS()? The same pattern appears in all five subtests
(kmod_btfs_pass, kmod_btfs_nonexist, kmod_btfs_dup, kmod_btfs_skip,
kmod_btfs_no_cnt). DECLARE_LIBBPF_OPTS is defined in libbpf_legacy.h as a
backwards-compatibility alias, and most of prog_tests/ uses LIBBPF_OPTS()
directly.

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32236360082