diff mbox series

device-drivers/zram: zram_lib: Fix modinfo's usage

Message ID 20200917081917.31510-1-ycliang@andestech.com
State New
Headers show
Series device-drivers/zram: zram_lib: Fix modinfo's usage | expand

Commit Message

Leo Liang Sept. 17, 2020, 8:19 a.m. UTC
zram_lib uses the exit code of modinfo to determine the presence of zram module,
but the exit code does not have direct relation to it.

We could be missing zram module and modinfo still exits "successfully"
because it has done its job of informing the user zram is missing.

Such behavior would give confusing zram test report.
Without this patch, some of the system run LTP without zram module
would have a FAIL instead of CONF as a result.

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
 testcases/kernel/device-drivers/zram/zram_lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis Sept. 17, 2020, 1:51 p.m. UTC | #1
Hi!
> zram_lib uses the exit code of modinfo to determine the presence of zram module,
> but the exit code does not have direct relation to it.

What distribution is this? Where did the modinfo binary came from?

It works fine with modinfo from the kmod packages, see:

https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/tools/modinfo.c#n463
diff mbox series

Patch

diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
index 3f4d1d55f..372b93990 100755
--- a/testcases/kernel/device-drivers/zram/zram_lib.sh
+++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
@@ -211,5 +211,5 @@  zram_mount()
 	tst_res TPASS "mount of zram device(s) succeeded"
 }
 
-modinfo zram > /dev/null 2>&1 ||
+modinfo zram 2>&1 | grep filename > /dev/null 2>&1 ||
 	tst_brk TCONF "zram not configured in kernel"