[LTP] [PATCH 2/3] zram/zram_lib.sh: Skip test if zram module can not be removed

Yang Xu xuyang2018.jy@fujitsu.com
Thu Dec 9 08:43:42 CET 2021


If zram-generator package is installed and works, then we can not
remove zram module because zram swap is being used. We can also use zramstart
command or similar shell script(use zramctl,mkswap,swapon) to do this.

Since zram01.sh and zram02.sh needs to rmmod and modprobe, they can't work well
if zram module can't be removed. So skip it.

Fixes: #888
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/device-drivers/zram/zram_lib.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
index fe9c915c3..ad5b6e216 100755
--- a/testcases/kernel/device-drivers/zram/zram_lib.sh
+++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
@@ -49,6 +49,8 @@ zram_load()
 
 	tst_set_timeout $((dev_num*450))
 
+	rmmod zram > /dev/null 2>&1 || tst_brk TCONF "zram module is being used"
+
 	tst_res TINFO "create '$dev_num' zram device(s)"
 
 	modprobe zram num_devices=$dev_num || \
@@ -57,7 +59,8 @@ zram_load()
 	dev_num_created=$(ls /dev/zram* | wc -w)
 
 	if [ "$dev_num_created" -ne "$dev_num" ]; then
-		tst_brk TFAIL "unexpected num of devices: $dev_num_created"
+		tst_brk FAIL "num of devices expected $dev_num, but created"\
+				"$dev_num_created"
 	fi
 
 	tst_res TPASS "all zram devices successfully created"
-- 
2.23.0



More information about the ltp mailing list