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

xuyang2018.jy@fujitsu.com xuyang2018.jy@fujitsu.com
Wed Dec 15 07:24:21 CET 2021


Hi All

I will send a v4 patch today by using hot_add/hot_remove interface
instead of skipping case.

Best Regards
Yang Xu
> 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 | 13 ++++++++++++-
>   1 file changed, 12 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..26f19ec02 100755
> --- a/testcases/kernel/device-drivers/zram/zram_lib.sh
> +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
> @@ -5,6 +5,7 @@
> 
>   dev_makeswap=-1
>   dev_mounted=-1
> +dev_zram_load=-1
> 
>   TST_NEEDS_TMPDIR=1
>   TST_NEEDS_ROOT=1
> @@ -17,6 +18,10 @@ zram_cleanup()
>   {
>   	local i
> 
> +	if [ $dev_zram_load -le 0 ]; then
> +		return
> +	fi
> +
>   	for i in $(seq 0 $dev_makeswap); do
>   		swapoff /dev/zram$i
>   	done
> @@ -47,6 +52,10 @@ zram_load()
>   		tst_brk TBROK "dev_num must be>  0"
>   	fi
> 
> +	if grep -q '^zram' /proc/modules; then
> +		 rmmod zram>  /dev/null 2>&1 || tst_brk TCONF "zram module is being used"
> +	fi
> +
>   	tst_set_timeout $((dev_num*450))
> 
>   	tst_res TINFO "create '$dev_num' zram device(s)"
> @@ -54,10 +63,12 @@ zram_load()
>   	modprobe zram num_devices=$dev_num || \
>   		tst_brk TBROK "failed to insert zram module"
> 
> +	dev_zram_load=1
>   	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 TFAIL "expected num of devices $dev_num, but created"\
> +				"$dev_num_created"
>   	fi
> 
>   	tst_res TPASS "all zram devices successfully created"


More information about the ltp mailing list