[Devel] [PATCH hci-8.1 v2 6/6] configs: check the User Mode Linux KUnit config at build time
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Oct 27 01:34:24 MSK 2026
process_configs.sh resolves the um variant with dummy tools, which
claim every compiler feature. The build resolves it again with the real
compiler, where an option the um layer sets can still drop out: a
toolchain without KASAN support takes CONFIG_KASAN away, and the KASAN
checks of every test go with it, on a green run.
A KUnit test whose prompt stays visible under KUNIT_ALL_TESTS keeps the
=m of the generic layers, and UML loads no modules. process_configs.sh
takes =m as a valid value, so a test that a RHEL import adds this way
silently never runs.
check_um_config.sh fails the build when the resolved config:
- lost a value the um layer sets, or has an option on that it turns off
- has a KUnit test, a symbol defaulting to KUNIT_ALL_TESTS, as a module
It fails as well when it finds no um layer or no KUnit test to check
against, rather than pass having checked nothing. kernel.spec runs it
after olddefconfig, before building the kernel.
https://virtuozzo.atlassian.net/browse/VSTOR-143636
https://virtuozzo.atlassian.net/browse/VSTOR-148112
Feature: KUnit tests on User Mode Linux
Suggested-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
redhat/configs/check_um_config.sh | 66 +++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/redhat/configs/check_um_config.sh b/redhat/configs/check_um_config.sh
new file mode 100755
index 0000000000000..190bd3e256f5f
--- /dev/null
+++ b/redhat/configs/check_um_config.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# Check the config of the User Mode Linux KUnit kernel, the "um" variant,
+# once the build has resolved it with olddefconfig:
+#
+# check_um_config.sh CONFIG
+#
+# process_configs.sh resolves the variant with dummy tools, the build with
+# the real compiler, which can still drop an option the um layer sets. And
+# UML loads no modules, so a KUnit test left a module never runs.
+
+config=$1
+if [ ! -f "$config" ]; then
+ echo "usage: $0 CONFIG" >&2
+ exit 2
+fi
+
+dir=$(dirname "$(readlink -f "$0")")
+layer=$dir/custom-overrides/generic/um
+
+die()
+{
+ echo "$0: $1" >&2
+ exit 2
+}
+
+ls "$layer"/CONFIG_* > /dev/null 2>&1 || die "no um layer in $layer"
+
+kunit_tests=$(find "$dir/../.." -name 'Kconfig*' -print0 |
+ xargs -0 awk '
+ /^(menu)?config / { name = $2 }
+ /^[ \t]+default KUNIT_ALL_TESTS/ { print "CONFIG_" name }' |
+ sort -u)
+[ -n "$kunit_tests" ] || die "no KUnit test in the Kconfig files under $dir/../.."
+
+layer_lost()
+{
+ local line sym
+
+ cat "$layer"/CONFIG_* | while read -r line; do
+ case "$line" in
+ CONFIG_*=*)
+ grep -qxF -- "$line" "$config" ||
+ echo "$line: lost"
+ ;;
+ "# CONFIG_"*" is not set")
+ sym=${line#\# }
+ sym=${sym%% *}
+ grep "^$sym=" "$config" | sed "s/\$/: set, the um layer has it off/"
+ ;;
+ esac
+ done
+}
+
+kunit_modules()
+{
+ echo "$kunit_tests" | sed 's/$/=m/' | grep -xFf - "$config" |
+ sed 's/$/: a KUnit test left a module/'
+}
+
+bad=$(layer_lost; kunit_modules)
+if [ -n "$bad" ]; then
+ echo "$config is not the um config the KUnit kernel needs:"
+ echo "$bad"
+ exit 1
+fi
--
2.43.0
More information about the Devel
mailing list