> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_module_names.c 
> b/tools/testing/selftests/bpf/prog_tests/btf_module_names.c
> new file mode 100644
> index 0000000000000..3dc72bef014c8
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_module_names.c
> @@ -0,0 +1,139 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <test_progs.h>
> +#include "btf_module_names.skel.h"
> +
> +static void btf_module_names_load(void)
> +{
> +     struct btf_module_names *skel = NULL;
> +     int ret;
> +     static const char *mod_names[] = { "bpf_testmod" };
> +
> +     LIBBPF_OPTS(bpf_object_open_opts, opts,
> +             .btf_module_names = mod_names,
> +             .nr_btf_module_names = 1,
> +     );

[ ... ]

> +static void btf_module_names_skip(void)
> +{
> +     struct btf_module_names *skel = NULL;
> +     int ret;
> +     static const char *mod_names[] = { "module_nonexist" };
> +
> +     LIBBPF_OPTS(bpf_object_open_opts, opts,
> +             .btf_module_names = mod_names,
> +             .nr_btf_module_names = 1,
> +     );

[ ... ]

> +static void btf_module_names_empty(void)
> +{
> +     struct btf_module_names *skel = NULL;
> +     int ret;
> +     static const char *mod_names[] = { "" };
> +
> +     LIBBPF_OPTS(bpf_object_open_opts, opts,
> +             .btf_module_names = mod_names,
> +     );

[ ... ]

> +static void btf_module_names_invalid(void)
> +{
> +     struct btf_module_names *skel = NULL;
> +     const char *names[] = { NULL };
> +     const char *empty_names[] = { "" };
> +     const char *duplicate_names[] = {
> +             "bpf_testmod", "bpf_testmod",
> +     };
> +     LIBBPF_OPTS(bpf_object_open_opts, opts,
> +             .btf_module_names = names,
> +             .nr_btf_module_names = 1,
> +     );

This isn't a bug, but could the three static const char *mod_names[]
declarations in btf_module_names_load(), btf_module_names_skip(), and
btf_module_names_empty() just be automatic arrays, matching the non-static
declarations in btf_module_names_invalid()? Since libbpf strdup()s the
entries, the static storage doesn't add anything beyond inconsistency within
this new file.


---
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/32974547426

Reply via email to