[Devel] [PATCH hci-8.1 4/6] selftests/zram: fail when a step fails
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Mon Oct 26 15:40:13 MSK 2026
The library prints FAIL for a step that fails and carries on, zram01
and zram02 print their verdict and exit 0 either way, and zram.sh
exits with the status of zram02 alone, so no zram failure reached the
runner. A failed step now fails its test, a failed test fails the
suite.
https://virtuozzo.atlassian.net/browse/VSTOR-134205
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
tools/testing/selftests/zram/zram.sh | 11 +++++++++--
tools/testing/selftests/zram/zram01.sh | 4 ++++
tools/testing/selftests/zram/zram02.sh | 1 +
tools/testing/selftests/zram/zram_lib.sh | 24 +++++++++++++++---------
4 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh
index b0b91d9b0dc2..56adeb17768f 100755
--- a/tools/testing/selftests/zram/zram.sh
+++ b/tools/testing/selftests/zram/zram.sh
@@ -4,15 +4,22 @@ TCID="zram.sh"
. ./zram_lib.sh
+# A failure outranks a skip, a skip outranks a pass
+result () {
+ [ $1 -eq $ksft_skip ] && [ $ret -ne 0 ] || ret=$1
+}
+
run_zram () {
echo "--------------------"
echo "running zram tests"
echo "--------------------"
-./zram01.sh
+./zram01.sh || result $?
echo ""
-./zram02.sh
+./zram02.sh || result $?
}
check_prereqs
+ret=0
run_zram
+exit $ret
diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh
index 8f4affe34f3e..8ab63c98c1af 100755
--- a/tools/testing/selftests/zram/zram01.sh
+++ b/tools/testing/selftests/zram/zram01.sh
@@ -33,6 +33,9 @@ zram_algs="lzo"
zram_fill_fs()
{
+ # An earlier step failed, and after a failed mount the directory
+ # would be filled on the host's filesystem
+ [ $ERR_CODE -ne 0 ] && return
for i in $(seq $dev_start $dev_end); do
echo "fill zram$i..."
local b=0
@@ -70,6 +73,7 @@ zram_cleanup
if [ $ERR_CODE -ne 0 ]; then
echo "$TCID : [FAIL]"
+ exit 1
else
echo "$TCID : [PASS]"
fi
diff --git a/tools/testing/selftests/zram/zram02.sh b/tools/testing/selftests/zram/zram02.sh
index 2418b0c4ed13..54e17bbfdbb7 100755
--- a/tools/testing/selftests/zram/zram02.sh
+++ b/tools/testing/selftests/zram/zram02.sh
@@ -39,6 +39,7 @@ zram_cleanup
if [ $ERR_CODE -ne 0 ]; then
echo "$TCID : [FAIL]"
+ exit 1
else
echo "$TCID : [PASS]"
fi
diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
index 21ec1966de76..25e32cb956df 100755
--- a/tools/testing/selftests/zram/zram_lib.sh
+++ b/tools/testing/selftests/zram/zram_lib.sh
@@ -131,12 +131,14 @@ zram_max_streams()
for max_s in $zram_max_streams; do
local sys_path="/sys/block/zram${i}/max_comp_streams"
echo $max_s > $sys_path || \
- echo "FAIL failed to set '$max_s' to $sys_path"
+ { echo "FAIL failed to set '$max_s' to $sys_path"; ERR_CODE=-1; }
sleep 1
local max_streams=$(cat $sys_path)
- [ "$max_s" -ne "$max_streams" ] && \
- echo "FAIL can't set max_streams '$max_s', get $max_stream"
+ if [ "$max_s" -ne "$max_streams" ]; then
+ echo "FAIL can't set max_streams '$max_s', get $max_streams"
+ ERR_CODE=-1
+ fi
i=$(($i + 1))
echo "$sys_path = '$max_streams'"
@@ -156,7 +158,7 @@ zram_compress_alg()
for alg in $zram_algs; do
local sys_path="/sys/block/zram${i}/comp_algorithm"
echo "$alg" > $sys_path || \
- echo "FAIL can't set '$alg' to $sys_path"
+ { echo "FAIL can't set '$alg' to $sys_path"; ERR_CODE=-1; }
i=$(($i + 1))
echo "$sys_path = '$alg'"
done
@@ -171,7 +173,7 @@ zram_set_disksizes()
for ds in $zram_sizes; do
local sys_path="/sys/block/zram${i}/disksize"
echo "$ds" > $sys_path || \
- echo "FAIL can't set '$ds' to $sys_path"
+ { echo "FAIL can't set '$ds' to $sys_path"; ERR_CODE=-1; }
i=$(($i + 1))
echo "$sys_path = '$ds'"
@@ -188,7 +190,7 @@ zram_set_memlimit()
for ds in $zram_mem_limits; do
local sys_path="/sys/block/zram${i}/mem_limit"
echo "$ds" > $sys_path || \
- echo "FAIL can't set '$ds' to $sys_path"
+ { echo "FAIL can't set '$ds' to $sys_path"; ERR_CODE=-1; }
i=$(($i + 1))
echo "$sys_path = '$ds'"
@@ -205,13 +207,15 @@ zram_makeswap()
mkswap /dev/zram$i > err.log 2>&1
if [ $? -ne 0 ]; then
cat err.log
- echo "FAIL mkswap /dev/zram$1 failed"
+ echo "FAIL mkswap /dev/zram$i failed"
+ ERR_CODE=-1
fi
swapon /dev/zram$i > err.log 2>&1
if [ $? -ne 0 ]; then
cat err.log
- echo "FAIL swapon /dev/zram$1 failed"
+ echo "FAIL swapon /dev/zram$i failed"
+ ERR_CODE=-1
fi
echo "done with /dev/zram$i"
@@ -229,6 +233,7 @@ zram_swapoff()
if [ $? -ne 0 ]; then
cat err.log
echo "FAIL swapoff /dev/zram$i failed"
+ ERR_CODE=-1
fi
done
dev_makeswap=-1
@@ -248,6 +253,7 @@ zram_makefs()
if [ $? -ne 0 ]; then
cat err.log
echo "FAIL failed to make $fs on /dev/zram$i"
+ ERR_CODE=-1
fi
i=$(($i + 1))
echo "zram mkfs.$fs: OK"
@@ -261,7 +267,7 @@ zram_mount()
echo "mount /dev/zram$i"
mkdir zram$i
mount /dev/zram$i zram$i > /dev/null || \
- echo "FAIL mount /dev/zram$i failed"
+ { echo "FAIL mount /dev/zram$i failed"; ERR_CODE=-1; }
dev_mounted=$i
done
--
2.56.0
More information about the Devel
mailing list