> diff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c 
> b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c
> new file mode 100644
> index 000000000000..140401dd2548
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c
> @@ -0,0 +1,99 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <errno.h>
> +#include <unistd.h>
> +#include <bpf/bpf.h>
> +#include <bpftool_helpers.h>
> +#include <test_progs.h>
> +
> +static const struct map_flags_test {
> +     const char *name;
> +     const char *flags;
> +     __u32 expected_flags;
> +     const char *error;
> +} tests[] = {
> +     { "zero", "0", 0 },
> +     { "decimal", "129", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
> +     { "hexadecimal", "0x81", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
> +     { "octal", "0201", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
> +     { "positive_sign", "+1", BPF_F_NO_PREALLOC },
> +     { "single_name", "BPF_F_NO_PREALLOC", BPF_F_NO_PREALLOC },
> +     { "combined_names", "BPF_F_NO_PREALLOC,BPF_F_RDONLY_PROG",
> +       BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
> +     { "repeated_name", "BPF_F_NO_PREALLOC,BPF_F_NO_PREALLOC", 
> BPF_F_NO_PREALLOC },
> +     { "unknown_name", "BPF_F_NOT_A_MAP_FLAG", 0, "can't parse" },
> +     { "other_command_flag", "BPF_F_PATH_FD", 0, "can't parse" },
> +     { "update_flag", "BPF_F_LOCK", 0, "can't parse" },
> +     { "abbreviated_name", "BPF_F_NO_PRE", 0, "can't parse" },
> +     { "lowercase_name", "bpf_f_no_prealloc", 0, "can't parse" },
> +     { "empty", "", 0, "can't parse" },
> +     { "whitespace", " ", 0, "can't parse" },
> +     { "empty_list", ",", 0, "can't parse" },
> +     { "leading_comma", ",BPF_F_NO_PREALLOC", 0, "can't parse" },
> +     { "trailing_comma", "BPF_F_NO_PREALLOC,", 0, "can't parse" },
> +     { "empty_element", "BPF_F_NO_PREALLOC,,BPF_F_RDONLY_PROG", 0, "can't 
> parse" },
> +     { "number_then_name", "1,BPF_F_RDONLY_PROG", 0, "can't parse" },
> +     { "name_then_number", "BPF_F_NO_PREALLOC,128", 0, "can't parse" },
> +     { "numeric_list", "1,128", 0, "can't parse" },
> +     { "whitespace_in_list", "BPF_F_NO_PREALLOC, BPF_F_RDONLY_PROG", 0, 
> "can't parse" },
> +     { "overflow_u32", "4294967296", 0, "can't parse" },
> +     { "overflow_hex", "0x100000000", 0, "can't parse" },
> +     { "overflow_u64", "18446744073709551616", 0, "can't parse" },
> +     { "negative", "-1", 0, "can't parse" },
> +     /* Numeric bits unknown to bpftool must still reach the kernel. */
> +     { "all_bits", "0xffffffff", 0, "map create failed" },
> +     { "invalid_combination", "BPF_F_RDONLY,BPF_F_WRONLY", 0, "map create 
> failed" },

This isn't a bug, but is the comment meant to cover both of the following
rows? The "invalid_combination" test uses a symbolic list rather than
unknown numeric bits, so it might read more clearly as something like
"bpftool does not validate map-specific flag combinations; the kernel
does".

> +};

[ ... ]


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

Reply via email to