summaryrefslogtreecommitdiff
path: root/tests/kernel-module-install/test.sh
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-08-30 03:10:39 +0300
committerDenys Fedoryshchenko <denys.f@collabora.com>2026-08-30 03:10:39 +0300
commitdbc9d0fb6863026b16f4805709acc7e4977d7e66 (patch)
treeac241e6e1ace4e126c50364bebf65688a314151b /tests/kernel-module-install/test.sh
parent89637ee2417fc7f42e4213d417da38aa814047e4 (diff)
downloadaccel-ppp-dbc9d0fb6863026b16f4805709acc7e4977d7e66.tar.gz
accel-ppp-dbc9d0fb6863026b16f4805709acc7e4977d7e66.zip
cmake: fix kernel module installation
Install each module from its real build directory, propagate staged install roots, and fail when kbuild modules_install fails. Add a rootless CTest and CI regression for successful and failed installs. Best practices followed: Use the standard CMake DESTDIR and kbuild INSTALL_MOD_PATH staging interfaces: https://cmake.org/cmake/help/latest/envvar/DESTDIR.html https://docs.kernel.org/kbuild/modules.html#install-mod-path Check child command status with execute_process RESULT_VARIABLE: https://cmake.org/cmake/help/latest/command/execute_process.html Register repeatable tests with CTest add_test: https://cmake.org/cmake/help/latest/command/add_test.html
Diffstat (limited to 'tests/kernel-module-install/test.sh')
-rw-r--r--tests/kernel-module-install/test.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/kernel-module-install/test.sh b/tests/kernel-module-install/test.sh
new file mode 100644
index 00000000..1fbfd623
--- /dev/null
+++ b/tests/kernel-module-install/test.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+set -eu
+
+cmake_command=${1:-cmake}
+script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
+source_dir=$(CDPATH= cd -- "${script_dir}/../.." && pwd)
+work_dir=$(mktemp -d)
+trap 'rm -rf "${work_dir}"' EXIT HUP INT TERM
+
+"${cmake_command}" \
+ -S "${source_dir}" \
+ -B "${work_dir}/build" \
+ -DBUILD_TESTING=OFF \
+ -DBUILD_DRIVER_ONLY=TRUE \
+ -DBUILD_IPOE_DRIVER=TRUE \
+ -DBUILD_VLAN_MON_DRIVER=TRUE \
+ -DBUILD_PPPOSEQ_DRIVER=TRUE \
+ -DIGNORE_GIT=TRUE \
+ -DKDIR="${script_dir}"
+
+"${cmake_command}" --build "${work_dir}/build" --parallel 2
+
+DESTDIR="${work_dir}/stage" \
+ "${cmake_command}" --install "${work_dir}/build"
+
+test -f "${work_dir}/stage/lib/modules/test-kernel/extra/ipoe.ko"
+test -f "${work_dir}/stage/lib/modules/test-kernel/extra/vlan_mon.ko"
+test -f "${work_dir}/stage/lib/modules/test-kernel/extra/ppposeq.ko"
+
+if FAIL_MODULES_INSTALL=1 DESTDIR="${work_dir}/failed-stage" \
+ "${cmake_command}" --install "${work_dir}/build" \
+ >"${work_dir}/failed-install.log" 2>&1; then
+ printf '%s\n' 'kernel module installation unexpectedly succeeded' >&2
+ exit 1
+fi
+
+grep -q 'Failed to install kernel module' "${work_dir}/failed-install.log"