treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / livepatch / test-ftrace.sh
blobe2a76887f40a9363c392aebaa242ce884825c674
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 Joe Lawrence <joe.lawrence@redhat.com>
5 . $(dirname $0)/functions.sh
7 MOD_LIVEPATCH=test_klp_livepatch
9 setup_config
12 # TEST: livepatch interaction with ftrace_enabled sysctl
13 # - turn ftrace_enabled OFF and verify livepatches can't load
14 # - turn ftrace_enabled ON and verify livepatch can load
15 # - verify that ftrace_enabled can't be turned OFF while a livepatch is loaded
17 echo -n "TEST: livepatch interaction with ftrace_enabled sysctl ... "
18 dmesg -C
20 set_ftrace_enabled 0
21 load_failing_mod $MOD_LIVEPATCH
23 set_ftrace_enabled 1
24 load_lp $MOD_LIVEPATCH
25 if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
26 echo -e "FAIL\n\n"
27 die "livepatch kselftest(s) failed"
30 set_ftrace_enabled 0
31 if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
32 echo -e "FAIL\n\n"
33 die "livepatch kselftest(s) failed"
35 disable_lp $MOD_LIVEPATCH
36 unload_lp $MOD_LIVEPATCH
38 check_result "livepatch: kernel.ftrace_enabled = 0
39 % modprobe $MOD_LIVEPATCH
40 livepatch: enabling patch '$MOD_LIVEPATCH'
41 livepatch: '$MOD_LIVEPATCH': initializing patching transition
42 livepatch: failed to register ftrace handler for function 'cmdline_proc_show' (-16)
43 livepatch: failed to patch object 'vmlinux'
44 livepatch: failed to enable patch '$MOD_LIVEPATCH'
45 livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpatch
46 livepatch: '$MOD_LIVEPATCH': completing unpatching transition
47 livepatch: '$MOD_LIVEPATCH': unpatching complete
48 modprobe: ERROR: could not insert '$MOD_LIVEPATCH': Device or resource busy
49 livepatch: kernel.ftrace_enabled = 1
50 % modprobe $MOD_LIVEPATCH
51 livepatch: enabling patch '$MOD_LIVEPATCH'
52 livepatch: '$MOD_LIVEPATCH': initializing patching transition
53 livepatch: '$MOD_LIVEPATCH': starting patching transition
54 livepatch: '$MOD_LIVEPATCH': completing patching transition
55 livepatch: '$MOD_LIVEPATCH': patching complete
56 livepatch: sysctl: setting key \"kernel.ftrace_enabled\": Device or resource busy kernel.ftrace_enabled = 0
57 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
58 livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
59 livepatch: '$MOD_LIVEPATCH': starting unpatching transition
60 livepatch: '$MOD_LIVEPATCH': completing unpatching transition
61 livepatch: '$MOD_LIVEPATCH': unpatching complete
62 % rmmod $MOD_LIVEPATCH"
65 exit 0