Re: [PATCH 04/11] selftests/livepatch: Test klp-build with dependent patches

From
sashiko-bot@kernel.org
Date
2026-10-17 00:30:14
Reply to
Song Liu, 2026-10-17
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] selftests/livepatch: test-dependent-patches.sh duplicates test-basic.sh setup
--

commit fc2a73d39b4eb0e68d2bd9630878b28c5feeaab1
Author: Song Liu [off-list ref]

selftests/livepatch: Test klp-build with dependent patches

This commit adds a new selftest script, test-dependent-patches.sh, to test
klp-build when a second patch modifies lines added by an earlier patch.
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/livepatch/test_klp_build/test-dependent-patches.sh b/tools/testing/selftests/livepatch/test_klp_build/test-dependent-patches.sh
new file mode 100755
index 0000000000000..75b957ac002c0
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test_klp_build/test-dependent-patches.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. "$(dirname "$0")/functions.sh"
+
+setup_tree
+
+add_file drivers/foo/foo.c <<'EOT'
+int foo(int x)
+{
+	if (x < 0)
+		return -1;
+	return x;
+}
+
+int bar(void)
+{
+	return __LINE__;
+}
+EOT
+
+# - a patch which changes lines added by an earlier patch doesn't apply to the
+#   original source on its own, but the combined patch does
+
+start_test "patch which depends on an earlier one"
+
+add_patch 0001-foo.patch <<'EOT'
+--- a/drivers/foo/foo.c
++++ b/drivers/foo/foo.c
+@@ -1,6 +1,8 @@
+ int foo(int x)
+ {
++	if (!x)
++		return 0;
+ 	if (x < 0)
+ 		return -1;
+ 	return x;
+ }
+EOT
[Severity: Low]
In tools/testing/selftests/livepatch/test_klp_build/test-basic.sh, the
script already calls setup_tree, creates the identical drivers/foo/foo.c
via add_file, and defines the identical 0001-foo.patch via add_patch.

Since run_klp_build() in functions.sh leaves $TREE unmodified between
invocations and supports running multiple start_test cases sequentially in
a single script, should this dependent-patch test case be added to
test-basic.sh instead of duplicating the setup in a new standalone
test-dependent-patches.sh file?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261017002441.716615-1-song@kernel.org?part=4
Thread (16 messages) 16 messages, 3 authors, last reply 19d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help