selftests/bpf: remove last tests with legacy BPF map definitions
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 27 Jun 2022 21:15:25 +0000 (14:15 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 28 Jun 2022 20:13:33 +0000 (13:13 -0700)
Libbpf 1.0 stops support legacy-style BPF map definitions. Selftests has
been migrated away from using legacy BPF map definitions except for two
selftests, to make sure that legacy functionality still worked in
pre-1.0 libbpf. Now it's time to let those tests go as libbpf 1.0 is
imminent.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20220627211527.2245459-14-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/bpf_legacy.h
tools/testing/selftests/bpf/prog_tests/btf.c
tools/testing/selftests/bpf/progs/test_btf_haskv.c [deleted file]
tools/testing/selftests/bpf/progs/test_btf_newkv.c

index 719ab56..8452095 100644 (file)
@@ -2,15 +2,6 @@
 #ifndef __BPF_LEGACY__
 #define __BPF_LEGACY__
 
-#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val)         \
-       struct ____btf_map_##name {                             \
-               type_key key;                                   \
-               type_val value;                                 \
-       };                                                      \
-       struct ____btf_map_##name                               \
-       __attribute__ ((section(".maps." #name), used))         \
-               ____btf_map_##name = { }
-
 /* llvm builtin functions that eBPF C program may use to
  * emit BPF_LD_ABS and BPF_LD_IND instructions
  */
index 1fd792a..941b010 100644 (file)
@@ -4651,7 +4651,6 @@ struct btf_file_test {
 };
 
 static struct btf_file_test file_tests[] = {
-       { .file = "test_btf_haskv.o", },
        { .file = "test_btf_newkv.o", },
        { .file = "test_btf_nokv.o", .btf_kv_notfound = true, },
 };
diff --git a/tools/testing/selftests/bpf/progs/test_btf_haskv.c b/tools/testing/selftests/bpf/progs/test_btf_haskv.c
deleted file mode 100644 (file)
index 07c94df..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (c) 2018 Facebook */
-#include <linux/bpf.h>
-#include <bpf/bpf_helpers.h>
-#include "bpf_legacy.h"
-
-struct ipv_counts {
-       unsigned int v4;
-       unsigned int v6;
-};
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-struct bpf_map_def SEC("maps") btf_map = {
-       .type = BPF_MAP_TYPE_ARRAY,
-       .key_size = sizeof(int),
-       .value_size = sizeof(struct ipv_counts),
-       .max_entries = 4,
-};
-#pragma GCC diagnostic pop
-
-BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
-
-__attribute__((noinline))
-int test_long_fname_2(void)
-{
-       struct ipv_counts *counts;
-       int key = 0;
-
-       counts = bpf_map_lookup_elem(&btf_map, &key);
-       if (!counts)
-               return 0;
-
-       counts->v6++;
-
-       return 0;
-}
-
-__attribute__((noinline))
-int test_long_fname_1(void)
-{
-       return test_long_fname_2();
-}
-
-SEC("dummy_tracepoint")
-int _dummy_tracepoint(void *arg)
-{
-       return test_long_fname_1();
-}
-
-char _license[] SEC("license") = "GPL";
index 762671a..251854a 100644 (file)
@@ -9,19 +9,6 @@ struct ipv_counts {
        unsigned int v6;
 };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-/* just to validate we can handle maps in multiple sections */
-struct bpf_map_def SEC("maps") btf_map_legacy = {
-       .type = BPF_MAP_TYPE_ARRAY,
-       .key_size = sizeof(int),
-       .value_size = sizeof(long long),
-       .max_entries = 4,
-};
-#pragma GCC diagnostic pop
-
-BPF_ANNOTATE_KV_PAIR(btf_map_legacy, int, struct ipv_counts);
-
 struct {
        __uint(type, BPF_MAP_TYPE_ARRAY);
        __uint(max_entries, 4);
@@ -41,11 +28,6 @@ int test_long_fname_2(void)
 
        counts->v6++;
 
-       /* just verify we can reference both maps */
-       counts = bpf_map_lookup_elem(&btf_map_legacy, &key);
-       if (!counts)
-               return 0;
-
        return 0;
 }