@@ -56,6 +56,11 @@ _found_test() {
return 1
fi
+ if [[ -n $CAN_BE_ZONED ]] && declare -fF test >/dev/null && declare -fF set_conditions >/dev/null; then
+ _warning "${test_name} defines both CAN_BE_ZONED and set_conditions()"
+ return 1
+ fi
+
if (( QUICK && TIMED )); then
_warning "${test_name} cannot be both QUICK and TIMED"
return 1
@@ -194,7 +199,6 @@ _output_status() {
local status="$2"
local str="${test} "
- (( RUN_FOR_ZONED )) && str="$str(zoned) "
[[ ${COND_DESC:-} ]] && str="$str(${COND_DESC}) "
[[ ${DESCRIPTION:-} ]] && str="$str(${DESCRIPTION})"
printf '%-60s' "${str}"
@@ -472,15 +476,6 @@ _check_and_call_test() {
[[ -n $COND_DESC ]] && postfix=_${COND_DESC//[ =]/_}
RESULTS_DIR="$OUTPUT/nodev${postfix}"
_call_test test
- ret=$?
- if (( RUN_ZONED_TESTS && CAN_BE_ZONED )); then
- RESULTS_DIR="$OUTPUT/nodev_zoned${postfix}"
- RUN_FOR_ZONED=1
- _call_test test
- ret=$(( ret || $? ))
- fi
-
- return $ret
}
_check_and_call_test_device() {
@@ -538,6 +533,9 @@ _run_test() {
. "tests/${TEST_NAME}"
if declare -fF test >/dev/null; then
+ if ((RUN_ZONED_TESTS && CAN_BE_ZONED)); then
+ . "common/zoned"
+ fi
if declare -fF set_conditions >/dev/null; then
nr_conds=$(set_conditions)
for ((cond_i = 0; cond_i < nr_conds; cond_i++)); do
new file mode 100644
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Western Digital Corporation or its affiliates.
+
+# The helper function for test cases with CAN_BE_ZONED flag and test()
+# function. Run the test case twice for non-zoned and zoned conditions.
+set_conditions() {
+ local index=$1
+
+ if [[ -z $index ]]; then
+ echo 2
+ return
+ fi
+
+ if ((index == 0)); then
+ export RUN_FOR_ZONED=0
+ export COND_DESC=
+ elif ((index == 1)); then
+ export RUN_FOR_ZONED=1
+ export COND_DESC="zoned"
+ fi
+}
When the test case with test() function is marked as CAN_BE_ZONED, blktests runs the test case twice: once for non-zoned device, and the second for zoned device. This is now implemented as a special logic in the check script. To simplify the implementation, use the feature to repeat test cases with different conditions. Use set_conditions() and move out the special logic from the check script to the common/zoned script file. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- check | 18 ++++++++---------- common/zoned | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 common/zoned