netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Song Liu <song@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH v2 bpf-next 7/7] selftests/bpf: Add unit tests for global functions
Date: Thu, 9 Jan 2020 14:09:37 -0800	[thread overview]
Message-ID: <20200109220935.iyabjybd5bsesszy@ast-mbp> (raw)
In-Reply-To: <CAPhsuW67HfWZ7JLMWtXSURc97SSP4MOT7d65F+r075qGqpW9Cg@mail.gmail.com>

On Thu, Jan 09, 2020 at 09:27:26AM -0800, Song Liu wrote:
> On Wed, Jan 8, 2020 at 10:39 PM Alexei Starovoitov <ast@kernel.org> wrote:
> >
> > test_global_func[12] - check 512 stack limit.
> > test_global_func[34] - check 8 frame call chain limit.
> > test_global_func5    - check that non-ctx pointer cannot be passed into
> >                        a function that expects context.
> > test_global_func6    - check that ctx pointer is unmodified.
> >
> > Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> 
> Acked-by: Song Liu <songliubraving@fb.com>
> 
> > ---
> >  .../bpf/prog_tests/test_global_funcs.c        | 81 +++++++++++++++++++
> >  .../selftests/bpf/progs/test_global_func1.c   | 45 +++++++++++
> >  .../selftests/bpf/progs/test_global_func2.c   |  4 +
> >  .../selftests/bpf/progs/test_global_func3.c   | 65 +++++++++++++++
> >  .../selftests/bpf/progs/test_global_func4.c   |  4 +
> >  .../selftests/bpf/progs/test_global_func5.c   | 31 +++++++
> >  .../selftests/bpf/progs/test_global_func6.c   | 31 +++++++
> >  7 files changed, 261 insertions(+)
> >  create mode 100644 tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func1.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func2.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func3.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func4.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func5.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/test_global_func6.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
> > new file mode 100644
> > index 000000000000..bc588fa87d65
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
> > @@ -0,0 +1,81 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Copyright (c) 2020 Facebook */
> > +#include <test_progs.h>
> > +
> > +const char *err_str;
> > +bool found;
> > +
> > +static int libbpf_debug_print(enum libbpf_print_level level,
> > +                             const char *format, va_list args)
> > +{
> > +       char *log_buf;
> > +
> > +       if (level != LIBBPF_WARN ||
> > +           strcmp(format, "libbpf: \n%s\n")) {
> > +               vprintf(format, args);
> > +               return 0;
> > +       }
> > +
> > +       log_buf = va_arg(args, char *);
> > +       if (!log_buf)
> > +               goto out;
> > +       if (strstr(log_buf, err_str) == 0)
> > +               found = true;
> > +out:
> > +       printf(format, log_buf);
> > +       return 0;
> > +}
> 
> libbpf_debug_print() looks very useful. Maybe we can move it to some
> header files?

I think it's hack that goes deep into libbpf internals that should be
discouraged. It's clearly very useful for selftests, but imo libbpf's log_buf
api should be redesigned instead. It's imo the worst part of the library.

  reply	other threads:[~2020-01-09 22:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09  6:37 [PATCH v2 bpf-next 0/7] bpf: Introduce global functions Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 1/7] libbpf: Sanitize " Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 2/7] libbpf: Collect static vs global info about functions Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 3/7] bpf: Introduce function-by-function verification Alexei Starovoitov
2020-01-09 18:09   ` Song Liu
2020-01-09 22:17     ` Alexei Starovoitov
2020-01-22  2:30       ` Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 4/7] selftests/bpf: Add fexit-to-skb test for global funcs Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 5/7] selftests/bpf: Add a test for a large global function Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 6/7] selftests/bpf: Modify a test to check global functions Alexei Starovoitov
2020-01-09  6:37 ` [PATCH v2 bpf-next 7/7] selftests/bpf: Add unit tests for " Alexei Starovoitov
2020-01-09 17:27   ` Song Liu
2020-01-09 22:09     ` Alexei Starovoitov [this message]
2020-01-09 22:35       ` Song Liu

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=20200109220935.iyabjybd5bsesszy@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=song@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;
as well as URLs for NNTP newsgroup(s).