public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: David Vernet <void@manifault.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Artem Savkov <asavkov@redhat.com>
Subject: Re: [PATCHv2 bpf-next 2/7] selftests/bpf: Move test_progs helpers to testing_helpers object
Date: Tue, 31 Jan 2023 00:16:54 +0100	[thread overview]
Message-ID: <Y9hP5hQVcVWh3rQ8@krava> (raw)
In-Reply-To: <Y9fg5ErTG2xaYlV8@maniforge>

On Mon, Jan 30, 2023 at 09:23:16AM -0600, David Vernet wrote:

SNIP

> > diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c
> > index 9695318e8132..c0eb54bf08b3 100644
> > --- a/tools/testing/selftests/bpf/testing_helpers.c
> > +++ b/tools/testing/selftests/bpf/testing_helpers.c
> > @@ -8,6 +8,7 @@
> >  #include <bpf/libbpf.h>
> >  #include "test_progs.h"
> >  #include "testing_helpers.h"
> > +#include <linux/membarrier.h>
> >  
> >  int parse_num_list(const char *s, bool **num_set, int *num_set_len)
> >  {
> > @@ -229,3 +230,65 @@ int bpf_test_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
> >  
> >  	return bpf_prog_load(type, NULL, license, insns, insns_cnt, &opts);
> >  }
> > +
> > +static int finit_module(int fd, const char *param_values, int flags)
> > +{
> > +	return syscall(__NR_finit_module, fd, param_values, flags);
> > +}
> > +
> > +static int delete_module(const char *name, int flags)
> > +{
> > +	return syscall(__NR_delete_module, name, flags);
> > +}
> > +
> > +void unload_bpf_testmod(FILE *err, bool verbose)
> 
> Maybe you should pass a const struct test_env * here and in
> load_bpf_testmod() instead?  Technically it also has a FILE *stdout, so
> to be consistent we should probably also pass that to the fprintf()
> calls on the success path.

struct test_env is specific for test_progs and we want to call
un/load_bpf_testmod from test_verifier.. but yes, it looks weird
to pass just 'err' and verbose.. maybe we could pass both out/err

> 
> > +{
> > +	if (kern_sync_rcu())
> > +		fprintf(err, "Failed to trigger kernel-side RCU sync!\n");
> > +	if (delete_module("bpf_testmod", 0)) {
> > +		if (errno == ENOENT) {
> > +			if (verbose)
> > +				fprintf(stdout, "bpf_testmod.ko is already unloaded.\n");
> > +			return;
> > +		}
> > +		fprintf(err, "Failed to unload bpf_testmod.ko from kernel: %d\n", -errno);
> > +		return;
> > +	}
> > +	if (verbose)
> > +		fprintf(stdout, "Successfully unloaded bpf_testmod.ko.\n");
> > +}
> > +

SNIP

> > diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h
> > index 6ec00bf79cb5..2f80ca5b5f54 100644
> > --- a/tools/testing/selftests/bpf/testing_helpers.h
> > +++ b/tools/testing/selftests/bpf/testing_helpers.h
> > @@ -1,5 +1,9 @@
> >  /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
> >  /* Copyright (C) 2020 Facebook, Inc. */
> > +
> > +#ifndef __TRACING_HELPERS_H
> > +#define __TRACING_HELPERS_H
> 
> s/__TRACING/__TESTING here and below

right, thanks

jirka

  reply	other threads:[~2023-01-30 23:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30  8:55 [PATCHv2 bpf-next 0/7] bpf: Move kernel test kfuncs into bpf_testmod Jiri Olsa
2023-01-30  8:55 ` [PATCHv2 bpf-next 1/7] selftests/bpf: Move kfunc exports to bpf_testmod/bpf_testmod_kfunc.h Jiri Olsa
2023-01-30 15:15   ` David Vernet
2023-01-30 23:16     ` Jiri Olsa
2023-01-30  8:55 ` [PATCHv2 bpf-next 2/7] selftests/bpf: Move test_progs helpers to testing_helpers object Jiri Olsa
2023-01-30 15:23   ` David Vernet
2023-01-30 23:16     ` Jiri Olsa [this message]
2023-01-30  8:55 ` [PATCHv2 bpf-next 3/7] selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod Jiri Olsa
2023-01-30 15:28   ` David Vernet
2023-01-30  8:55 ` [PATCHv2 bpf-next 4/7] selftests/bpf: Use un/load_bpf_testmod functions in tests Jiri Olsa
2023-01-30 15:32   ` David Vernet
2023-01-30  8:55 ` [PATCHv2 bpf-next 5/7] selftests/bpf: Load bpf_testmod for verifier test Jiri Olsa
2023-01-30  8:55 ` [PATCHv2 bpf-next 6/7] selftests/bpf: Allow to use kfunc from testmod.ko in test_verifier Jiri Olsa
2023-01-30  8:55 ` [PATCHv2 bpf-next 7/7] bpf: Move kernel test kfuncs to bpf_testmod Jiri Olsa

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=Y9hP5hQVcVWh3rQ8@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=asavkov@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=memxor@gmail.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=void@manifault.com \
    --cc=yhs@fb.com \
    /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