diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2023-02-15 20:59:53 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-02-17 21:20:44 +0100 |
commit | 95ebb376176c52382293e05e63f142114a5e40ef (patch) | |
tree | 17b8bedca1f8aa7ab08816ef2f6fede6108a38fe /tools/testing/selftests/bpf/progs/test_global_func4.c | |
parent | d384dce281ed1b504fae2e279507827638d56fa3 (diff) | |
download | linux-95ebb376176c52382293e05e63f142114a5e40ef.tar.gz linux-95ebb376176c52382293e05e63f142114a5e40ef.tar.bz2 linux-95ebb376176c52382293e05e63f142114a5e40ef.zip |
selftests/bpf: Convert test_global_funcs test to test_loader framework
Convert 17 test_global_funcs subtests into test_loader framework for
easier maintenance and more declarative way to define expected
failures/successes.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20230216045954.3002473-3-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_global_func4.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_global_func4.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_global_func4.c b/tools/testing/selftests/bpf/progs/test_global_func4.c index 610f75edf276..1733d87ad3f3 100644 --- a/tools/testing/selftests/bpf/progs/test_global_func4.c +++ b/tools/testing/selftests/bpf/progs/test_global_func4.c @@ -1,4 +1,55 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2020 Facebook */ -#define NO_FN8 -#include "test_global_func3.c" +#include <stddef.h> +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> +#include "bpf_misc.h" + +__attribute__ ((noinline)) +int f1(struct __sk_buff *skb) +{ + return skb->len; +} + +__attribute__ ((noinline)) +int f2(int val, struct __sk_buff *skb) +{ + return f1(skb) + val; +} + +__attribute__ ((noinline)) +int f3(int val, struct __sk_buff *skb, int var) +{ + return f2(var, skb) + val; +} + +__attribute__ ((noinline)) +int f4(struct __sk_buff *skb) +{ + return f3(1, skb, 2); +} + +__attribute__ ((noinline)) +int f5(struct __sk_buff *skb) +{ + return f4(skb); +} + +__attribute__ ((noinline)) +int f6(struct __sk_buff *skb) +{ + return f5(skb); +} + +__attribute__ ((noinline)) +int f7(struct __sk_buff *skb) +{ + return f6(skb); +} + +SEC("tc") +__success +int global_func4(struct __sk_buff *skb) +{ + return f7(skb); +} |