Skip to content

Commit 8994e97

Browse files
athira-rajeevacmel
authored andcommitted
perf test bpf: Skip test if clang is not present
Perf BPF filter test fails in environment where "clang" is not installed. Test failure logs: <<>> 42: BPF filter : 42.1: Basic BPF filtering : Skip 42.2: BPF pinning : FAILED! 42.3: BPF prologue generation : FAILED! <<>> Enabling verbose option provided debug logs which says clang/llvm needs to be installed. Snippet of verbose logs: <<>> 42.2: BPF pinning : --- start --- test child forked, pid 61423 ERROR: unable to find clang. Hint: Try to install latest clang/llvm to support BPF. Check your $PATH <<logs_here>> Failed to compile test case: 'Basic BPF llvm compile' Unable to get BPF object, fix kbuild first test child finished with -1 ---- end ---- BPF filter subtest 2: FAILED! <<>> Here subtests, "BPF pinning" and "BPF prologue generation" failed and logs shows clang/llvm is needed. After installing clang, testcase passes. Reason on why subtest failure happens though logs has proper debug information: Main function __test__bpf calls test_llvm__fetch_bpf_obj by passing 4th argument as true ( 4th arguments maps to parameter "force" in test_llvm__fetch_bpf_obj ). But this will cause test_llvm__fetch_bpf_obj to skip the check for clang/llvm. Snippet of code part which checks for clang based on parameter "force" in test_llvm__fetch_bpf_obj: <<>> if (!force && (!llvm_param.user_set_param && <<>> Since force is set to "false", test won't get skipped and fails to compile test case. The BPF code compilation needs clang, So pass the fourth argument as "false" and also skip the test if reason for return is "TEST_SKIP" After the patch: <<>> 42: BPF filter : 42.1: Basic BPF filtering : Skip 42.2: BPF pinning : Skip 42.3: BPF prologue generation : Skip <<>> Fixes: ba1fae4 ("perf test: Add 'perf test BPF'") Reviewed-by: Kajol Jain <[email protected]> Signed-off-by: Athira Jajeev <[email protected]> Acked-by: Ian Rogers <[email protected]> Cc: Disha Goel <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: [email protected] Cc: Madhavan Srinivasan <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nageswara R Sastry <[email protected]> Cc: Wang Nan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent cfd7092 commit 8994e97

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/perf/tests/bpf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ static int __test__bpf(int idx)
222222

223223
ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
224224
bpf_testcase_table[idx].prog_id,
225-
true, NULL);
225+
false, NULL);
226226
if (ret != TEST_OK || !obj_buf || !obj_buf_sz) {
227227
pr_debug("Unable to get BPF object, %s\n",
228228
bpf_testcase_table[idx].msg_compile_fail);
229-
if (idx == 0)
229+
if ((idx == 0) || (ret == TEST_SKIP))
230230
return TEST_SKIP;
231231
else
232232
return TEST_FAIL;
@@ -364,9 +364,11 @@ static int test__bpf_prologue_test(struct test_suite *test __maybe_unused,
364364
static struct test_case bpf_tests[] = {
365365
#ifdef HAVE_LIBBPF_SUPPORT
366366
TEST_CASE("Basic BPF filtering", basic_bpf_test),
367-
TEST_CASE("BPF pinning", bpf_pinning),
367+
TEST_CASE_REASON("BPF pinning", bpf_pinning,
368+
"clang isn't installed or environment missing BPF support"),
368369
#ifdef HAVE_BPF_PROLOGUE
369-
TEST_CASE("BPF prologue generation", bpf_prologue_test),
370+
TEST_CASE_REASON("BPF prologue generation", bpf_prologue_test,
371+
"clang isn't installed or environment missing BPF support"),
370372
#else
371373
TEST_CASE_REASON("BPF prologue generation", bpf_prologue_test, "not compiled in"),
372374
#endif

0 commit comments

Comments
 (0)