From: Daniel Borkmann <daniel@iogearbox.net>
To: Nicolas Schichan <nschichan@freebox.fr>,
Alexei Starovoitov <ast@plumgrid.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] test_bpf: add module parameters to filter the tests to run.
Date: Mon, 03 Aug 2015 17:58:08 +0200 [thread overview]
Message-ID: <55BF8F90.5030001@iogearbox.net> (raw)
In-Reply-To: <1438610528-14245-5-git-send-email-nschichan@freebox.fr>
On 08/03/2015 04:02 PM, Nicolas Schichan wrote:
> When developping on the interpreter or a particular JIT, it can be
> insteresting to restrict the test list to a specific test or a
s/insteresting/interesting/
> particular range of tests.
>
> This patch adds the following module parameters to the test_bpf module:
>
> * test_name=<string>: only the specified named test will be run.
>
> * test_id=<number>: only the test with the specified id will be run
> (see the output of test_pbf without parameters to get the test id).
s/test_pbf/test_bpf/
> * test_range=<number>,<number>: only the tests with IDs in the
> specified id range are run (see the output of test_pbf without
s/test_pbf/test_bpf/
> parameters to get the test ids).
>
> Any invalid range, test id or test name will result in -EINVAL being
> returned and no tests being run.
>
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
Seems very useful for the test suite, thanks.
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
> lib/test_bpf.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 73 insertions(+)
>
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index f5606fb..abd0507 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -4870,10 +4870,72 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
> return err_cnt;
> }
>
> +static char test_name[64];
> +module_param_string(test_name, test_name, sizeof(test_name), 0);
> +
> +static int test_id = -1;
> +module_param(test_id, int, 0);
> +
> +static int test_range[2] = { -1, -1 };
> +module_param_array(test_range, int, NULL, 0);
> +
> +static __init int find_test_index(const char *test_name)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(tests); i++) {
> + if (!strcmp(tests[i].descr, test_name))
> + return i;
> + }
> + return -1;
> +}
> +
> static __init int prepare_bpf_tests(void)
> {
> int i;
>
> + if (test_id >= 0) {
> + /*
> + * if a test_id was specified, use test_range to
> + * conver only that test.
s/conver/cover/
> + */
> + if (test_id >= ARRAY_SIZE(tests)) {
> + pr_err("test_bpf: invalid test_id specified.\n");
> + return -EINVAL;
> + }
[...]
> @@ -4893,6 +4955,14 @@ static __init void destroy_bpf_tests(void)
> }
> }
>
> +static bool exclude_test(int test_id)
> +{
> + if (test_range[0] >= 0 &&
> + (test_id < test_range[0] || test_id > test_range[1]))
> + return true;
> + return false;
Minor nit: could directly return it, f.e.:
return test_range[0] >= 0 && (test_id < test_range[0] ||
test_id > test_range[1]);
Btw, for the range test in prepare_bpf_tests(), you could also reject
a negative lower bound index right there.
next prev parent reply other threads:[~2015-08-03 15:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 14:02 [PATCH 0/6] test_bpf improvements Nicolas Schichan
2015-08-03 14:02 ` [PATCH 1/6] test_bpf: avoid oopsing the kernel when generate_test_data() fails Nicolas Schichan
2015-08-03 14:48 ` Daniel Borkmann
2015-08-03 14:02 ` [PATCH 2/6] test_bpf: allow tests to specify an skb fragment Nicolas Schichan
2015-08-03 15:29 ` Daniel Borkmann
2015-08-03 16:38 ` Nicolas Schichan
2015-08-03 17:37 ` Daniel Borkmann
2015-08-03 14:02 ` [PATCH 3/6] test_bpf: test LD_ABS and LD_IND instructions on fragmented skbs Nicolas Schichan
2015-08-03 15:00 ` Daniel Borkmann
2015-08-03 14:02 ` [PATCH 4/6] test_bpf: add module parameters to filter the tests to run Nicolas Schichan
2015-08-03 15:58 ` Daniel Borkmann [this message]
2015-08-03 16:23 ` Nicolas Schichan
2015-08-03 16:34 ` Daniel Borkmann
2015-08-03 14:02 ` [PATCH 5/6] test_bpf: add more tests for LD_ABS and LD_IND Nicolas Schichan
2015-08-03 15:02 ` Daniel Borkmann
2015-08-03 14:02 ` [PATCH 6/6] test_bpf: add tests checking that JIT/interpreter sets A and X to 0 Nicolas Schichan
2015-08-03 15:03 ` Daniel Borkmann
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=55BF8F90.5030001@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nschichan@freebox.fr \
/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