@@ -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}"
@@ -464,7 +468,6 @@ _unload_modules() {
_check_and_call_test() {
local postfix
- local ret
if declare -fF requires >/dev/null; then
requires
@@ -473,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() {
@@ -540,6 +534,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
+}