[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YOsEwcMRkUn5mdNr@krava>
Date: Sun, 11 Jul 2021 16:48:33 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.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 07, 2021 at 05:12:07PM -0700, Andrii Nakryiko wrote:
> 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 */
ok
>
> > +
> > + get_func_ip_test__detach(skel);
>
> no need to explicitly detach, __destroy does that automatically
I see, will remove that
thanks,
jirka
>
> > +
> > +cleanup:
> > + get_func_ip_test__destroy(skel);
> > +}
>
> [...]
>
Powered by blists - more mailing lists