[Devel] [PATCH vz10] selftests/gpio: skip when gpio-mockup module is unavailable
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri Jun 26 16:09:23 MSK 2026
On 6/25/26 19:51, Eva Kurchatova wrote:
> The gpio-mockup test begins with:
>
> remove_module || fail "can't remove existing $module module"
>
> where remove_module is simply 'modprobe -r -q gpio-mockup'. On a kernel
> built without CONFIG_GPIO_MOCKUP (which is the case for many distro
> kernels, including RHEL), the module file does not exist, modprobe -r
> returns non-zero, and the test is reported as FAIL even though there
> is nothing for it to test. Detect this case early and skip cleanly.
>
> After this:
>
> # GPIO gpio-mockup test SKIP
> ok 1 selftests: gpio: gpio-mockup.sh # SKIP
>
> instead of:
>
> not ok 1 selftests: gpio: gpio-mockup.sh # exit=1
>
> Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
>
> https://virtuozzo.atlassian.net/browse/VSTOR-134202
> Feature: fix selftests
>
> ---
> tools/testing/selftests/gpio/gpio-mockup.sh | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/gpio/gpio-mockup.sh b/tools/testing/selftests/gpio/gpio-mockup.sh
> index fc2dd4c24d06..1d815692d4f1 100755
> --- a/tools/testing/selftests/gpio/gpio-mockup.sh
> +++ b/tools/testing/selftests/gpio/gpio-mockup.sh
> @@ -51,12 +51,15 @@ prerequisite()
> DEBUGFS=$(grep -w debugfs /proc/mounts | cut -f2 -d' ')
> [ -d "$DEBUGFS" ] || skip "debugfs is not mounted"
>
> + modinfo -n $module >/dev/null 2>&1 || skip "$module module is not available"
"-n" is excess. No other test uses this, only plain modinfo.
> +
> GPIO_DEBUGFS=$DEBUGFS/$module
> }
>
> remove_module()
> {
> - modprobe -r -q $module
> + # Ignore errors when the module is not present
> + modprobe -r -q $module || true
> }
>
> cleanup()
--
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.
More information about the Devel
mailing list