BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/6] bpftool, selftests: Add tests for C dump and fix a dropped type
@ 2026-08-28 21:52 Ihor Solodrai
  2026-08-28 21:52 ` [PATCH bpf-next v2 1/6] selftests/bpf: Add compare_text_to_expected() helper Ihor Solodrai
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Ihor Solodrai @ 2026-08-28 21:52 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Quentin Monnet
  Cc: bpf

"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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-30  1:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 21:52 [PATCH bpf-next v2 0/6] bpftool, selftests: Add tests for C dump and fix a dropped type Ihor Solodrai
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox