Commit 99363382 authored by Jakub Sitnicki's avatar Jakub Sitnicki Committed by Alexei Starovoitov

selftests/bpf: Unroll the main loop in reuseport test

Prepare for iterating over individual tests without introducing another
nested loop in the main test function.
Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191212102259.418536-6-jakub@cloudflare.com
parent a9ce4cf4
...@@ -698,20 +698,9 @@ static const char *sotype_str(int sotype) ...@@ -698,20 +698,9 @@ static const char *sotype_str(int sotype)
} }
} }
static void test_all(void) static void test_config(int type, sa_family_t family, bool inany)
{ {
/* Extra SOCK_STREAM to test bind_inany==true */ int err;
const int types[] = { SOCK_STREAM, SOCK_DGRAM, SOCK_STREAM };
const sa_family_t families[] = { AF_INET6, AF_INET };
const bool bind_inany[] = { false, false, true };
int t, f, err;
for (f = 0; f < ARRAY_SIZE(families); f++) {
sa_family_t family = families[f];
for (t = 0; t < ARRAY_SIZE(types); t++) {
bool inany = bind_inany[t];
int type = types[t];
printf("######## %s/%s %s ########\n", printf("######## %s/%s %s ########\n",
family_str(family), sotype_str(type), family_str(family), sotype_str(type),
...@@ -737,8 +726,28 @@ static void test_all(void) ...@@ -737,8 +726,28 @@ static void test_all(void)
cleanup_per_test(); cleanup_per_test();
printf("\n"); printf("\n");
} }
}
#define BIND_INANY true
static void test_all(void)
{
const struct config {
int sotype;
sa_family_t family;
bool inany;
} configs[] = {
{ SOCK_STREAM, AF_INET },
{ SOCK_STREAM, AF_INET, BIND_INANY },
{ SOCK_STREAM, AF_INET6 },
{ SOCK_STREAM, AF_INET6, BIND_INANY },
{ SOCK_DGRAM, AF_INET },
{ SOCK_DGRAM, AF_INET6 },
};
const struct config *c;
for (c = configs; c < configs + ARRAY_SIZE(configs); c++)
test_config(c->sotype, c->family, c->inany);
} }
int main(int argc, const char **argv) int main(int argc, const char **argv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment