diff mbox series

lsmod01.sh: Fix failure when CONFIG_MODULE_UNLOAD is not set

Message ID 20201221115111.31982-1-radoslav.kolev@suse.com
State Accepted
Headers show
Series lsmod01.sh: Fix failure when CONFIG_MODULE_UNLOAD is not set | expand

Commit Message

Radoslav Kolev Dec. 21, 2020, 11:51 a.m. UTC
If CONFIG_MODULE_UNLOAD is not set lsmod shows '-2' (-ENOENT) for
the used by column, but /proc/modules has only '-' there.

Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
---
 testcases/commands/lsmod/lsmod01.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Petr Vorel Jan. 5, 2021, 11:47 a.m. UTC | #1
Hi Radoslav,

> If CONFIG_MODULE_UNLOAD is not set lsmod shows '-2' (-ENOENT) for
> the used by column, but /proc/modules has only '-' there.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Merged, thanks!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/commands/lsmod/lsmod01.sh b/testcases/commands/lsmod/lsmod01.sh
index c373b2893..2e044c718 100755
--- a/testcases/commands/lsmod/lsmod01.sh
+++ b/testcases/commands/lsmod/lsmod01.sh
@@ -44,7 +44,9 @@  cleanup()
 
 lsmod_matches_proc_modules()
 {
-	lsmod_output=$(lsmod | awk '!/Module/{print $1, $2, $3}' | sort)
+	lsmod_output=$(lsmod \
+			| awk '!/Module/{print $1, $2, ($3==-2) ? "-" : $3}' \
+			| sort)
 	if [ -z "$lsmod_output" ]; then
 		tst_brk TBROK "Failed to parse the output from lsmod"
 	fi