summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorQiliang Yuan <odys.yuan@gmail.com>2026-10-09 09:49:42 +0800
committerDaniel Borkmann <daniel@iogearbox.net>2026-10-15 18:50:39 +0200
commit653b8f14fdda385bd7c5b786f8dfdcc3e5599e27 (patch)
tree06b9e38733429aaf0e73428b5278a9f688f8ab54 /tools
parentd3c9ecb8765d4befbc46ee325c8d76efd523eece (diff)
selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test
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. 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@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: T.J. Mercier <tjmercier@google.com> Link: https://lore.kernel.org/bpf/20261009-selftests-bpf-dmabuf-iter-unnamed-v1-1-962ee94f7a5e@gmail.com
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c5
1 files 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 fb2cea710db3..1a5dc1adae73 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");