From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Quentin Monnet <qmo@kernel.org>
Cc: bpf@vger.kernel.org
Subject: [PATCH bpf-next v2 0/6] bpftool, selftests: Add tests for C dump and fix a dropped type
Date: Fri, 28 Aug 2026 14:52:01 -0700 [thread overview]
Message-ID: <20260828215207.3105313-1-ihor.solodrai@linux.dev> (raw)
"bpftool btf dump format c" generates the vmlinux.h that BPF programs
are built against, and it has no direct test coverage. Building
against the header is not a substitute for testing it, nothing a
compiler accepts would break the build.
Add selftests targeting C dump in particular.
While we are here, refactor btf_dump selftests to use a new
compare_text_to_expected() helper and become more efficient.
Fix a bug in bpftool dump that dropped a type when sorting.
---
v1->v2:
* new patches (#1-#3) introducing compare_text_to_expected() helper
and refactoring btf_dump selftests
* bpftool dump selftest compares the output to the expected files
exactly (Eduard)
* use VALIDATE_RAW_BTF macro in the new test (Eduard)
* drop v1 patch #4 ("selftests/bpf: Check that sorting preserves
types in bpftool dump") as it became unnecessary
* nit in the bpftool fix (Andrii)
v1: https://lore.kernel.org/bpf/20260820000627.3826188-1-ihor.solodrai@linux.dev/
---
Ihor Solodrai (6):
selftests/bpf: Add compare_text_to_expected() helper
selftests/bpf: Modernize btf_dump test scaffolding
selftests/bpf: Compare btf_dump expected output in-process
selftests/bpf: NUL-terminate bpftool command output
selftests/bpf: Add tests for bpftool btf dump format c
bpftool: Don't drop a type in the sorted C dump
tools/bpf/bpftool/btf.c | 6 +-
tools/testing/selftests/bpf/Makefile | 8 +-
.../bpf/bpftool_btf_dump_sorted.expected | 48 +++++
.../bpf/bpftool_btf_dump_unsorted.expected | 48 +++++
tools/testing/selftests/bpf/bpftool_helpers.c | 7 +-
.../bpf/prog_tests/bpftool_btf_dump.c | 178 ++++++++++++++++++
.../selftests/bpf/prog_tests/btf_dump.c | 125 ++++++++----
.../bpf/prog_tests/prog_tests_framework.c | 23 +++
tools/testing/selftests/bpf/testing_helpers.c | 43 +++++
tools/testing/selftests/bpf/testing_helpers.h | 3 +
10 files changed, 446 insertions(+), 43 deletions(-)
create mode 100644 tools/testing/selftests/bpf/bpftool_btf_dump_sorted.expected
create mode 100644 tools/testing/selftests/bpf/bpftool_btf_dump_unsorted.expected
create mode 100644 tools/testing/selftests/bpf/prog_tests/bpftool_btf_dump.c
base-commit: cd35e1b10182c42b4ae31ee49119463b17d8ba7f
--
2.55.0
next reply other threads:[~2026-08-28 21:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 21:52 Ihor Solodrai [this message]
2026-08-28 21:52 ` [PATCH bpf-next v2 1/6] selftests/bpf: Add compare_text_to_expected() helper Ihor Solodrai
2026-08-28 21:52 ` [PATCH bpf-next v2 2/6] selftests/bpf: Modernize btf_dump test scaffolding Ihor Solodrai
2026-08-28 21:52 ` [PATCH bpf-next v2 3/6] selftests/bpf: Compare btf_dump expected output in-process Ihor Solodrai
2026-08-28 21:52 ` [PATCH bpf-next v2 4/6] selftests/bpf: NUL-terminate bpftool command output Ihor Solodrai
2026-08-28 21:52 ` [PATCH bpf-next v2 5/6] selftests/bpf: Add tests for bpftool btf dump format c Ihor Solodrai
2026-08-28 21:52 ` [PATCH bpf-next v2 6/6] bpftool: Don't drop a type in the sorted C dump Ihor Solodrai
2026-08-30 1:30 ` [PATCH bpf-next v2 0/6] bpftool, selftests: Add tests for C dump and fix a dropped type patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828215207.3105313-1-ihor.solodrai@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox