From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 4/7] selftests/zram: fail when a step fails
Date: Tue, 27 Oct 2026 19:34:20 +0200 [thread overview]
Message-ID: <20261027173457.1261044-5-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261027173457.1261044-1-eva.kurchatova@virtuozzo.com>
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 step that reports FAIL now fails its test, and the suite
takes the worst result of its two tests, a failure over a skip over a
pass. A compression algorithm the kernel is built without, or a tool
the tests need that is not installed, skips them instead of failing.
https://virtuozzo.atlassian.net/browse/VSTOR-134205
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
tools/testing/selftests/zram/zram.sh | 11 ++++--
tools/testing/selftests/zram/zram01.sh | 8 +++++
tools/testing/selftests/zram/zram02.sh | 1 +
tools/testing/selftests/zram/zram_lib.sh | 45 +++++++++++++++++++-----
4 files changed, 54 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..8f337e6adf8b 100755
--- a/tools/testing/selftests/zram/zram01.sh
+++ b/tools/testing/selftests/zram/zram01.sh
@@ -10,6 +10,7 @@
TCID="zram01"
ERR_CODE=0
+SKIP_CODE=0
. ./zram_lib.sh
@@ -33,6 +34,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 +74,10 @@ zram_cleanup
if [ $ERR_CODE -ne 0 ]; then
echo "$TCID : [FAIL]"
+ exit 1
+elif [ $SKIP_CODE -ne 0 ]; then
+ echo "$TCID : [SKIP]"
+ exit $SKIP_CODE
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..6d71022296e5 100755
--- a/tools/testing/selftests/zram/zram_lib.sh
+++ b/tools/testing/selftests/zram/zram_lib.sh
@@ -28,6 +28,13 @@ check_prereqs()
echo $msg must be run as root >&2
exit $ksft_skip
fi
+
+ for cmd in mkfs.ext2 mkswap swapon swapoff; do
+ if ! command -v $cmd > /dev/null 2>&1; then
+ echo $msg $cmd is not installed >&2
+ exit $ksft_skip
+ fi
+ done
}
kernel_gte()
@@ -131,12 +138,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'"
@@ -152,11 +161,25 @@ zram_compress_alg()
local i=$dev_start
local algs=$(cat /sys/block/zram${i}/comp_algorithm)
echo "supported algs: $algs"
+ if [ -z "$algs" ]; then
+ echo "FAIL can't read /sys/block/zram${i}/comp_algorithm"
+ ERR_CODE=-1
+ fi
for alg in $zram_algs; do
local sys_path="/sys/block/zram${i}/comp_algorithm"
+ # A kernel built without the algorithm is not a zram failure
+ case " $(echo "$algs" | tr -d '[]') " in
+ *" $alg "*) ;;
+ *)
+ echo "SKIP '$alg' is not supported by this kernel"
+ SKIP_CODE=$ksft_skip
+ i=$(($i + 1))
+ continue
+ ;;
+ esac
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 +194,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 +211,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 +228,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 +254,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 +274,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 +288,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
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-27 17:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 17:34 [Devel] [PATCH hci-8.1 v3 0/7] selftests: fix sticky failure in runners Eva Kurchatova
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 1/7] ms/selftests/bpf: Upon failures, exit with code 1 in test_xsk.sh Eva Kurchatova
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 2/7] selftests/memfd: fail run_hugetlbfs_test.sh when a test fails Eva Kurchatova
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 3/7] selftests: sigaltstack: report the failures the signal handler records Eva Kurchatova
2026-10-27 17:34 ` Eva Kurchatova [this message]
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 5/7] ms/selftests/futex: futex_waitv wouldblock test should fail Eva Kurchatova
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 6/7] selftests/futex: fail run.sh when a test fails Eva Kurchatova
2026-10-27 17:34 ` [Devel] [PATCH hci-8.1 v3 7/7] selftests/futex: fail futex_waitv when the waiter failed Eva Kurchatova
2026-10-30 18:45 ` [Devel] [PATCH hci-8.1 v3 0/7] selftests: fix sticky failure in runners Konstantin Khorenko
2026-10-30 18:57 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027173457.1261044-5-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox