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

Cyril Hrubis chrubis@suse.cz
Fri Dec 10 13:25:24 CET 2021


Hi!
> +	lsmod | grep -q '^zram'
> +	if [ $? -eq 0 ]; then

Why not just:
	if grep -q '^zram' /proc/modules; then
		...

Here as well what the lsmod does it to open /proc/modules and for each
entry it also looks at /sys/module/$name/refcnt and
/sys/module/$name/hodlers. But we are not interested in the second part
at all...

> +		 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 +64,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"
> -- 
> 2.23.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list