# This file is released under the GPL.
usage() {
- echo "Usage: $(basename "$0") [-d] [-e] [-l] [-r] [-v] [-t <test>] [-z] <SMR drive device node>"
+ echo "Usage: $(basename "$0") [OPTIONS] <test target device file>"
+ echo "Options:"
+ echo -e "\t-d Run fio with valgrind using DRD tool"
+ echo -e "\t-e Run fio with valgrind using helgrind tool"
+ echo -e "\t-v Run fio with valgrind --read-var-info option"
+ echo -e "\t-l Test with libzbc ioengine"
+ echo -e "\t-r Reset all zones before test start"
+ echo -e "\t-o <max_open_zones> Run fio with max_open_zones limit"
+ echo -e "\t-t <test #> Run only a single test case with specified number"
+ echo -e "\t-z Run fio with debug=zbd option"
}
max() {
eval "[ '$reset_count' '$1' '$2' ]"
}
+# Check log for failed assertions and crashes. Without these checks,
+# a test can succeed even when these events happen, but it must fail.
+check_log() {
+ [ ! -f "${logfile}.${1}" ] && return 0
+ ! grep -q -e "Assertion " -e "Aborted " "${logfile}.${1}"
+}
+
# Whether or not $1 (/dev/...) is a SCSI device.
is_scsi_device() {
local d f
return 1
}
+job_var_opts_exclude() {
+ local o
+ local ex_key="${1}"
+
+ for o in "${job_var_opts[@]}"; do
+ if [[ ${o} =~ "${ex_key}" ]]; then
+ continue
+ fi
+ echo -n "${o}"
+ done
+}
+
+has_max_open_zones() {
+ while (($# > 1)); do
+ if [[ ${1} =~ "--max_open_zones" ]]; then
+ return 0
+ fi
+ shift
+ done
+ return 1
+}
+
run_fio() {
local fio opts
fio=$(dirname "$0")/../../fio
- opts=("--max-jobs=16" "--aux-path=/tmp" "--allow_file_create=0" \
- "--significant_figures=10" "$@")
- opts+=(${var_opts[@]})
+ opts=(${global_var_opts[@]})
+ opts+=("--max-jobs=16" "--aux-path=/tmp" "--allow_file_create=0" \
+ "--significant_figures=10" "$@")
+ # When max_open_zones option is specified to this test script, add
+ # max_open_zones option to fio command unless the test case already add it.
+ if [[ -n ${max_open_zones_opt} ]] && ! has_max_open_zones "${opts[@]}"; then
+ opts+=("--max_open_zones=${max_open_zones_opt}")
+ fi
{ echo; echo "fio ${opts[*]}"; echo; } >>"${logfile}.${test_number}"
"${dynamic_analyzer[@]}" "$fio" "${opts[@]}"
local r
local write_offset="${1}"
local write_size="${2}"
+ local -a write_opts
shift 2
r=$(((RANDOM << 16) | RANDOM))
- run_fio --filename="$dev" --randseed="$r" --name="write_job" --rw=write \
- "$(ioengine "psync")" --bs="${logical_block_size}" \
- --zonemode=zbd --zonesize="${zone_size}" --thread=1 --direct=1 \
- --offset="${write_offset}" --size="${write_size}" \
+ write_opts=(--name="write_job" --rw=write "$(ioengine "psync")" \
+ --bs="${logical_block_size}" --zonemode=zbd \
+ --zonesize="${zone_size}" --thread=1 --direct=1 \
+ --offset="${write_offset}" --size="${write_size}")
+ write_opts+=("${job_var_opts[@]}")
+ run_fio --filename="$dev" --randseed="$r" "${write_opts[@]}" \
--name="$dev" --wait_for="write_job" "$@" --thread=1 --direct=1
}
opts+=("--offset=$((first_sequential_zone_sector*512 + zone_size*i))")
opts+=("--size=$zone_size" "$(ioengine "psync")" "--rw=write" "--bs=16K")
opts+=("--zonemode=zbd" "--zonesize=${zone_size}" "--group_reporting=1")
- opts+=(${var_opts[@]})
+ opts+=(${job_var_opts[@]})
done
run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
}
opts+=("--size=$zone_size" "--io_size=$capacity" "$(ioengine "psync")" "--rw=randwrite")
opts+=("--thread=1" "--direct=1" "--zonemode=zbd")
opts+=("--zonesize=${zone_size}" "--group_reporting=1")
- opts+=(${var_opts[@]})
+ opts+=(${job_var_opts[@]})
done
run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
check_written $((jobs * $capacity)) || return $?
opts+=("$(ioengine "psync")" "--rw=randwrite" "--direct=1")
opts+=("--max_open_zones=4" "--group_reporting=1")
opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
- opts+=(${var_opts[@]})
+ # max_open_zones is already specified
+ opts+=($(job_var_opts_exclude "--max_open_zones"))
done
run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
check_written $((jobs * zone_size)) || return $?
opts+=("--bs=$bs" "--size=$zone_size" "$(ioengine "libaio")")
opts+=("--rw=write" "--direct=1" "--thread=1" "--stats=0")
opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
- opts+=(${var_opts[@]})
+ opts+=(${job_var_opts[@]})
done
"$(dirname "$0")/../../fio" "${opts[@]}" >> "${logfile}.${test_number}" 2>&1
# Next, run the test.
opts+=("--bs=$bs" "$(ioengine "psync")" "--rw=randread" "--direct=1")
opts+=("--thread=1" "--time_based" "--runtime=30" "--zonemode=zbd")
opts+=("--zonesize=${zone_size}")
+ opts+=(${job_var_opts[@]})
run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
}
opts+=("--name=job$i" "--filename=$dev" "--offset=$off" "--bs=16K")
opts+=("--io_size=$zone_size" "--iodepth=256" "--thread=1")
opts+=("--group_reporting=1")
+ # max_open_zones is already specified
+ opts+=($(job_var_opts_exclude "--max_open_zones"))
done
fio=$(dirname "$0")/../../fio
reset_all_zones=
use_libzbc=
zbd_debug=
+max_open_zones_opt=
while [ "${1#-}" != "$1" ]; do
case "$1" in
-l) use_libzbc=1; shift;;
-r) reset_all_zones=1; shift;;
-t) tests+=("$2"); shift; shift;;
+ -o) max_open_zones_opt="${2}"; shift; shift;;
-v) dynamic_analyzer=(valgrind "--read-var-info=yes");
shift;;
-z) zbd_debug=1; shift;;
# shellcheck source=functions
source "$(dirname "$0")/functions" || exit $?
-var_opts=()
+global_var_opts=()
+job_var_opts=()
if [ -n "$zbd_debug" ]; then
- var_opts+=("--debug=zbd")
+ global_var_opts+=("--debug=zbd")
fi
dev=$1
realdev=$(readlink -f "$dev")
fi
fi
+if [[ -n ${max_open_zones_opt} ]]; then
+ # Override max_open_zones with the script option value
+ max_open_zones="${max_open_zones_opt}"
+ job_var_opts+=("--max_open_zones=${max_open_zones_opt}")
+fi
+
echo -n "First sequential zone starts at sector $first_sequential_zone_sector;"
echo " zone size: $((zone_size >> 20)) MB"
for test_number in "${tests[@]}"; do
rm -f "${logfile}.${test_number}"
echo -n "Running test $(printf "%02d" $test_number) ... "
- if eval "test$test_number"; then
+ if eval "test$test_number" && check_log $test_number; then
status="PASS"
cc_status="${green}${status}${end}"
((passed++))