[LTP] [PATCH 3/3] zram/zram_lib.sh: iterate through all available compression algorithms for all zram block devices

Cyril Hrubis chrubis@suse.cz
Tue Jul 9 13:42:04 CEST 2019


Hi!
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>  .../kernel/device-drivers/zram/zram_lib.sh     | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
> index d50be699d..96400b2d9 100755
> --- a/testcases/kernel/device-drivers/zram/zram_lib.sh
> +++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
> @@ -101,12 +101,18 @@ zram_compress_alg()
>  	local zram_algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)"
>  	tst_resm TINFO "supported algs: $zram_algs"
>  	local i=0
> -	for alg in $zram_algs; do
> -		local sys_path="/sys/block/zram${i}/comp_algorithm"
> -		echo "$alg" >  $sys_path || \
> -			tst_brkm TFAIL "can't set '$alg' to $sys_path"
> -		i=$(($i + 1))
> -		tst_resm TINFO "$sys_path = '$alg' ($i/$dev_num)"
> +	local dev_max=0
> +	while [ -d /sys/block/zram$(($dev_max + 1)) ]; do
> +		dev_max=$(($dev_max + 1))
> +	done

The zram01.sh test defines dev_num that is passed to the modprobe zram
as num_devices, there is no point in counting the block devices like
this.

> +	for i in $(seq 0 $dev_max); do
> +		for alg in $zram_algs; do
> +			local sys_path="/sys/block/zram${i}/comp_algorithm"
> +			echo "$alg" >  $sys_path || \
> +				tst_brkm TFAIL "can't set '$alg' to $sys_path"
> +			tst_resm TINFO "$sys_path = '$alg' ($i/$dev_max)"
> +		done
>  	done

This is OK, but we should make sure we end up with expected compression
method for subsequent tests.

Maybe we should just set the alg to the zram_algs="" as defined in the
zram01.sh after this loop.

>  	tst_resm TPASS "test succeeded"
> -- 
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list