From: Stanislav Fomichev <sdf@fomichev.me>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 6/9] selftests/bpf: abstract away test log output
Date: Fri, 26 Jul 2019 15:26:52 -0700 [thread overview]
Message-ID: <20190726222652.GG24397@mini-arch> (raw)
In-Reply-To: <CAEf4BzaVCdHT_U+m7niJLsSmbf+M9DrFjf_PNOmQQZvuHsr9Xg@mail.gmail.com>
On 07/26, Andrii Nakryiko wrote:
> On Fri, Jul 26, 2019 at 2:31 PM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > On 07/26, Andrii Nakryiko wrote:
> > > This patch changes how test output is printed out. By default, if test
> > > had no errors, the only output will be a single line with test number,
> > > name, and verdict at the end, e.g.:
> > >
> > > #31 xdp:OK
> > >
> > > If test had any errors, all log output captured during test execution
> > > will be output after test completes.
> > >
> > > It's possible to force output of log with `-v` (`--verbose`) option, in
> > > which case output won't be buffered and will be output immediately.
> > >
> > > To support this, individual tests are required to use helper methods for
> > > logging: `test__printf()` and `test__vprintf()`.
> > >
> > > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > > ---
> > > .../selftests/bpf/prog_tests/bpf_obj_id.c | 6 +-
> > > .../bpf/prog_tests/bpf_verif_scale.c | 31 ++--
> > > .../bpf/prog_tests/get_stack_raw_tp.c | 4 +-
> > > .../selftests/bpf/prog_tests/l4lb_all.c | 2 +-
> > > .../selftests/bpf/prog_tests/map_lock.c | 10 +-
> > > .../selftests/bpf/prog_tests/send_signal.c | 8 +-
> > > .../selftests/bpf/prog_tests/spinlock.c | 2 +-
> > > .../bpf/prog_tests/stacktrace_build_id.c | 4 +-
> > > .../bpf/prog_tests/stacktrace_build_id_nmi.c | 4 +-
> > > .../selftests/bpf/prog_tests/xdp_noinline.c | 3 +-
> > > tools/testing/selftests/bpf/test_progs.c | 135 +++++++++++++-----
> > > tools/testing/selftests/bpf/test_progs.h | 37 ++++-
> > > 12 files changed, 173 insertions(+), 73 deletions(-)
> > >
>
> [...]
>
> > > error_cnt++;
> > > - printf("test_l4lb:FAIL:stats %lld %lld\n", bytes, pkts);
> > > + test__printf("test_l4lb:FAIL:stats %lld %lld\n", bytes, pkts);
> > #define printf(...) test__printf(...) in tests.h?
> >
> > A bit ugly, but no need to retrain everyone to use new printf wrappers.
>
> I try to reduce amount of magic and surprising things, not add new
> ones :) I also led by example and converted all current instances of
> printf usage to test__printf, so anyone new will just copy/paste good
> example, hopefully. Even if not, this non-buffered output will be
> immediately obvious to anyone who just runs `sudo ./test_progs`.
[..]
> And
> author of new test with this problem should hopefully be the first and
> the only one to catch and fix this.
Yeah, that is my only concern, that regular printfs will eventually
creep in. It's already confusing to go to/from printf/printk.
2c:
I'm coming from a perspective of tools/testing/selftests/kselftest.h
which is supposed to be a generic framework with custom
printf variants (ksft_print_msg), but I still see a bunch of tests
calling printf :-/
grep -ril ksft_exit_fail_msg selftests/ | xargs -n1 grep -w printf
Since we don't expect regular buffered io from the tests anyway
it might be easier just to add a bit of magic and call it a day.
> > > }
> > > out:
> > > bpf_object__close(obj);
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/map_lock.c b/tools/testing/selftests/bpf/prog_tests/map_lock.c
> > > index ee99368c595c..2e78217ed3fd 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/map_lock.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/map_lock.c
> > > @@ -9,12 +9,12 @@ static void *parallel_map_access(void *arg)
>
> [...]
next prev parent reply other threads:[~2019-07-26 22:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 20:37 [PATCH bpf-next 0/9] Revamp test_progs as a test running framework Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 1/9] selftests/bpf: prevent headers to be compiled as C code Andrii Nakryiko
2019-07-26 21:21 ` Stanislav Fomichev
2019-07-26 21:42 ` Andrii Nakryiko
2019-07-26 22:01 ` Stanislav Fomichev
2019-07-27 18:53 ` Andrii Nakryiko
2019-07-31 13:21 ` Ilya Leoshkevich
2019-07-31 17:04 ` Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 2/9] selftests/bpf: revamp test_progs to allow more control Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 3/9] selftests/bpf: add test selectors by number and name to test_progs Andrii Nakryiko
2019-07-26 21:25 ` Stanislav Fomichev
2019-07-26 21:45 ` Andrii Nakryiko
2019-07-26 22:03 ` Stanislav Fomichev
2019-07-26 20:37 ` [PATCH bpf-next 4/9] libbpf: add libbpf_swap_print to get previous print func Andrii Nakryiko
2019-07-26 21:28 ` Stanislav Fomichev
2019-07-26 21:47 ` Andrii Nakryiko
2019-07-27 0:30 ` Alexei Starovoitov
2019-07-27 18:49 ` Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 5/9] selftest/bpf: centralize libbpf logging management for test_progs Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 6/9] selftests/bpf: abstract away test log output Andrii Nakryiko
2019-07-26 21:31 ` Stanislav Fomichev
2019-07-26 21:51 ` Andrii Nakryiko
2019-07-26 22:26 ` Stanislav Fomichev [this message]
2019-07-27 0:34 ` Alexei Starovoitov
2019-07-27 18:56 ` Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 7/9] selftests/bpf: add sub-tests support for test_progs Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 8/9] selftests/bpf: convert bpf_verif_scale.c to sub-tests API Andrii Nakryiko
2019-07-26 20:37 ` [PATCH bpf-next 9/9] selftests/bpf: convert send_signal.c to use subtests Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190726222652.GG24397@mini-arch \
--to=sdf@fomichev.me \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox