[Devel] [PATCH vz10 v2] selftests/gpio: skip when gpio-mockup module is unavailable

Konstantin Khorenko khorenko at virtuozzo.com
Tue Aug 18 21:07:15 MSK 2026


From: Eva Kurchatova <eva.kurchatova at virtuozzo.com>

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 RHEL10 and ours), 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.

Note that 'modprobe -r -q' returns 0 for a module which exists but is
not loaded, so it is only the completely absent module which trips this
up. Detect that in prerequisite() and skip cleanly, the way
selftests/mm/test_hmm.sh, selftests/mm/test_vmalloc.sh and
selftests/fpu/run_test_fpu.sh already do.

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

https://virtuozzo.atlassian.net/browse/VSTOR-134202
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

---
v2 changes:
  * dropped hunk in cleanup: if we skip the test when the module is not
    available, that hunk is redundant
  * dropped "-n" argument in modprobe. Less questions. Other testcase do the
    same without "-n".

---
 tools/testing/selftests/gpio/gpio-mockup.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/gpio/gpio-mockup.sh b/tools/testing/selftests/gpio/gpio-mockup.sh
index fc2dd4c24d069..e6c236018c42a 100755
--- a/tools/testing/selftests/gpio/gpio-mockup.sh
+++ b/tools/testing/selftests/gpio/gpio-mockup.sh
@@ -51,6 +51,8 @@ prerequisite()
 	DEBUGFS=$(grep -w debugfs /proc/mounts | cut -f2 -d' ')
 	[ -d "$DEBUGFS" ] || skip "debugfs is not mounted"
 
+	modinfo $module >/dev/null 2>&1 || skip "$module module is not available"
+
 	GPIO_DEBUGFS=$DEBUGFS/$module
 }
 
-- 
2.43.0



More information about the Devel mailing list