aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/btf_tag.c
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2021-09-14 23:10:36 -0700
committerAlexei Starovoitov <ast@kernel.org>2021-09-15 08:49:49 -0700
commit2220ecf55c1b7aa36e99b00a6b964f4e5333f9bf (patch)
tree58ee06def650c8449d4bd27feb69f8a409a7faa8 /tools/testing/selftests/bpf/prog_tests/btf_tag.c
parentMerge branch 'bpf: add support for new btf kind BTF_KIND_TAG' (diff)
downloadlinux-dev-2220ecf55c1b7aa36e99b00a6b964f4e5333f9bf.tar.xz
linux-dev-2220ecf55c1b7aa36e99b00a6b964f4e5333f9bf.zip
selftests/bpf: Skip btf_tag test if btf_tag attribute not supported
Commit c240ba287890 ("selftests/bpf: Add a test with a bpf program with btf_tag attributes") added btf_tag selftest to test BTF_KIND_TAG generation from C source code, and to test kernel validation of generated BTF types. But if an old clang (clang 13 or earlier) is used, the following compiler warning may be seen: progs/tag.c:23:20: warning: unknown attribute 'btf_tag' ignored and the test itself is marked OK. The compiler warning is bad and the test itself shouldn't be marked OK. This patch added the check for btf_tag attribute support. If btf_tag is not supported by the clang, the attribute will not be used in the code and the test will be marked as skipped. For example, with clang 13: ./test_progs -t btf_tag #21 btf_tag:SKIP Summary: 1/0 PASSED, 1 SKIPPED, 0 FAILED The selftests/README.rst is updated to clarify when the btf_tag test may be skipped. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210915061036.2577971-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/btf_tag.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/btf_tag.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/btf_tag.c b/tools/testing/selftests/bpf/prog_tests/btf_tag.c
index f939527ede77..91821f42714d 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_tag.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_tag.c
@@ -10,5 +10,11 @@ void test_btf_tag(void)
skel = tag__open_and_load();
if (!ASSERT_OK_PTR(skel, "btf_tag"))
return;
+
+ if (skel->rodata->skip_tests) {
+ printf("%s:SKIP: btf_tag attribute not supported", __func__);
+ test__skip();
+ }
+
tag__destroy(skel);
}