Re: [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test

From: T.J. Mercier

Date: Fri Oct 09 2026 - 11:34:08 EST


On Fri, Oct 9, 2026 at 3:49 AM Qiliang Yuan <odys.yuan@xxxxxxxxx> wrote:
>
> The dmabuf_collector iterator prints the inode, size, name and exporter
> of every dma-buf in the system on separate lines, with an empty name for
> the buffers that have none. The default_iter subtest parses that output
> and looks for the two buffers it created.
>
> It requires a name for every buffer, and sscanf() finds none on the
> empty line of an unnamed one. On a system that has such a buffer, like
> one exported by udmabuf without a name, the subtest fails before it gets
> to its own buffers.

Hi Qiliang, are you running this locally instead of with:
tools/testing/selftests/bpf/vmtest.sh -- ./test_progs?

> Take an empty name for a buffer without one.
>
> Fixes: ae5d2c59ecd7 ("selftests/bpf: Add test for dmabuf_iter")
> Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
> ---
> tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> index fb2cea710db3e..1a5dc1adae735 100644
> --- a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> @@ -188,8 +188,9 @@ static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel)
> ASSERT_EQ(sscanf(line, "%ld", &bufinfo.size), 1,
> "read size");
> } else if (f % FIELD_COUNT == NAME) {
> - ASSERT_EQ(sscanf(line, "%s", bufinfo.name), 1,
> - "read name");
> + /* Keep an empty name for a buffer without one */
> + if (sscanf(line, "%s", bufinfo.name) != 1)
> + bufinfo.name[0] = '\0';
> } else if (f % FIELD_COUNT == EXPORTER) {
> ASSERT_EQ(sscanf(line, "%31s", bufinfo.exporter), 1,
> "read exporter");
>
> ---
> base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
> change-id: 20261009-selftests-bpf-dmabuf-iter-unnamed-217561e20d84
>
> Best regards,
> --
> Qiliang Yuan <odys.yuan@xxxxxxxxx>
>