diff mbox series

[2/3] zram/zram_lib.sh: fix variable name and algorithm retrieval

Message ID 20190703102303.32166-3-po-hsu.lin@canonical.com
State Changes Requested
Headers show
Series zram/zram_lib.sh: fix zram_compress_alg() test for zram01 | expand

Commit Message

Po-Hsu Lin July 3, 2019, 10:23 a.m. UTC
The compression algorithm was stored into a local variable algs,
however the variable name zram_algs was used in the for loop later.

Unify them with zram_algs, and use sed to get rid of the square
brackets that indicates the compression algorithm currently in use.
    $ cat /sys/block/zram0/comp_algorithm
    [lzo] lz4 lz4hc 842 zstd

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 testcases/kernel/device-drivers/zram/zram_lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis July 9, 2019, 11:44 a.m. UTC | #1
Hi!
>  	tst_resm TINFO "test that we can set compression algorithm"
>  
> -	local algs="$(cat /sys/block/zram0/comp_algorithm)"
> -	tst_resm TINFO "supported algs: $algs"
> +	local zram_algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)"

This has still the same name as the variable set in the zram01.sh.

There are two options what to do here, either we remove zram_algs from
the zram01.sh or set the algorithms to the ones defined in the zram01.sh
test at the end of this function.

> +	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"
> -- 
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Po-Hsu Lin July 10, 2019, 4:35 a.m. UTC | #2
On Tue, Jul 9, 2019 at 7:44 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> >       tst_resm TINFO "test that we can set compression algorithm"
> >
> > -     local algs="$(cat /sys/block/zram0/comp_algorithm)"
> > -     tst_resm TINFO "supported algs: $algs"
> > +     local zram_algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)"
>
> This has still the same name as the variable set in the zram01.sh.
>
> There are two options what to do here, either we remove zram_algs from
> the zram01.sh or set the algorithms to the ones defined in the zram01.sh
> test at the end of this function.
>

OK thanks,
I think maybe it's better to keep zram_algs in zram01.sh, make the
mapped zram property structure intact.
That's probably the original purpose for the local variable "algs".

I will re-send a version with variable name unified with the local
algs here, so we don't need to restore the zram_algs in the end of
this function.


> > +     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"
> > --
> > 2.17.1
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
diff mbox series

Patch

diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
index d0e7704a8..d50be699d 100755
--- a/testcases/kernel/device-drivers/zram/zram_lib.sh
+++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
@@ -98,8 +98,8 @@  zram_compress_alg()
 
 	tst_resm TINFO "test that we can set compression algorithm"
 
-	local algs="$(cat /sys/block/zram0/comp_algorithm)"
-	tst_resm TINFO "supported algs: $algs"
+	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"