Re: [PATCH bpf-next 4/4] selftests/bpf: Add bpf_fib_lookup test

Andrii Nakryiko
2023-02-17T23:02:25Z

On Thu, Feb 16, 2023 at 4:42 PM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> From: Martin KaFai Lau <martin.lau@kernel.org>
>
> This patch tests the bpf_fib_lookup helper when looking up
> a neigh in NUD_FAILED and NUD_STALE state. It also adds test
> for the new BPF_FIB_LOOKUP_SKIP_NEIGH flag.
>
> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
> ---
> .../selftests/bpf/prog_tests/fib_lookup.c | 187 ++++++++++++++++++
> .../testing/selftests/bpf/progs/fib_lookup.c | 22 +++
> 2 files changed, 209 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/fib_lookup.c
> create mode 100644 tools/testing/selftests/bpf/progs/fib_lookup.c
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
> new file mode 100644
> index 000000000000..61ccddccf485
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c
> @@ -0,0 +1,187 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
> +
> +#include <sys/types.h>
> +#include <net/if.h>
> +
> +#include "test_progs.h"
> +#include "network_helpers.h"
> +#include "fib_lookup.skel.h"
> +
> +#define SYS(fmt, ...) \
> + ({ \
> + char cmd[1024]; \
> + snprintf(cmd, sizeof(cmd), fmt, ##__VA_ARGS__); \
> + if (!ASSERT_OK(system(cmd), cmd)) \
> + goto fail; \
> + })

it's probably a high time to move this SYS() macro into test_progs.h
and stop copy/pasting it across many test? …