selftests/bpf: Rename progs/tag.c to progs/btf_decl_tag.c
authorYonghong Song <yhs@fb.com>
Fri, 12 Nov 2021 01:26:41 +0000 (17:26 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Nov 2021 01:41:11 +0000 (17:41 -0800)
Rename progs/tag.c to progs/btf_decl_tag.c so we can introduce
progs/btf_type_tag.c in the next patch.

Also create a subtest for btf_decl_tag in prog_tests/btf_tag.c
so we can introduce btf_type_tag subtest in the next patch.

I also took opportunity to remove the check whether __has_attribute
is defined or not in progs/btf_decl_tag.c since all recent
clangs should already support this macro.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211112012641.1507144-1-yhs@fb.com
tools/testing/selftests/bpf/prog_tests/btf_tag.c
tools/testing/selftests/bpf/progs/btf_decl_tag.c [moved from tools/testing/selftests/bpf/progs/tag.c with 94% similarity]

index 91821f4..d15cc7a 100644 (file)
@@ -1,20 +1,26 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (c) 2021 Facebook */
 #include <test_progs.h>
-#include "tag.skel.h"
+#include "btf_decl_tag.skel.h"
 
-void test_btf_tag(void)
+static void test_btf_decl_tag(void)
 {
-       struct tag *skel;
+       struct btf_decl_tag *skel;
 
-       skel = tag__open_and_load();
-       if (!ASSERT_OK_PTR(skel, "btf_tag"))
+       skel = btf_decl_tag__open_and_load();
+       if (!ASSERT_OK_PTR(skel, "btf_decl_tag"))
                return;
 
        if (skel->rodata->skip_tests) {
-               printf("%s:SKIP: btf_tag attribute not supported", __func__);
+               printf("%s:SKIP: btf_decl_tag attribute not supported", __func__);
                test__skip();
        }
 
-       tag__destroy(skel);
+       btf_decl_tag__destroy(skel);
+}
+
+void test_btf_tag(void)
+{
+       if (test__start_subtest("btf_decl_tag"))
+               test_btf_decl_tag();
 }
similarity index 94%
rename from tools/testing/selftests/bpf/progs/tag.c
rename to tools/testing/selftests/bpf/progs/btf_decl_tag.c
index 1792f4e..c88ccc5 100644 (file)
@@ -4,10 +4,6 @@
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
 
-#ifndef __has_attribute
-#define __has_attribute(x) 0
-#endif
-
 #if __has_attribute(btf_decl_tag)
 #define __tag1 __attribute__((btf_decl_tag("tag1")))
 #define __tag2 __attribute__((btf_decl_tag("tag2")))