summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@redhat.com>2019-07-18 16:29:48 -0400
committerShuah Khan <skhan@linuxfoundation.org>2019-07-30 17:47:10 -0400
commitfbb01c52471c8fb4ec2422c0ab26c134bd90bbff (patch)
treec4b41180f0f34007d38e42df4c8d185d0f9ff8d6 /tools
parentfc2e634e997d84f2610a482b500865ef2c04fcde (diff)
selftests/livepatch: push and pop dynamic debug config
The livepatching self-tests tweak the dynamic debug config to verify the kernel log during the tests. Enhance set_dynamic_debug() so that the config changes are restored when the script exits. Note this functionality needs to keep in sync with: - dynamic_debug input/output formatting - functions affected by set_dynamic_debug() For example, push_dynamic_debug() transforms: kernel/livepatch/transition.c:530 [livepatch]klp_init_transition =_ "'%s': initializing %s transition\012" to the following: file kernel/livepatch/transition.c line 530 =_ Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> Tested-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/livepatch/functions.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index edcfeace4655..79b0affd21fb 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -29,13 +29,27 @@ function die() {
29 exit 1 29 exit 1
30} 30}
31 31
32# set_dynamic_debug() - setup kernel dynamic debug 32function push_dynamic_debug() {
33# TODO - push and pop this config? 33 DYNAMIC_DEBUG=$(grep '^kernel/livepatch' /sys/kernel/debug/dynamic_debug/control | \
34 awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}')
35}
36
37function pop_dynamic_debug() {
38 if [[ -n "$DYNAMIC_DEBUG" ]]; then
39 echo -n "$DYNAMIC_DEBUG" > /sys/kernel/debug/dynamic_debug/control
40 fi
41}
42
43# set_dynamic_debug() - save the current dynamic debug config and tweak
44# it for the self-tests. Set a script exit trap
45# that restores the original config.
34function set_dynamic_debug() { 46function set_dynamic_debug() {
35 cat << EOF > /sys/kernel/debug/dynamic_debug/control 47 push_dynamic_debug
36file kernel/livepatch/* +p 48 trap pop_dynamic_debug EXIT INT TERM HUP
37func klp_try_switch_task -p 49 cat <<-EOF > /sys/kernel/debug/dynamic_debug/control
38EOF 50 file kernel/livepatch/* +p
51 func klp_try_switch_task -p
52 EOF
39} 53}
40 54
41# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES, 55# loop_until(cmd) - loop a command until it is successful or $MAX_RETRIES,