summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSun Jian <sun.jian.kdev@gmail.com>2026-03-09 13:44:48 +0300
committerAlexei Starovoitov <ast@kernel.org>2026-03-11 19:36:37 +0300
commitc02e0ab8aeeca716948d06a88993c470e4fbe426 (patch)
tree4764274b74ffd2b330478821beae03f92d2babad
parentaa181c7d642cf10c31d53f73754795b6e5d88785 (diff)
downloadlinux-c02e0ab8aeeca716948d06a88993c470e4fbe426.tar.xz
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>
-rw-r--r--tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c b/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c
index 72aa5376c30e..0a12af924a99 100644
--- a/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c
+++ b/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c
@@ -5,6 +5,8 @@
#include "testing_helpers.h"
#include "livepatch_trampoline.skel.h"
+#define LIVEPATCH_ENABLED_PATH "/sys/kernel/livepatch/livepatch_sample/enabled"
+
static int load_livepatch(void)
{
char path[4096];
@@ -19,7 +21,8 @@ static int load_livepatch(void)
static void unload_livepatch(void)
{
/* Disable the livepatch before unloading the module */
- system("echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled");
+ if (!access(LIVEPATCH_ENABLED_PATH, F_OK))
+ system("echo 0 > " LIVEPATCH_ENABLED_PATH);
unload_module("livepatch_sample", env_verbosity > VERBOSE_NONE);
}
@@ -81,9 +84,22 @@ out:
void test_livepatch_trampoline(void)
{
int retry_cnt = 0;
+ int err;
+
+ /* Skip if kernel was built without CONFIG_LIVEPATCH */
+ if (access("/sys/kernel/livepatch", F_OK)) {
+ test__skip();
+ return;
+ }
retry:
- if (load_livepatch()) {
+ err = load_livepatch();
+ if (err) {
+ if (err == -ENOENT) {
+ test__skip();
+ return;
+ }
+
if (retry_cnt) {
ASSERT_OK(1, "load_livepatch");
goto out;