> diff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_metadata.c
> b/tools/testing/selftests/bpf/prog_tests/bpftool_metadata.c
> new file mode 100644
> index 000000000000..b5598741a01c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/bpftool_metadata.c
[ ... ]
> +static void run_test(struct test_desc *test)
> +{
> + int ret;
> + char cmd[MAX_BPFTOOL_CMD_LEN];
> +
> + ret = snprintf(cmd, MAX_BPFTOOL_CMD_LEN, "prog load %s %s",
> + test->bpf_prog, test->bpffs_path);
> + if (!ASSERT_GT(ret, 0, "format prog insert command"))
> + return;
> + ret = run_bpftool_command(cmd);
> + if (!ASSERT_OK(ret, "load program"))
> + return;
> +
> + /* Check output with default format */
> + ret = snprintf(cmd, MAX_BPFTOOL_CMD_LEN, "prog show pinned %s",
> + test->bpffs_path);
> + if (!ASSERT_GT(ret, 0, "format pinned prog check command"))
> + return;
> + ret = get_bpftool_command_output(cmd, output,
> + MAX_BPFTOOL_OUTPUT_LEN);
> + if (ASSERT_OK(ret, "get program info")) {
> + ret = check_metadata(output, test->expected_output,
> + ARRAY_SIZE(test->expected_output));
> + ASSERT_OK(ret, "find metadata");
> + }
> +
> + /* Check output with json format */
> + ret = snprintf(cmd, MAX_BPFTOOL_CMD_LEN, "prog -j show pinned %s",
> + test->bpffs_path);
> + if (!ASSERT_GT(ret, 0, "format pinned prog check command in json"))
> + return;
> + ret = get_bpftool_command_output(cmd, output,
> + MAX_BPFTOOL_OUTPUT_LEN);
> + if (ASSERT_OK(ret, "get program info in json")) {
> + ret = check_metadata(output, test->expected_output_json,
> + ARRAY_SIZE(test->expected_output_json));
> + ASSERT_OK(ret, "find metadata in json");
> + }
> +
> +}
The original shell script also verified the map listing output:
> diff --git a/tools/testing/selftests/bpf/test_bpftool_metadata.sh
> b/tools/testing/selftests/bpf/test_bpftool_metadata.sh
> deleted file mode 100755
> index b5520692f41b..000000000000
> --- a/tools/testing/selftests/bpf/test_bpftool_metadata.sh
> +++ /dev/null
[ ... ]
> -bpftool prog --json | grep '"metadata":{"a":"foo","b":1}' > /dev/null
> -
> -bpftool map | grep 'metadata.rodata' > /dev/null
[ ... ]
> -bpftool prog --json | grep '"metadata":{"a":"bar","b":2}' > /dev/null
> -
> -bpftool map | grep 'metadata.rodata' > /dev/null
Was the "bpftool map | grep 'metadata.rodata'" check intentionally removed
from the converted test? The original script verified that the metadata map
appeared in bpftool's map listing, which tests a different code path than
the "prog show" commands. If this was dropped on purpose, it might be worth
a comment explaining why; otherwise this appears to be a test coverage
regression.
---
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/21225032840