[PATCH 09/11] selftests/livepatch: Test klp-build's rejection of unsupported files

From: Song Liu

Date: Fri Oct 16 2026 - 20:27:29 EST


Add a test that klp-build rejects patches to lib/, the vDSO, real mode
code and assembly files, which it can't build a livepatch for.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu <song@xxxxxxxxxx>
---
.../livepatch/test_klp_build/Makefile | 3 +-
.../test_klp_build/test-unsupported-files.sh | 30 +++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/livepatch/test_klp_build/test-unsupported-files.sh

diff --git a/tools/testing/selftests/livepatch/test_klp_build/Makefile b/tools/testing/selftests/livepatch/test_klp_build/Makefile
index 83f4e23460ac..af8f350226c2 100644
--- a/tools/testing/selftests/livepatch/test_klp_build/Makefile
+++ b/tools/testing/selftests/livepatch/test_klp_build/Makefile
@@ -6,7 +6,8 @@ TEST_PROGS := \
test-independent-patches.sh \
test-cancelling-patches.sh \
test-new-and-deleted-files.sh \
- test-line-directives.sh
+ test-line-directives.sh \
+ test-unsupported-files.sh

TEST_PROGS_EXTENDED := functions.sh

diff --git a/tools/testing/selftests/livepatch/test_klp_build/test-unsupported-files.sh b/tools/testing/selftests/livepatch/test_klp_build/test-unsupported-files.sh
new file mode 100755
index 000000000000..968ae80f7128
--- /dev/null
+++ b/tools/testing/selftests/livepatch/test_klp_build/test-unsupported-files.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. "$(dirname "$0")/functions.sh"
+
+setup_tree
+
+# - patches to lib/, the vDSO, real mode code and assembly are rejected
+
+for file in lib/string.c \
+ arch/x86/entry/vdso/vma.c \
+ arch/x86/realmode/rm/video-mode.c \
+ arch/x86/kernel/head_64.S; do
+
+ start_test "patch to $file"
+
+ add_patch unsupported.patch <<EOT
+--- a/$file
++++ b/$file
+@@ -1 +1 @@
+-int x;
++int y;
+EOT
+
+ run_klp_build unsupported.patch
+
+ expect_error "$PATCH_DIR/unsupported.patch: unsupported patch to $file"
+done
+
+exit 0
--
2.53.0-Meta