From: Jakub Sitnicki <jakub@cloudflare.com>
To: bpf@vger.kernel.org
Cc: Martin Lau <kafai@fb.com>, kernel-team@cloudflare.com
Subject: [PATCH bpf-next 08/10] selftests/bpf: Pull up printing the test name into test runner
Date: Thu, 12 Dec 2019 11:22:57 +0100 [thread overview]
Message-ID: <20191212102259.418536-9-jakub@cloudflare.com> (raw)
In-Reply-To: <20191212102259.418536-1-jakub@cloudflare.com>
Again, prepare for switching reuseport tests to test_progs framework.
test_progs framework will print the subtest name for us if we set it.
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
.../selftests/bpf/test_select_reuseport.c | 27 +++++++++----------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_select_reuseport.c b/tools/testing/selftests/bpf/test_select_reuseport.c
index cc35816b7b34..0d5687feb689 100644
--- a/tools/testing/selftests/bpf/test_select_reuseport.c
+++ b/tools/testing/selftests/bpf/test_select_reuseport.c
@@ -441,7 +441,6 @@ static void test_err_inner_map(int type, sa_family_t family)
.pass_on_failure = 0,
};
- printf("%s: ", __func__);
expected_results[DROP_ERR_INNER_MAP]++;
do_test(type, family, &cmd, DROP_ERR_INNER_MAP);
printf("OK\n");
@@ -449,7 +448,6 @@ static void test_err_inner_map(int type, sa_family_t family)
static void test_err_skb_data(int type, sa_family_t family)
{
- printf("%s: ", __func__);
expected_results[DROP_ERR_SKB_DATA]++;
do_test(type, family, NULL, DROP_ERR_SKB_DATA);
printf("OK\n");
@@ -462,7 +460,6 @@ static void test_err_sk_select_port(int type, sa_family_t family)
.pass_on_failure = 0,
};
- printf("%s: ", __func__);
expected_results[DROP_ERR_SK_SELECT_REUSEPORT]++;
do_test(type, family, &cmd, DROP_ERR_SK_SELECT_REUSEPORT);
printf("OK\n");
@@ -473,7 +470,6 @@ static void test_pass(int type, sa_family_t family)
struct cmd cmd;
int i;
- printf("%s: ", __func__);
cmd.pass_on_failure = 0;
for (i = 0; i < REUSEPORT_ARRAY_SIZE; i++) {
expected_results[PASS]++;
@@ -494,7 +490,6 @@ static void test_syncookie(int type, sa_family_t family)
if (type != SOCK_STREAM)
return;
- printf("%s: ", __func__);
/*
* +1 for TCP-SYN and
* +1 for the TCP-ACK (ack the syncookie)
@@ -530,7 +525,6 @@ static void test_pass_on_err(int type, sa_family_t family)
.pass_on_failure = 1,
};
- printf("%s: ", __func__);
expected_results[PASS_ERR_SK_SELECT_REUSEPORT] += 1;
do_test(type, family, &cmd, PASS_ERR_SK_SELECT_REUSEPORT);
printf("OK\n");
@@ -545,7 +539,6 @@ static void test_detach_bpf(int type, sa_family_t family)
struct cmd cmd = {};
int optvalue = 0;
- printf("%s: ", __func__);
err = setsockopt(sk_fds[0], SOL_SOCKET, SO_DETACH_REUSEPORT_BPF,
&optvalue, sizeof(optvalue));
CHECK(err == -1, "setsockopt(SO_DETACH_REUSEPORT_BPF)",
@@ -584,7 +577,7 @@ static void test_detach_bpf(int type, sa_family_t family)
printf("OK\n");
close(cli_fd);
#else
- printf("%s: SKIP\n", __func__);
+ printf("SKIP\n");
#endif
}
@@ -734,19 +727,22 @@ static const char *sotype_str(int sotype)
}
}
+#define TEST_INIT(fn, ...) { fn, #fn, __VA_ARGS__ }
+
static void test_config(int type, sa_family_t family, bool inany)
{
const struct test {
void (*fn)(int sotype, sa_family_t family);
+ const char *name;
bool no_inner_map;
} tests[] = {
- { test_err_inner_map, true /* no_inner_map */ },
- { test_err_skb_data },
- { test_err_sk_select_port },
- { test_pass },
- { test_syncookie },
- { test_pass_on_err },
- { test_detach_bpf },
+ TEST_INIT(test_err_inner_map, true /* no_inner_map */),
+ TEST_INIT(test_err_skb_data),
+ TEST_INIT(test_err_sk_select_port),
+ TEST_INIT(test_pass),
+ TEST_INIT(test_syncookie),
+ TEST_INIT(test_pass_on_err),
+ TEST_INIT(test_detach_bpf),
};
const struct test *t;
@@ -756,6 +752,7 @@ static void test_config(int type, sa_family_t family, bool inany)
for (t = tests; t < tests + ARRAY_SIZE(tests); t++) {
setup_per_test(type, family, inany, t->no_inner_map);
+ printf("%s: ", t->name);
t->fn(type, family);
cleanup_per_test(t->no_inner_map);
}
--
2.23.0
next prev parent reply other threads:[~2019-12-12 10:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 10:22 [PATCH bpf-next 00/10] Switch reuseport tests for test_progs framework Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 01/10] libbpf: Recognize SK_REUSEPORT programs from section name Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 02/10] selftests/bpf: Let libbpf determine program type " Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 03/10] selftests/bpf: Use sa_family_t everywhere in reuseport tests Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 04/10] selftests/bpf: Add helpers for getting socket family & type name Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 05/10] selftests/bpf: Unroll the main loop in reuseport test Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 06/10] selftests/bpf: Run reuseport tests in a loop Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 07/10] selftests/bpf: Propagate errors during setup for reuseport tests Jakub Sitnicki
2019-12-12 10:22 ` Jakub Sitnicki [this message]
2019-12-12 10:22 ` [PATCH bpf-next 09/10] selftests/bpf: Move reuseport tests under prog_tests/ Jakub Sitnicki
2019-12-12 10:22 ` [PATCH bpf-next 10/10] selftests/bpf: Switch reuseport tests for test_progs framework Jakub Sitnicki
2019-12-13 5:36 ` [PATCH bpf-next 00/10] " Alexei Starovoitov
2019-12-13 16:30 ` Martin Lau
2019-12-13 20:41 ` Alexei Starovoitov
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=20191212102259.418536-9-jakub@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=bpf@vger.kernel.org \
--cc=kafai@fb.com \
--cc=kernel-team@cloudflare.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;
as well as URLs for NNTP newsgroup(s).