[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bzap=EHCRXwePxU+sW94DGFFOLqBnwtJyqhnFJ+s86D4qQ@mail.gmail.com>
Date: Thu, 15 Jul 2021 23:24:35 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Alan Maguire <alan.maguire@...cle.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
john fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Bill Wendling <morbo@...gle.com>,
Shuah Khan <shuah@...nel.org>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6 bpf-next 3/3] selftests/bpf: add dump type data tests
to btf dump tests
On Thu, Jul 15, 2021 at 8:16 AM Alan Maguire <alan.maguire@...cle.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@...cle.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
>
Powered by blists - more mailing lists