[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZxDAQZ4Y5n8uCjvrEgmr51CY3AQ8y7zM_Hoh+7zqd6DA@mail.gmail.com>
Date: Wed, 7 Jul 2021 17:12:07 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andriin@...com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>
Subject: Re: [PATCHv3 bpf-next 5/7] selftests/bpf: Add test for
bpf_get_func_ip helper
On Wed, Jul 7, 2021 at 2:54 PM Jiri Olsa <jolsa@...hat.com> wrote:
>
> Adding test for bpf_get_func_ip helper for fentry, fexit,
> kprobe, kretprobe and fmod_ret programs.
>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> .../bpf/prog_tests/get_func_ip_test.c | 42 +++++++++++++
> .../selftests/bpf/progs/get_func_ip_test.c | 62 +++++++++++++++++++
> 2 files changed, 104 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
> create mode 100644 tools/testing/selftests/bpf/progs/get_func_ip_test.c
>
[...]
> + ASSERT_OK(err, "test_run");
> +
> + result = (__u64 *)skel->bss;
> + for (i = 0; i < sizeof(*skel->bss) / sizeof(__u64); i++) {
> + if (!ASSERT_EQ(result[i], 1, "fentry_result"))
> + break;
> + }
I dislike such generic loop over results. It's super error prone and
takes the same 5 lines of code that you'd write for explicit
ASSERT_EQ(testX_result, 1, "testX_result"); /* 5 times */
> +
> + get_func_ip_test__detach(skel);
no need to explicitly detach, __destroy does that automatically
> +
> +cleanup:
> + get_func_ip_test__destroy(skel);
> +}
[...]
Powered by blists - more mailing lists