Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Skip livepatch test when prerequisites are missing

livepatch_trampoline relies on livepatch sysfs and livepatch-sample.ko.
When CONFIG_LIVEPATCH is disabled or the samples module isn't built, the
test fails with ENOENT and causes false failures in minimal CI configs.

Skip the test when livepatch sysfs or the sample module is unavailable.
Also avoid writing to livepatch sysfs when it's not present.

Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20260309104448.817401-1-sun.jian.kdev@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Sun Jian and committed by
Alexei Starovoitov
c02e0ab8 aa181c7d

+18 -2
+18 -2
tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c
··· 5 5 #include "testing_helpers.h" 6 6 #include "livepatch_trampoline.skel.h" 7 7 8 + #define LIVEPATCH_ENABLED_PATH "/sys/kernel/livepatch/livepatch_sample/enabled" 9 + 8 10 static int load_livepatch(void) 9 11 { 10 12 char path[4096]; ··· 21 19 static void unload_livepatch(void) 22 20 { 23 21 /* Disable the livepatch before unloading the module */ 24 - system("echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled"); 22 + if (!access(LIVEPATCH_ENABLED_PATH, F_OK)) 23 + system("echo 0 > " LIVEPATCH_ENABLED_PATH); 25 24 26 25 unload_module("livepatch_sample", env_verbosity > VERBOSE_NONE); 27 26 } ··· 84 81 void test_livepatch_trampoline(void) 85 82 { 86 83 int retry_cnt = 0; 84 + int err; 85 + 86 + /* Skip if kernel was built without CONFIG_LIVEPATCH */ 87 + if (access("/sys/kernel/livepatch", F_OK)) { 88 + test__skip(); 89 + return; 90 + } 87 91 88 92 retry: 89 - if (load_livepatch()) { 93 + err = load_livepatch(); 94 + if (err) { 95 + if (err == -ENOENT) { 96 + test__skip(); 97 + return; 98 + } 99 + 90 100 if (retry_cnt) { 91 101 ASSERT_OK(1, "load_livepatch"); 92 102 goto out;