Re: [PATCH v9 2/9] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes
From: Yafang Shao <hidden>
Date: 2026-09-29 09:26:06
On Tue, Sep 29, 2026 at 4:43 PM Miroslav Benes [off-list ref] wrote:
quoted
quoted
quoted
# check_result() - verify dmesg output # TODO - better filter, out of order msgs, etc? function check_result {@@ -365,6 +374,27 @@ function does_sysfs_exist() { [[ -f "$SYSFS_KLP_DIR/$mod/$attr" ]] } +# detect_provides_attr() - detect whether the running kernel supports the +# livepatch "provides" attribute and set HAS_PROVIDES_ATTR accordingly. +# The provides/obsoletes based tests are only run when HAS_PROVIDES_ATTR +# is set. +function detect_provides_attr() { + HAS_PROVIDES_ATTR=0 + + if [[ -r /proc/config.gz ]] && + zgrep -q "CONFIG_KLP_HAS_PROVIDES=y" /proc/config.gz 2>/dev/null; then + HAS_PROVIDES_ATTR=1 + return 0 + fi + + load_lp test_klp_cmdline_lp + if does_sysfs_exist test_klp_cmdline_lp "provides"; then + HAS_PROVIDES_ATTR=1 + fi + disable_lp test_klp_cmdline_lp + unload_lp test_klp_cmdline_lp +}Why is there does_sysfs_exist() fallback? I mean, we use that currently for exactly this purpose. My understanding is that CONFIG_KLP_HAS_PROVIDES is also used elsewhere in the code so using it here makes some sense, but do we need both?CONFIG_IKCONFIG_PROC may not be enabled, so if /proc/config.gz doesn't exist, we must fall back to an alternative one.Ok. Let's keep it like that because it is definitely cheaper than loading and unloading a module. Could you add a comment just before does_sysfs_exist() fallback about CONFIG_IKCONFIG_PROC, please?
I will update it. -- Regards Yafang