zram01: Improve error detection
PATCH v3 1/1 zram01: Improve error detection
* TBROK when detected size is 0 (+ print dd stderr, if any)
* TBROK if actually used memory is 0, this fixes division by 0:
Sometimes free reports no memory use by zram, which leads to division by 0:
zram01 8 TINFO: zram used 0M, zram disk sizes 104857600M /opt/ltp/testcases/bin/zram01.sh: line 87: 100 * 104857600 / 0: division by 0 (error token is "0")
---
Hi Alexey,
feel free to send your fix if this is not what you meant.
Kind regards,
Petr
Changes v2->v3:
* print last dd error (if any) only when $b -eq 0
Changes v2->v3:
* add TBROK when $b -eq 0
* print last dd error, if any
---
testcases/kernel/device-drivers/zram/zram01.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/kernel/device-drivers/zram/zram01.sh +7 -1
@@ -67,9 +67,13 @@ zram_fill_fs() while true; do dd conv=notrunc if=/dev/zero of=zram${i}/file \ oflag=append count=1 bs=1024 status=none \ - > /dev/null 2>&1 || break + 2>err.txt || break b=$(($b + 1)) done + if [ $b -eq 0 ]; then + [ -s err.txt ] && tst_resm TWARN "dd error: $(cat err.txt)" + tst_brkm TBROK "cannot fill zram" + fi tst_resm TINFO "zram$i can be filled with '$b' KB" done
@@ -82,6 +86,8 @@ zram_fill_fs() total_size=$(($total_size + $s)) done + [ $used_mem -eq 0 ] && tst_brkm TBROK "no memory used by zram" + tst_resm TINFO "zram used ${used_mem}M, zram disk sizes ${total_size}M" local v=$((100 * $total_size / $used_mem))
Signature · 1 line
2.22.0
PATCH v3 1/1 zram01: Improve error detection
Hi Petr,
Quoted 12 lines · Petr Vorel
* TBROK when detected size is 0 (+ print dd stderr, if any)
* TBROK if actually used memory is 0, this fixes division by 0:Sometimes free reports no memory use by zram, which leads to division by 0:
zram01 8 TINFO: zram used 0M, zram disk sizes 104857600M/opt/ltp/testcases/bin/zram01.sh: line 87: 100 * 104857600 / 0: division by 0 (error token is "0")Suggested-by Alexey Kodanev <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
Hi Alexey,
Quoted 7 lines
feel free to send your fix if this is not what you meant.
Kind regards,
PetrChanges
v2->v3:
* print last dd error (if any) only when $b -eq 0
Yes, that's what I meant :)
Quoted 38 lines
Changes
v2->v3:
* add TBROK when $b -eq 0
* print last dd error, if any
---testcases/kernel/device-drivers/zram/zram01.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)testcases/kernel/device-drivers/zram/zram01.sh +7
-1@@ -67,9 +67,13 @@ zram_fill_fs() while true; do dd conv=notrunc if=/dev/zero of=zram${i}/file \ oflag=append count=1 bs=1024 status=none \ - > /dev/null 2>&1 || break + 2>err.txt || break b=$(($b + 1)) done + if [ $b -eq 0 ]; then + [ -s err.txt ] && tst_resm TWARN "dd error: $(cat err.txt)" + tst_brkm TBROK "cannot fill zram" + fi tst_resm TINFO "zram$i can be filled with '$b' KB" done@@ -82,6 +86,8 @@ zram_fill_fs() total_size=$(($total_size + $s)) done + [ $used_mem -eq 0 ] && tst_brkm TBROK "no memory used by zram" + tst_resm TINFO "zram used ${used_mem}M, zram disk sizes ${total_size}M" local v=$((100 * $total_size / $used_mem))
PATCH v3 1/1 zram01: Improve error detection
Hi Alexey,
Quoted 4 lines
Quoted 2 lines
Changes
v2->v3:
* print last dd error (if any) only when $b -eq 0Yes, that's what I meant :)
Thanks :) Merged.
Kind regards,
Petr