On Thu, Jul 15, 2021 at 8:16 AM Alan Maguire alan.maguire@oracle.com wrote:
Test various type data dumping operations by comparing expected format with the dumped string; an snprintf-style printf function is used to record the string dumped. Also verify overflow handling where the data passed does not cover the full size of a type, such as would occur if a tracer has a portion of the 8k "struct task_struct".
Signed-off-by: Alan Maguire alan.maguire@oracle.com
tools/testing/selftests/bpf/prog_tests/btf_dump.c | 600 ++++++++++++++++++++++ 1 file changed, 600 insertions(+)
[...]
@@ -245,4 +815,34 @@ void test_btf_dump() { } if (test__start_subtest("btf_dump: incremental")) test_btf_dump_incremental();
btf = libbpf_find_kernel_btf();
if (!ASSERT_NEQ(btf, NULL, "no kernel BTF found"))
return;
d = btf_dump__new(btf, NULL, &opts, btf_dump_snprintf);
if (!ASSERT_NEQ(d, NULL, "could not create BTF dump"))
better use ASSERT_OK_PTR() for this, I'll adjust when applying
return;
/* Verify type display for various types. */
if (test__start_subtest("btf_dump: int_data"))
test_btf_dump_int_data(btf, d, str);
if (test__start_subtest("btf_dump: float_data"))
test_btf_dump_float_data(btf, d, str);
if (test__start_subtest("btf_dump: char_data"))
test_btf_dump_char_data(btf, d, str);
if (test__start_subtest("btf_dump: typedef_data"))
test_btf_dump_typedef_data(btf, d, str);
if (test__start_subtest("btf_dump: enum_data"))
test_btf_dump_enum_data(btf, d, str);
if (test__start_subtest("btf_dump: struct_data"))
test_btf_dump_struct_data(btf, d, str);
if (test__start_subtest("btf_dump: var_data"))
test_btf_dump_var_data(btf, d, str);
btf_dump__free(d);
btf__free(btf);
if (test__start_subtest("btf_dump: datasec_data"))
test_btf_dump_datasec_data(str);
}
1.8.3.1