Skip to content

Commit

Permalink
zram_lib.sh: fix variable name and algorithm retrieval
Browse files Browse the repository at this point in the history
The compression algorithm was stored into a local variable $algs,
however the variable name $zram_algs was used in the for loop later.

Use local variable $algs and remove now unused $zram_algs.
This allows us to use all actually available algorithms instead of 4
times lzo.

This requires 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

Reviewed-by: Cyril Hrubis <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Po-Hsu Lin <[email protected]>
[ pvorel: removed $zram_algs ]
Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
Cypresslin authored and pevik committed Mar 17, 2020
1 parent a3d4ae1 commit 483b9f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion testcases/kernel/device-drivers/zram/zram01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fi
zram_sizes="26214400 26214400 26214400 $FS_SIZE"
zram_mem_limits="25M 25M 25M $((FS_SIZE/1024/1024))M"
zram_filesystems="ext3 ext4 xfs $FS_TYPE"
zram_algs="lzo lzo lzo lzo"

zram_fill_fs()
{
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/device-drivers/zram/zram_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ zram_compress_alg()
local i=0

tst_res TINFO "test that we can set compression algorithm"
local algs="$(cat /sys/block/zram0/comp_algorithm)"
local algs="$(sed 's/[][]//g' /sys/block/zram0/comp_algorithm)"
tst_res TINFO "supported algs: $algs"

for alg in $zram_algs; do
for alg in $algs; do
local sys_path="/sys/block/zram${i}/comp_algorithm"
echo "$alg" > $sys_path || \
tst_brk TFAIL "can't set '$alg' to $sys_path"
Expand Down

0 comments on commit 483b9f3

Please sign in to comment.