diff options
author | Andrii Nakryiko | 2019-07-05 17:50:11 +0200 |
---|---|---|
committer | Daniel Borkmann | 2019-07-05 22:52:25 +0200 |
commit | bc7430cc8bfb51577e466a8ca02ad87375a70bde (patch) | |
tree | c56b050f3bb07c491da3f0fa082e651dbfe6d993 /tools/testing/selftests/bpf/progs/test_global_data.c | |
parent | selftests/bpf: add __uint and __type macro for BTF-defined maps (diff) | |
download | kernel-qcow2-linux-bc7430cc8bfb51577e466a8ca02ad87375a70bde.tar.gz kernel-qcow2-linux-bc7430cc8bfb51577e466a8ca02ad87375a70bde.tar.xz kernel-qcow2-linux-bc7430cc8bfb51577e466a8ca02ad87375a70bde.zip |
selftests/bpf: convert selftests using BTF-defined maps to new syntax
Convert all the existing selftests that are already using BTF-defined
maps to use new syntax (with no static data initialization).
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_global_data.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_global_data.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_global_data.c b/tools/testing/selftests/bpf/progs/test_global_data.c index 866cc7ddbe43..32a6073acb99 100644 --- a/tools/testing/selftests/bpf/progs/test_global_data.c +++ b/tools/testing/selftests/bpf/progs/test_global_data.c @@ -8,24 +8,18 @@ #include "bpf_helpers.h" struct { - __u32 type; - __u32 max_entries; - __u32 *key; - __u64 *value; -} result_number SEC(".maps") = { - .type = BPF_MAP_TYPE_ARRAY, - .max_entries = 11, -}; + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 11); + __type(key, __u32); + __type(value, __u64); +} result_number SEC(".maps"); struct { - __u32 type; - __u32 max_entries; - __u32 *key; + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 5); + __type(key, __u32); const char (*value)[32]; -} result_string SEC(".maps") = { - .type = BPF_MAP_TYPE_ARRAY, - .max_entries = 5, -}; +} result_string SEC(".maps"); struct foo { __u8 a; @@ -34,14 +28,11 @@ struct foo { }; struct { - __u32 type; - __u32 max_entries; - __u32 *key; - struct foo *value; -} result_struct SEC(".maps") = { - .type = BPF_MAP_TYPE_ARRAY, - .max_entries = 5, -}; + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 5); + __type(key, __u32); + __type(value, struct foo); +} result_struct SEC(".maps"); /* Relocation tests for __u64s. */ static __u64 num0; |