File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
tools/testing/selftests/livepatch Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,18 @@ function is_root() {
34
34
fi
35
35
}
36
36
37
+ # Check if we can compile the modules before loading them
38
+ function has_kdir() {
39
+ if [ -z " $KDIR " ]; then
40
+ KDIR=" /lib/modules/$( uname -r) /build"
41
+ fi
42
+
43
+ if [ ! -d " $KDIR " ]; then
44
+ echo " skip all tests: KDIR ($KDIR ) not available to compile modules."
45
+ exit $ksft_skip
46
+ fi
47
+ }
48
+
37
49
# die(msg) - game over, man
38
50
# msg - dying words
39
51
function die() {
@@ -108,6 +120,7 @@ function cleanup() {
108
120
# the ftrace_enabled sysctl.
109
121
function setup_config() {
110
122
is_root
123
+ has_kdir
111
124
push_config
112
125
set_dynamic_debug
113
126
set_ftrace_enabled 1
Original file line number Diff line number Diff line change @@ -13,8 +13,14 @@ obj-m += test_klp_atomic_replace.o \
13
13
test_klp_shadow_vars.o \
14
14
test_klp_syscall.o
15
15
16
+ # Ensure that KDIR exists, otherwise skip the compilation
16
17
modules :
18
+ ifneq ("$(wildcard $(KDIR ) ) ", "")
17
19
$(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
20
+ endif
18
21
22
+ # Ensure that KDIR exists, otherwise skip the clean target
19
23
clean :
24
+ ifneq ("$(wildcard $(KDIR ) ) ", "")
20
25
$(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR)
26
+ endif
You can’t perform that action at this time.
0 commit comments