From: Song Liu <song@kernel.org>
To: <live-patching@vger.kernel.org>
Cc: <jpoimboe@kernel.org>, <jikos@kernel.org>, <mbenes@suse.cz>,
<pmladek@suse.com>, <joe.lawrence@redhat.com>,
<kernel-team@fb.com>, Song Liu <song@kernel.org>
Subject: [PATCH v2 2/2] selftests/livepatch: add sysfs test
Date: Mon, 1 Aug 2022 18:08:57 -0700 [thread overview]
Message-ID: <20220802010857.3574103-3-song@kernel.org> (raw)
In-Reply-To: <20220802010857.3574103-1-song@kernel.org>
Add a test for livepatch sysfs entries.
Signed-off-by: Song Liu <song@kernel.org>
---
tools/testing/selftests/livepatch/Makefile | 3 +-
.../testing/selftests/livepatch/test-sysfs.sh | 40 +++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/livepatch/test-sysfs.sh
diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
index 1acc9e1fa3fb..02fadc9d55e0 100644
--- a/tools/testing/selftests/livepatch/Makefile
+++ b/tools/testing/selftests/livepatch/Makefile
@@ -6,7 +6,8 @@ TEST_PROGS := \
test-callbacks.sh \
test-shadow-vars.sh \
test-state.sh \
- test-ftrace.sh
+ test-ftrace.sh \
+ test-sysfs.sh
TEST_FILES := settings
diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
new file mode 100755
index 000000000000..eb4a69ba1c2c
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test-sysfs.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Song Liu <song@kernel.org>
+
+. $(dirname $0)/functions.sh
+
+MOD_LIVEPATCH=test_klp_livepatch
+
+setup_config
+
+# - load a livepatch and verifies the sysfs entries work as expected
+
+start_test "sysfs test"
+
+load_lp $MOD_LIVEPATCH
+
+grep . "/sys/kernel/livepatch/$MOD_LIVEPATCH"/* > /dev/kmsg
+grep . "/sys/kernel/livepatch/$MOD_LIVEPATCH"/*/* > /dev/kmsg
+
+disable_lp $MOD_LIVEPATCH
+
+unload_lp $MOD_LIVEPATCH
+
+check_result "% modprobe $MOD_LIVEPATCH
+livepatch: enabling patch '$MOD_LIVEPATCH'
+livepatch: '$MOD_LIVEPATCH': initializing patching transition
+livepatch: '$MOD_LIVEPATCH': starting patching transition
+livepatch: '$MOD_LIVEPATCH': completing patching transition
+livepatch: '$MOD_LIVEPATCH': patching complete
+/sys/kernel/livepatch/test_klp_livepatch/enabled:1
+/sys/kernel/livepatch/test_klp_livepatch/transition:0
+/sys/kernel/livepatch/test_klp_livepatch/vmlinux/patched:1
+% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
+livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
+livepatch: '$MOD_LIVEPATCH': starting unpatching transition
+livepatch: '$MOD_LIVEPATCH': completing unpatching transition
+livepatch: '$MOD_LIVEPATCH': unpatching complete
+% rmmod $MOD_LIVEPATCH"
+
+exit 0
--
2.30.2
next prev parent reply other threads:[~2022-08-02 1:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 1:08 [PATCH v2 0/2] add sysfs entry "patched" for each klp_object Song Liu
2022-08-02 1:08 ` [PATCH v2 1/2] livepatch: " Song Liu
2022-09-02 11:49 ` Petr Mladek
2022-08-02 1:08 ` Song Liu [this message]
2022-08-02 21:36 ` [PATCH v2 2/2] selftests/livepatch: add sysfs test Joe Lawrence
2022-09-02 12:37 ` Petr Mladek
2022-09-02 15:42 ` Joe Lawrence
2022-08-02 21:37 ` [PATCH v2 0/2] add sysfs entry "patched" for each klp_object Joe Lawrence
2022-08-30 19:09 ` Song Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220802010857.3574103-3-song@kernel.org \
--to=song@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=kernel-team@fb.com \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.