DEVICE_ONLY=1
```
+### Zoned Block Device
+
+To run test cases for zoned block devices, set the `RUN_ZONED_TESTS` variable.
+When this variable is set and a test case can prepare a virtual device such as
+`null_blk` with zoned mode, the test case is executed twice: first in non-zoned
+mode and second in zoned mode. The use of the `RUN_ZONED_TESTS` variable
+requires that the kernel be compiled with `CONFIG_BLK_DEV_ZONED` enabled.
+```sh
+RUN_ZONED_TESTS=1
+```
+
### Custom Setup
The `config` file is really just a bash file that is sourced at the beginning
local test_name="$1"
local explicit="$2"
- unset DESCRIPTION QUICK TIMED requires device_requires test test_device
+ unset CAN_BE_ZONED DESCRIPTION QUICK TIMED requires device_requires test test_device
# shellcheck disable=SC1090
if ! . "tests/${test_name}"; then
_output_status() {
local test="$1"
local status="$2"
+ local zoned=" "
+
+ if (( RUN_FOR_ZONED )); then zoned=" (zoned) "; fi
if [[ -v DESCRIPTION ]]; then
- printf '%-60s' "$test ($DESCRIPTION)"
+ printf '%-60s' "${test}${zoned}($DESCRIPTION)"
else
- printf '%-60s' "$test"
+ printf '%-60s' "${test}${zoned}"
fi
if [[ -z $status ]]; then
echo
fi
}
+_test_dev_is_zoned() {
+ if grep -qe "none" "${TEST_DEV_SYSFS}/queue/zoned" ; then
+ SKIP_REASON="${TEST_DEV} is not a zoned block device"
+ return 1
+ fi
+ return 0
+}
+
_run_test() {
TEST_NAME="$1"
CHECK_DMESG=1
DMESG_FILTER="cat"
+ RUN_FOR_ZONED=0
# shellcheck disable=SC1090
. "tests/${TEST_NAME}"
RESULTS_DIR="$OUTPUT/nodev"
_call_test test
+ if (( RUN_ZONED_TESTS && CAN_BE_ZONED )); then
+ RESULTS_DIR="$OUTPUT/nodev_zoned"
+ RUN_FOR_ZONED=1
+ _call_test test
+ fi
else
if [[ ${#TEST_DEVS[@]} -eq 0 ]]; then
return 0
local ret=0
for TEST_DEV in "${TEST_DEVS[@]}"; do
TEST_DEV_SYSFS="${TEST_DEV_SYSFS_DIRS["$TEST_DEV"]}"
+ if (( !CAN_BE_ZONED )) && _test_dev_is_zoned; then
+ SKIP_REASON="${TEST_DEV} is a zoned block device"
+ _output_notrun "$TEST_NAME => $(basename "$TEST_DEV")"
+ continue
+ fi
+ unset SKIP_REASON
if declare -fF device_requires >/dev/null && ! device_requires; then
_output_notrun "$TEST_NAME => $(basename "$TEST_DEV")"
continue
# Default configuration.
: "${DEVICE_ONLY:=0}"
: "${QUICK_RUN:=0}"
+: "${RUN_ZONED_TESTS:=0}"
: "${OUTPUT:=results}"
if [[ -v EXCLUDE ]] && ! declare -p EXCLUDE | grep -q '^declare -a'; then
# If EXCLUDE was not defined as an array, convert it to one.
}
_init_null_blk() {
- if ! modprobe -r null_blk || ! modprobe null_blk "$@"; then
+ if [[ -d /sys/kernel/config/nullb ]]; then
+ find /sys/kernel/config/nullb -mindepth 1 -maxdepth 1 \
+ -type d -delete
+ fi
+
+ local zoned=""
+ if (( RUN_FOR_ZONED )); then zoned="zoned=1"; fi
+
+ if ! modprobe -r null_blk || ! modprobe null_blk "$@" "${zoned}" ; then
return 1
fi
# Alternatively, you can filter out any unimportant messages in dmesg like so:
# DMESG_FILTER="grep -v sysfs"
+# TODO: if this test can be run for both regular block devices and zoned block
+# devices, uncomment the line below.
+# CAN_BE_ZONED=1
+
# TODO: if this test has any extra requirements, it should define a requires()
# function. If the test can be run, requires() should return 0. Otherwise, it
# should return non-zero and set the \$SKIP_REASON variable. Usually,