diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-11-05 07:33:56 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-11-06 05:37:30 +0300 |
commit | 1306c980cf892bc17e7296d3e9ab8e9082f893a1 (patch) | |
tree | 4d0fd52e7c7133816bb205c02401996efdfc262f /tools/testing/selftests/bpf/btf_helpers.h | |
parent | 197389da2fbfbc3cefb229268c32d858d9575c96 (diff) | |
download | linux-1306c980cf892bc17e7296d3e9ab8e9082f893a1.tar.xz |
selftests/bpf: Add checking of raw type dump in BTF writer APIs selftests
Add re-usable btf_helpers.{c,h} to provide BTF-related testing routines. Start
with adding a raw BTF dumping helpers.
Raw BTF dump is the most succinct and at the same time a very human-friendly
way to validate exact contents of BTF types. Cross-validate raw BTF dump and
writable BTF in a single selftest. Raw type dump checks also serve as a good
self-documentation.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201105043402.2530976-7-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/btf_helpers.h')
-rw-r--r-- | tools/testing/selftests/bpf/btf_helpers.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/btf_helpers.h b/tools/testing/selftests/bpf/btf_helpers.h new file mode 100644 index 000000000000..2c9ce1b61dc9 --- /dev/null +++ b/tools/testing/selftests/bpf/btf_helpers.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2020 Facebook */ +#ifndef __BTF_HELPERS_H +#define __BTF_HELPERS_H + +#include <stdio.h> +#include <bpf/btf.h> + +int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id); +const char *btf_type_raw_dump(const struct btf *btf, int type_id); + +#endif |