Merge branch 'msys2' of https://github.com/sitsofe/fio into master
[fio.git] / t / zbd / test-zbd-support
CommitLineData
191d1d1a
BVA
1#!/bin/bash
2#
3# Copyright (C) 2018 Western Digital Corporation or its affiliates.
4#
5# This file is released under the GPL.
6
7usage() {
17293ae3
SK
8 echo "Usage: $(basename "$0") [OPTIONS] <test target device file>"
9 echo "Options:"
10 echo -e "\t-d Run fio with valgrind using DRD tool"
11 echo -e "\t-e Run fio with valgrind using helgrind tool"
12 echo -e "\t-v Run fio with valgrind --read-var-info option"
13 echo -e "\t-l Test with libzbc ioengine"
14 echo -e "\t-r Reset all zones before test start"
7ce7422a 15 echo -e "\t-o <max_open_zones> Run fio with max_open_zones limit"
17293ae3
SK
16 echo -e "\t-t <test #> Run only a single test case with specified number"
17 echo -e "\t-z Run fio with debug=zbd option"
191d1d1a
BVA
18}
19
20max() {
21 if [ "$1" -gt "$2" ]; then
22 echo "$1"
23 else
24 echo "$2"
25 fi
26}
27
28min() {
29 if [ "$1" -lt "$2" ]; then
30 echo "$1"
31 else
32 echo "$2"
33 fi
34}
35
6dcb098d
DF
36ioengine() {
37 if [ -n "$use_libzbc" ]; then
38 echo -n "--ioengine=libzbc"
39 else
40 echo -n "--ioengine=$1"
41 fi
42}
43
191d1d1a
BVA
44set_io_scheduler() {
45 local dev=$1 sched=$2
46
47 [ -e "/sys/block/$dev" ] || return $?
48 if [ -e "/sys/block/$dev/mq" ]; then
49 case "$sched" in
50 noop) sched=none;;
51 deadline) sched=mq-deadline;;
52 esac
53 else
54 case "$sched" in
55 none) sched=noop;;
56 mq-deadline) sched=deadline;;
57 esac
58 fi
59
60 echo "$sched" >"/sys/block/$dev/queue/scheduler"
61}
62
63check_read() {
64 local read
65
66 read=$(fio_read <"${logfile}.${test_number}")
67 echo "read: $read <> $1" >> "${logfile}.${test_number}"
68 [ "$read" = "$1" ]
69}
70
71check_written() {
72 local written
73
74 written=$(fio_written <"${logfile}.${test_number}")
75 echo "written: $written <> $1" >> "${logfile}.${test_number}"
76 [ "$written" = "$1" ]
77}
78
79# Compare the reset count from the log file with reset count $2 using operator
80# $1 (=, -ge, -gt, -le, -lt).
81check_reset_count() {
82 local reset_count
83
84 reset_count=$(fio_reset_count <"${logfile}.${test_number}")
85 echo "reset_count: test $reset_count $1 $2" >> "${logfile}.${test_number}"
86 eval "[ '$reset_count' '$1' '$2' ]"
87}
88
0d578085
DF
89# Check log for failed assertions and crashes. Without these checks,
90# a test can succeed even when these events happen, but it must fail.
91check_log() {
92 [ ! -f "${logfile}.${1}" ] && return 0
93 ! grep -q -e "Assertion " -e "Aborted " "${logfile}.${1}"
94}
95
191d1d1a
BVA
96# Whether or not $1 (/dev/...) is a SCSI device.
97is_scsi_device() {
98 local d f
99
100 d=$(basename "$dev")
101 for f in /sys/class/scsi_device/*/device/block/"$d"; do
102 [ -e "$f" ] && return 0
103 done
104 return 1
105}
106
7ce7422a
SK
107job_var_opts_exclude() {
108 local o
109 local ex_key="${1}"
110
111 for o in "${job_var_opts[@]}"; do
112 if [[ ${o} =~ "${ex_key}" ]]; then
113 continue
114 fi
115 echo -n "${o}"
116 done
117}
118
119has_max_open_zones() {
120 while (($# > 1)); do
121 if [[ ${1} =~ "--max_open_zones" ]]; then
122 return 0
123 fi
124 shift
125 done
126 return 1
127}
128
191d1d1a 129run_fio() {
97e41ee4 130 local fio opts
191d1d1a
BVA
131
132 fio=$(dirname "$0")/../../fio
133
7ce7422a
SK
134 opts=(${global_var_opts[@]})
135 opts+=("--max-jobs=16" "--aux-path=/tmp" "--allow_file_create=0" \
136 "--significant_figures=10" "$@")
137 # When max_open_zones option is specified to this test script, add
138 # max_open_zones option to fio command unless the test case already add it.
139 if [[ -n ${max_open_zones_opt} ]] && ! has_max_open_zones "${opts[@]}"; then
140 opts+=("--max_open_zones=${max_open_zones_opt}")
141 fi
97e41ee4 142 { echo; echo "fio ${opts[*]}"; echo; } >>"${logfile}.${test_number}"
191d1d1a 143
97e41ee4 144 "${dynamic_analyzer[@]}" "$fio" "${opts[@]}"
191d1d1a
BVA
145}
146
147run_one_fio_job() {
148 local r
149
150 r=$(((RANDOM << 16) | RANDOM))
151 run_fio --name="$dev" --filename="$dev" "$@" --randseed="$r" \
152 --thread=1 --direct=1
153}
154
8f601b44
SK
155write_and_run_one_fio_job() {
156 local r
157 local write_offset="${1}"
158 local write_size="${2}"
7ce7422a 159 local -a write_opts
8f601b44
SK
160
161 shift 2
162 r=$(((RANDOM << 16) | RANDOM))
7ce7422a
SK
163 write_opts=(--name="write_job" --rw=write "$(ioengine "psync")" \
164 --bs="${logical_block_size}" --zonemode=zbd \
165 --zonesize="${zone_size}" --thread=1 --direct=1 \
166 --offset="${write_offset}" --size="${write_size}")
167 write_opts+=("${job_var_opts[@]}")
168 run_fio --filename="$dev" --randseed="$r" "${write_opts[@]}" \
8f601b44
SK
169 --name="$dev" --wait_for="write_job" "$@" --thread=1 --direct=1
170}
171
191d1d1a
BVA
172# Run fio on the first four sequential zones of the disk.
173run_fio_on_seq() {
174 local opts=()
175
176 opts+=("--offset=$((first_sequential_zone_sector * 512))")
177 opts+=("--size=$((4 * zone_size))" "--zonemode=zbd")
178 if [ -z "$is_zbd" ]; then
179 opts+=("--zonesize=${zone_size}")
180 fi
181 run_one_fio_job "${opts[@]}" "$@"
182}
183
b34eb155
SK
184# Prepare for write test by resetting zones. When max_open_zones option is
185# specified, reset all zones of the test target to ensure that zones out of the
186# test target range do not have open zones. This allows the write test to the
187# target range to be able to open zones up to max_open_zones.
188prep_write() {
189 [[ -n "${max_open_zones_opt}" && -n "${is_zbd}" ]] &&
190 reset_zone "${dev}" -1
191}
192
191d1d1a
BVA
193# Check whether buffered writes are refused.
194test1() {
195 run_fio --name=job1 --filename="$dev" --rw=write --direct=0 --bs=4K \
6dcb098d 196 "$(ioengine "psync")" --size="${zone_size}" --thread=1 \
191d1d1a
BVA
197 --zonemode=zbd --zonesize="${zone_size}" 2>&1 |
198 tee -a "${logfile}.${test_number}" |
199 grep -q 'Using direct I/O is mandatory for writing to ZBD drives'
200 local fio_rc=${PIPESTATUS[0]} grep_rc=${PIPESTATUS[2]}
201 case "$fio_rc" in
202 0|1) ;;
203 *) return "$fio_rc"
204 esac
205 if [ -n "$is_zbd" ]; then
206 [ "$grep_rc" = 0 ]
207 else
208 [ "$grep_rc" != 0 ]
209 fi
210}
211
212# Block size exceeds zone size.
213test2() {
214 local bs off opts=() rc
215
216 off=$(((first_sequential_zone_sector + 2 * sectors_per_zone) * 512))
217 bs=$((2 * zone_size))
6dcb098d 218 opts+=("$(ioengine "psync")")
191d1d1a
BVA
219 opts+=("--name=job1" "--filename=$dev" "--rw=write" "--direct=1")
220 opts+=("--zonemode=zbd" "--offset=$off" "--bs=$bs" "--size=$bs")
221 if [ -z "$is_zbd" ]; then
222 opts+=("--zonesize=${zone_size}")
223 fi
f572c8f6
DLM
224 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
225 ! grep -q 'WRITE:' "${logfile}.${test_number}"
191d1d1a
BVA
226}
227
228# Run fio against an empty zone. This causes fio to report "No I/O performed".
229test3() {
230 local off opts=() rc
231
232 off=$((first_sequential_zone_sector * 512 + 128 * zone_size))
233 size=$((zone_size))
234 [ -n "$is_zbd" ] && reset_zone "$dev" $((off / 512))
235 opts+=("--name=$dev" "--filename=$dev" "--offset=$off" "--bs=4K")
236 opts+=("--size=$size" "--zonemode=zbd")
6dcb098d 237 opts+=("$(ioengine "psync")" "--rw=read" "--direct=1" "--thread=1")
191d1d1a
BVA
238 if [ -z "$is_zbd" ]; then
239 opts+=("--zonesize=${zone_size}")
240 fi
241 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
bbd6f1bb 242 ! grep -q 'READ:' "${logfile}.${test_number}"
191d1d1a
BVA
243}
244
245# Run fio with --read_beyond_wp=1 against an empty zone.
246test4() {
247 local off opts=()
248
249 off=$((first_sequential_zone_sector * 512 + 129 * zone_size))
250 size=$((zone_size))
251 [ -n "$is_zbd" ] && reset_zone "$dev" $((off / 512))
252 opts+=("--name=$dev" "--filename=$dev" "--offset=$off" "--bs=$size")
253 opts+=("--size=$size" "--thread=1" "--read_beyond_wp=1")
6dcb098d 254 opts+=("$(ioengine "psync")" "--rw=read" "--direct=1" "--disable_lat=1")
191d1d1a
BVA
255 opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
256 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
257 check_read $size || return $?
258}
259
260# Sequential write to sequential zones.
261test5() {
d7c7539f 262 local size off capacity
191d1d1a 263
b34eb155 264 prep_write
d7c7539f
HH
265 off=$((first_sequential_zone_sector * 512))
266 capacity=$(total_zone_capacity 4 $off $dev)
191d1d1a 267 size=$((4 * zone_size))
6dcb098d 268 run_fio_on_seq "$(ioengine "psync")" --iodepth=1 --rw=write \
191d1d1a
BVA
269 --bs="$(max $((zone_size / 64)) "$logical_block_size")"\
270 --do_verify=1 --verify=md5 \
271 >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
272 check_written $capacity || return $?
273 check_read $capacity || return $?
191d1d1a
BVA
274}
275
0123751c 276# Sequential read from sequential zones.
191d1d1a 277test6() {
d7c7539f 278 local size off capacity
191d1d1a 279
b34eb155 280 prep_write
d7c7539f
HH
281 off=$((first_sequential_zone_sector * 512))
282 capacity=$(total_zone_capacity 4 $off $dev)
191d1d1a 283 size=$((4 * zone_size))
0123751c
SK
284 write_and_run_one_fio_job \
285 $((first_sequential_zone_sector * 512)) "${size}" \
d7c7539f 286 --offset="${off}" \
0123751c
SK
287 --size="${size}" --zonemode=zbd --zonesize="${zone_size}" \
288 "$(ioengine "psync")" --iodepth=1 --rw=read \
289 --bs="$(max $((zone_size / 64)) "$logical_block_size")" \
290 >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f 291 check_read $capacity || return $?
191d1d1a
BVA
292}
293
294# Random write to sequential zones, libaio, queue depth 1.
295test7() {
296 local size=$((zone_size))
d7c7539f 297 local off capacity
191d1d1a 298
b34eb155 299 prep_write
d7c7539f
HH
300 off=$((first_sequential_zone_sector * 512))
301 capacity=$(total_zone_capacity 1 $off $dev)
6dcb098d 302 run_fio_on_seq "$(ioengine "libaio")" --iodepth=1 --rw=randwrite \
191d1d1a
BVA
303 --bs="$(min 16384 "${zone_size}")" \
304 --do_verify=1 --verify=md5 --size="$size" \
305 >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
306 check_written $capacity || return $?
307 check_read $capacity || return $?
191d1d1a
BVA
308}
309
310# Random write to sequential zones, libaio, queue depth 64.
311test8() {
d7c7539f 312 local size off capacity
191d1d1a 313
b34eb155 314 prep_write
191d1d1a 315 size=$((4 * zone_size))
d7c7539f
HH
316 off=$((first_sequential_zone_sector * 512))
317 capacity=$(total_zone_capacity 4 $off $dev)
6dcb098d 318 run_fio_on_seq "$(ioengine "libaio")" --iodepth=64 --rw=randwrite \
191d1d1a
BVA
319 --bs="$(min 16384 "${zone_size}")" \
320 --do_verify=1 --verify=md5 \
321 >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
322 check_written $capacity || return $?
323 check_read $capacity || return $?
191d1d1a
BVA
324}
325
326# Random write to sequential zones, sg, queue depth 1.
327test9() {
328 local size
329
330 if ! is_scsi_device "$dev"; then
331 echo "$dev is not a SCSI device" >>"${logfile}.${test_number}"
332 return 0
333 fi
334
b34eb155 335 prep_write
191d1d1a 336 size=$((4 * zone_size))
6dcb098d
DF
337 run_fio_on_seq --ioengine=sg \
338 --iodepth=1 --rw=randwrite --bs=16K \
191d1d1a
BVA
339 --do_verify=1 --verify=md5 \
340 >>"${logfile}.${test_number}" 2>&1 || return $?
341 check_written $size || return $?
342 check_read $size || return $?
343}
344
345# Random write to sequential zones, sg, queue depth 64.
346test10() {
347 local size
348
349 if ! is_scsi_device "$dev"; then
350 echo "$dev is not a SCSI device" >>"${logfile}.${test_number}"
351 return 0
352 fi
353
b34eb155 354 prep_write
191d1d1a 355 size=$((4 * zone_size))
6dcb098d
DF
356 run_fio_on_seq --ioengine=sg \
357 --iodepth=64 --rw=randwrite --bs=16K \
191d1d1a
BVA
358 --do_verify=1 --verify=md5 \
359 >>"${logfile}.${test_number}" 2>&1 || return $?
360 check_written $size || return $?
361 check_read $size || return $?
362}
363
364# Random write to sequential zones, libaio, queue depth 64, random block size.
365test11() {
d7c7539f 366 local size off capacity
191d1d1a 367
b34eb155 368 prep_write
191d1d1a 369 size=$((4 * zone_size))
d7c7539f
HH
370 off=$((first_sequential_zone_sector * 512))
371 capacity=$(total_zone_capacity 4 $off $dev)
6dcb098d 372 run_fio_on_seq "$(ioengine "libaio")" --iodepth=64 --rw=randwrite \
191d1d1a
BVA
373 --bsrange=4K-64K --do_verify=1 --verify=md5 \
374 --debug=zbd >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
375 check_written $capacity || return $?
376 check_read $capacity || return $?
191d1d1a
BVA
377}
378
379# Random write to sequential zones, libaio, queue depth 64, max 1 open zone.
380test12() {
d7c7539f 381 local size off capacity
191d1d1a 382
b34eb155 383 prep_write
191d1d1a 384 size=$((8 * zone_size))
d7c7539f
HH
385 off=$((first_sequential_zone_sector * 512))
386 capacity=$(total_zone_capacity 8 $off $dev)
6dcb098d 387 run_fio_on_seq "$(ioengine "libaio")" --iodepth=64 --rw=randwrite --bs=16K \
191d1d1a
BVA
388 --max_open_zones=1 --size=$size --do_verify=1 --verify=md5 \
389 --debug=zbd >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
390 check_written $capacity || return $?
391 check_read $capacity || return $?
191d1d1a
BVA
392}
393
394# Random write to sequential zones, libaio, queue depth 64, max 4 open zones.
395test13() {
d7c7539f 396 local size off capacity
191d1d1a 397
b34eb155 398 prep_write
191d1d1a 399 size=$((8 * zone_size))
d7c7539f
HH
400 off=$((first_sequential_zone_sector * 512))
401 capacity=$(total_zone_capacity 8 $off $dev)
6dcb098d 402 run_fio_on_seq "$(ioengine "libaio")" --iodepth=64 --rw=randwrite --bs=16K \
191d1d1a
BVA
403 --max_open_zones=4 --size=$size --do_verify=1 --verify=md5 \
404 --debug=zbd \
405 >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f
HH
406 check_written $capacity || return $?
407 check_read $capacity || return $?
191d1d1a
BVA
408}
409
410# Random write to conventional zones.
411test14() {
412 local size
413
b34eb155 414 prep_write
191d1d1a
BVA
415 size=$((16 * 2**20)) # 20 MB
416 if [ $size -gt $((first_sequential_zone_sector * 512)) ]; then
417 echo "$dev does not have enough sequential zones" \
418 >>"${logfile}.${test_number}"
419 return 0
420 fi
6dcb098d 421 run_one_fio_job "$(ioengine "libaio")" --iodepth=64 --rw=randwrite --bs=16K \
191d1d1a
BVA
422 --zonemode=zbd --zonesize="${zone_size}" --do_verify=1 \
423 --verify=md5 --size=$size \
424 >>"${logfile}.${test_number}" 2>&1 || return $?
425 check_written $((size)) || return $?
426 check_read $((size)) || return $?
427}
428
429# Sequential read on a mix of empty and full zones.
430test15() {
431 local i off size
d7c7539f 432 local w_off w_size w_capacity
191d1d1a
BVA
433
434 for ((i=0;i<4;i++)); do
435 [ -n "$is_zbd" ] &&
436 reset_zone "$dev" $((first_sequential_zone_sector +
437 i*sectors_per_zone))
438 done
b34eb155 439 prep_write
291aa0a7
SK
440 w_off=$(((first_sequential_zone_sector + 2 * sectors_per_zone) * 512))
441 w_size=$((2 * zone_size))
d7c7539f 442 w_capacity=$(total_zone_capacity 2 $w_off $dev)
191d1d1a
BVA
443 off=$((first_sequential_zone_sector * 512))
444 size=$((4 * zone_size))
291aa0a7
SK
445 write_and_run_one_fio_job "${w_off}" "${w_size}" \
446 "$(ioengine "psync")" --rw=read --bs=$((zone_size / 16)) \
191d1d1a
BVA
447 --zonemode=zbd --zonesize="${zone_size}" --offset=$off \
448 --size=$((size)) >>"${logfile}.${test_number}" 2>&1 ||
449 return $?
d7c7539f
HH
450 check_written $((w_capacity)) || return $?
451 check_read $((w_capacity))
191d1d1a
BVA
452}
453
7285b445 454# Random read on a mix of empty and full zones.
191d1d1a
BVA
455test16() {
456 local off size
d7c7539f 457 local i w_off w_size w_capacity
191d1d1a 458
7285b445
SK
459 for ((i=0;i<4;i++)); do
460 [ -n "$is_zbd" ] &&
461 reset_zone "$dev" $((first_sequential_zone_sector +
462 i*sectors_per_zone))
463 done
b34eb155 464 prep_write
7285b445
SK
465 w_off=$(((first_sequential_zone_sector + 2 * sectors_per_zone) * 512))
466 w_size=$((2 * zone_size))
d7c7539f 467 w_capacity=$(total_zone_capacity 2 $w_off $dev)
191d1d1a
BVA
468 off=$((first_sequential_zone_sector * 512))
469 size=$((4 * zone_size))
7285b445
SK
470 write_and_run_one_fio_job "${w_off}" "${w_size}" \
471 "$(ioengine "libaio")" --iodepth=64 --rw=randread --bs=16K \
191d1d1a
BVA
472 --zonemode=zbd --zonesize="${zone_size}" --offset=$off \
473 --size=$size >>"${logfile}.${test_number}" 2>&1 || return $?
d7c7539f 474 check_written $w_capacity || return $?
191d1d1a
BVA
475 check_read $size || return $?
476}
477
478# Random reads and writes in the last zone.
479test17() {
480 local io off read size written
481
482 off=$(((disk_size / zone_size - 1) * zone_size))
483 size=$((disk_size - off))
191d1d1a
BVA
484 if [ -n "$is_zbd" ]; then
485 reset_zone "$dev" $((off / 512)) || return $?
486 fi
b34eb155 487 prep_write
6dcb098d 488 run_one_fio_job "$(ioengine "libaio")" --iodepth=8 --rw=randrw --bs=4K \
191d1d1a
BVA
489 --zonemode=zbd --zonesize="${zone_size}" \
490 --offset=$off --loops=2 --norandommap=1\
491 >>"${logfile}.${test_number}" 2>&1 || return $?
492 written=$(fio_written <"${logfile}.${test_number}")
493 read=$(fio_read <"${logfile}.${test_number}")
494 io=$((written + read))
495 echo "Total number of bytes read and written: $io <> $size" \
496 >>"${logfile}.${test_number}"
497 [ $io = $((size * 2)) ];
498}
499
500# Out-of-range zone reset threshold and frequency parameters.
501test18() {
502 run_fio_on_seq --zone_reset_threshold=-1 |&
503 tee -a "${logfile}.${test_number}" |
504 grep -q 'value out of range' || return $?
505}
506
507test19() {
508 run_fio_on_seq --zone_reset_threshold=2 |&
509 tee -a "${logfile}.${test_number}" |
510 grep -q 'value out of range' || return $?
511}
512
513test20() {
514 run_fio_on_seq --zone_reset_threshold=.4:.6 |&
515 tee -a "${logfile}.${test_number}" |
516 grep -q 'the list exceeding max length' || return $?
517}
518
519test21() {
520 run_fio_on_seq --zone_reset_frequency=-1 |&
521 tee -a "${logfile}.${test_number}" |
522 grep -q 'value out of range' || return $?
523}
524
525test22() {
526 run_fio_on_seq --zone_reset_frequency=2 |&
527 tee -a "${logfile}.${test_number}" |
528 grep -q 'value out of range' || return $?
529}
530
531test23() {
532 run_fio_on_seq --zone_reset_frequency=.4:.6 |&
533 tee -a "${logfile}.${test_number}" |
534 grep -q 'the list exceeding max length' || return $?
535}
536
537test24() {
538 local bs loops=9 size=$((zone_size))
d7c7539f
HH
539 local off capacity
540
b34eb155 541 prep_write
d7c7539f
HH
542 off=$((first_sequential_zone_sector * 512))
543 capacity=$(total_zone_capacity 1 $off $dev)
191d1d1a
BVA
544
545 bs=$(min $((256*1024)) "$zone_size")
6dcb098d
DF
546 run_fio_on_seq "$(ioengine "psync")" --rw=write --bs="$bs" \
547 --size=$size --loops=$loops \
191d1d1a
BVA
548 --zone_reset_frequency=.01 --zone_reset_threshold=.90 \
549 >> "${logfile}.${test_number}" 2>&1 || return $?
d7c7539f 550 check_written $((capacity * loops)) || return $?
191d1d1a
BVA
551 check_reset_count -eq 8 ||
552 check_reset_count -eq 9 ||
553 check_reset_count -eq 10 || return $?
554}
555
556# Multiple non-overlapping sequential write jobs for the same drive.
557test25() {
558 local i opts=()
559
560 for ((i=0;i<16;i++)); do
561 [ -n "$is_zbd" ] &&
562 reset_zone "$dev" $((first_sequential_zone_sector + i*sectors_per_zone))
563 done
b34eb155 564 prep_write
191d1d1a
BVA
565 for ((i=0;i<16;i++)); do
566 opts+=("--name=job$i" "--filename=$dev" "--thread=1" "--direct=1")
567 opts+=("--offset=$((first_sequential_zone_sector*512 + zone_size*i))")
6dcb098d 568 opts+=("--size=$zone_size" "$(ioengine "psync")" "--rw=write" "--bs=16K")
191d1d1a 569 opts+=("--zonemode=zbd" "--zonesize=${zone_size}" "--group_reporting=1")
7ce7422a 570 opts+=(${job_var_opts[@]})
191d1d1a
BVA
571 done
572 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
573}
574
575write_to_first_seq_zone() {
576 local loops=4 r
d7c7539f
HH
577 local off capacity
578
b34eb155 579 prep_write
d7c7539f
HH
580 off=$((first_sequential_zone_sector * 512))
581 capacity=$(total_zone_capacity 1 $off $dev)
191d1d1a
BVA
582
583 r=$(((RANDOM << 16) | RANDOM))
6dcb098d 584 run_fio --name="$dev" --filename="$dev" "$(ioengine "psync")" --rw="$1" \
191d1d1a 585 --thread=1 --do_verify=1 --verify=md5 --direct=1 --bs=4K \
d7c7539f
HH
586 --offset=$off \
587 --size=$zone_size --loops=$loops --randseed="$r" \
191d1d1a
BVA
588 --zonemode=zbd --zonesize="${zone_size}" --group_reporting=1 \
589 --gtod_reduce=1 >> "${logfile}.${test_number}" 2>&1 || return $?
d7c7539f 590 check_written $((loops * capacity)) || return $?
191d1d1a
BVA
591}
592
593# Overwrite the first sequential zone four times sequentially.
594test26() {
595 write_to_first_seq_zone write
596}
597
598# Overwrite the first sequential zone four times using random writes.
599test27() {
600 write_to_first_seq_zone randwrite
601}
602
603# Multiple overlapping random write jobs for the same drive.
604test28() {
605 local i jobs=16 off opts
606
607 off=$((first_sequential_zone_sector * 512 + 64 * zone_size))
608 [ -n "$is_zbd" ] && reset_zone "$dev" $((off / 512))
b34eb155 609 prep_write
191d1d1a 610 opts=("--debug=zbd")
d7c7539f 611 capacity=$(total_zone_capacity 1 $off $dev)
191d1d1a
BVA
612 for ((i=0;i<jobs;i++)); do
613 opts+=("--name=job$i" "--filename=$dev" "--offset=$off" "--bs=16K")
d7c7539f 614 opts+=("--size=$zone_size" "--io_size=$capacity" "$(ioengine "psync")" "--rw=randwrite")
191d1d1a
BVA
615 opts+=("--thread=1" "--direct=1" "--zonemode=zbd")
616 opts+=("--zonesize=${zone_size}" "--group_reporting=1")
7ce7422a 617 opts+=(${job_var_opts[@]})
191d1d1a
BVA
618 done
619 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
d7c7539f 620 check_written $((jobs * $capacity)) || return $?
191d1d1a
BVA
621 check_reset_count -eq $jobs ||
622 check_reset_count -eq $((jobs - 1)) ||
623 return $?
624}
625
626# Multiple overlapping random write jobs for the same drive and with a limited
627# number of open zones.
628test29() {
629 local i jobs=16 off opts=()
630
631 off=$((first_sequential_zone_sector * 512 + 64 * zone_size))
632 size=$((16*zone_size))
b34eb155 633 prep_write
191d1d1a
BVA
634 opts=("--debug=zbd")
635 for ((i=0;i<jobs;i++)); do
636 opts+=("--name=job$i" "--filename=$dev" "--offset=$off" "--bs=16K")
637 opts+=("--size=$size" "--io_size=$zone_size" "--thread=1")
6dcb098d 638 opts+=("$(ioengine "psync")" "--rw=randwrite" "--direct=1")
191d1d1a
BVA
639 opts+=("--max_open_zones=4" "--group_reporting=1")
640 opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
7ce7422a
SK
641 # max_open_zones is already specified
642 opts+=($(job_var_opts_exclude "--max_open_zones"))
191d1d1a
BVA
643 done
644 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
645 check_written $((jobs * zone_size)) || return $?
646}
647
648# Random reads and writes across the entire disk for 30s.
649test30() {
650 local off
651
b34eb155 652 prep_write
191d1d1a 653 off=$((first_sequential_zone_sector * 512))
6dcb098d 654 run_one_fio_job "$(ioengine "libaio")" --iodepth=8 --rw=randrw \
191d1d1a
BVA
655 --bs="$(max $((zone_size / 128)) "$logical_block_size")"\
656 --zonemode=zbd --zonesize="${zone_size}" --offset=$off\
657 --loops=2 --time_based --runtime=30s --norandommap=1\
658 >>"${logfile}.${test_number}" 2>&1
659}
660
661# Random reads across all sequential zones for 30s. This is not only a fio
662# test but also allows to verify the performance of a drive.
663test31() {
664 local bs inc nz off opts size
665
b34eb155 666 prep_write
191d1d1a
BVA
667 # Start with writing 128 KB to 128 sequential zones.
668 bs=128K
669 nz=128
670 # shellcheck disable=SC2017
671 inc=$(((disk_size - (first_sequential_zone_sector * 512)) / (nz * zone_size)
672 * zone_size))
673 opts=()
674 for ((off = first_sequential_zone_sector * 512; off < disk_size;
675 off += inc)); do
676 opts+=("--name=$dev" "--filename=$dev" "--offset=$off" "--io_size=$bs")
6dcb098d 677 opts+=("--bs=$bs" "--size=$zone_size" "$(ioengine "libaio")")
191d1d1a
BVA
678 opts+=("--rw=write" "--direct=1" "--thread=1" "--stats=0")
679 opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
7ce7422a 680 opts+=(${job_var_opts[@]})
191d1d1a
BVA
681 done
682 "$(dirname "$0")/../../fio" "${opts[@]}" >> "${logfile}.${test_number}" 2>&1
683 # Next, run the test.
684 off=$((first_sequential_zone_sector * 512))
685 size=$((disk_size - off))
686 opts=("--name=$dev" "--filename=$dev" "--offset=$off" "--size=$size")
6dcb098d 687 opts+=("--bs=$bs" "$(ioengine "psync")" "--rw=randread" "--direct=1")
191d1d1a
BVA
688 opts+=("--thread=1" "--time_based" "--runtime=30" "--zonemode=zbd")
689 opts+=("--zonesize=${zone_size}")
7ce7422a 690 opts+=(${job_var_opts[@]})
191d1d1a
BVA
691 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
692}
693
694# Random writes across all sequential zones. This is not only a fio test but
695# also allows to verify the performance of a drive.
696test32() {
697 local off opts=() size
698
b34eb155 699 prep_write
191d1d1a
BVA
700 off=$((first_sequential_zone_sector * 512))
701 size=$((disk_size - off))
702 opts+=("--name=$dev" "--filename=$dev" "--offset=$off" "--size=$size")
6dcb098d 703 opts+=("--bs=128K" "$(ioengine "psync")" "--rw=randwrite" "--direct=1")
191d1d1a
BVA
704 opts+=("--thread=1" "--time_based" "--runtime=30")
705 opts+=("--max_open_zones=$max_open_zones" "--zonemode=zbd")
706 opts+=("--zonesize=${zone_size}")
707 run_fio "${opts[@]}" >> "${logfile}.${test_number}" 2>&1 || return $?
708}
709
710# Write to sequential zones with a block size that is not a divisor of the
711# zone size.
712test33() {
713 local bs io_size size
d7c7539f 714 local off capacity=0;
191d1d1a 715
b34eb155 716 prep_write
d7c7539f
HH
717 off=$((first_sequential_zone_sector * 512))
718 capacity=$(total_zone_capacity 1 $off $dev)
191d1d1a 719 size=$((2 * zone_size))
d7c7539f
HH
720 io_size=$((5 * capacity))
721 bs=$((3 * capacity / 4))
6dcb098d
DF
722 run_fio_on_seq "$(ioengine "psync")" --iodepth=1 --rw=write \
723 --size=$size --io_size=$io_size --bs=$bs \
191d1d1a
BVA
724 >> "${logfile}.${test_number}" 2>&1 || return $?
725 check_written $(((io_size + bs - 1) / bs * bs)) || return $?
726}
727
728# Write to sequential zones with a block size that is not a divisor of the
729# zone size and with data verification enabled.
730test34() {
731 local size
732
b34eb155 733 prep_write
191d1d1a 734 size=$((2 * zone_size))
6dcb098d 735 run_fio_on_seq "$(ioengine "psync")" --iodepth=1 --rw=write --size=$size \
191d1d1a
BVA
736 --do_verify=1 --verify=md5 --bs=$((3 * zone_size / 4)) \
737 >> "${logfile}.${test_number}" 2>&1 && return 1
738 grep -q 'not a divisor of' "${logfile}.${test_number}"
739}
740
741# Test 1/4 for the I/O boundary rounding code: $size < $zone_size.
742test35() {
743 local bs off io_size size
744
b34eb155 745 prep_write
191d1d1a
BVA
746 off=$(((first_sequential_zone_sector + 1) * 512))
747 size=$((zone_size - 2 * 512))
748 bs=$((zone_size / 4))
6dcb098d
DF
749 run_one_fio_job --offset=$off --size=$size "$(ioengine "psync")" \
750 --iodepth=1 --rw=write --do_verify=1 --verify=md5 \
751 --bs=$bs --zonemode=zbd --zonesize="${zone_size}" \
191d1d1a
BVA
752 >> "${logfile}.${test_number}" 2>&1 && return 1
753 grep -q 'io_size must be at least one zone' "${logfile}.${test_number}"
754}
755
756# Test 2/4 for the I/O boundary rounding code: $size < $zone_size.
757test36() {
758 local bs off io_size size
759
b34eb155 760 prep_write
191d1d1a
BVA
761 off=$(((first_sequential_zone_sector) * 512))
762 size=$((zone_size - 512))
763 bs=$((zone_size / 4))
6dcb098d
DF
764 run_one_fio_job --offset=$off --size=$size "$(ioengine "psync")" \
765 --iodepth=1 --rw=write --do_verify=1 --verify=md5 \
766 --bs=$bs --zonemode=zbd --zonesize="${zone_size}" \
191d1d1a
BVA
767 >> "${logfile}.${test_number}" 2>&1 && return 1
768 grep -q 'io_size must be at least one zone' "${logfile}.${test_number}"
769}
770
771# Test 3/4 for the I/O boundary rounding code: $size > $zone_size.
772test37() {
d7c7539f 773 local bs off size capacity
191d1d1a 774
b34eb155 775 prep_write
d7c7539f 776 capacity=$(total_zone_capacity 1 $first_sequential_zone_sector $dev)
191d1d1a
BVA
777 if [ "$first_sequential_zone_sector" = 0 ]; then
778 off=0
779 else
780 off=$(((first_sequential_zone_sector - 1) * 512))
781 fi
782 size=$((zone_size + 2 * 512))
783 bs=$((zone_size / 4))
6dcb098d
DF
784 run_one_fio_job --offset=$off --size=$size "$(ioengine "psync")" \
785 --iodepth=1 --rw=write --do_verify=1 --verify=md5 \
786 --bs=$bs --zonemode=zbd --zonesize="${zone_size}" \
191d1d1a 787 >> "${logfile}.${test_number}" 2>&1
d7c7539f 788 check_written $capacity || return $?
191d1d1a
BVA
789}
790
791# Test 4/4 for the I/O boundary rounding code: $offset > $disk_size - $zone_size
792test38() {
793 local bs off size
794
b34eb155 795 prep_write
191d1d1a
BVA
796 size=$((logical_block_size))
797 off=$((disk_size - logical_block_size))
798 bs=$((logical_block_size))
6dcb098d
DF
799 run_one_fio_job --offset=$off --size=$size "$(ioengine "psync")" \
800 --iodepth=1 --rw=write --do_verify=1 --verify=md5 \
801 --bs=$bs --zonemode=zbd --zonesize="${zone_size}" \
191d1d1a
BVA
802 >> "${logfile}.${test_number}" 2>&1 && return 1
803 grep -q 'io_size must be at least one zone' "${logfile}.${test_number}"
804}
805
806# Read one block from a block device.
807read_one_block() {
808 local bs
809
810 bs=$((logical_block_size))
6dcb098d 811 run_one_fio_job --rw=read "$(ioengine "psync")" --bs=$bs --size=$bs "$@" 2>&1 |
191d1d1a
BVA
812 tee -a "${logfile}.${test_number}"
813}
814
815# Check whether fio accepts --zonemode=none for zoned block devices.
816test39() {
817 [ -n "$is_zbd" ] || return 0
818 read_one_block --zonemode=none >/dev/null || return $?
819 check_read $((logical_block_size)) || return $?
820}
821
822# Check whether fio accepts --zonemode=strided for zoned block devices.
823test40() {
824 local bs
825
826 bs=$((logical_block_size))
827 [ -n "$is_zbd" ] || return 0
828 read_one_block --zonemode=strided |
829 grep -q 'fio: --zonesize must be specified when using --zonemode=strided' ||
830 return $?
831 read_one_block --zonemode=strided --zonesize=$bs >/dev/null || return $?
832 check_read $bs || return $?
833}
834
835# Check whether fio checks the zone size for zoned block devices.
836test41() {
837 [ -n "$is_zbd" ] || return 0
838 read_one_block --zonemode=zbd --zonesize=$((2 * zone_size)) |
839 grep -q 'job parameter zonesize.*does not match disk zone size'
840}
841
842# Check whether fio handles --zonesize=0 correctly for regular block devices.
843test42() {
844 [ -n "$is_zbd" ] && return 0
845 read_one_block --zonemode=zbd --zonesize=0 |
846 grep -q 'Specifying the zone size is mandatory for regular block devices with --zonemode=zbd'
847}
848
a4b7f12b 849# Check whether fio handles --zonesize=1 correctly for regular block devices.
191d1d1a 850test43() {
a4b7f12b 851 [ -n "$is_zbd" ] && return 0
191d1d1a
BVA
852 read_one_block --zonemode=zbd --zonesize=1 |
853 grep -q 'zone size must be at least 512 bytes for --zonemode=zbd'
854}
855
856# Check whether fio handles --zonemode=none --zonesize=1 correctly.
857test44() {
858 read_one_block --zonemode=none --zonesize=1 |
859 grep -q 'fio: --zonemode=none and --zonesize are not compatible'
860}
861
862test45() {
863 local bs i
864
865 [ -z "$is_zbd" ] && return 0
b34eb155 866 prep_write
191d1d1a 867 bs=$((logical_block_size))
6dcb098d 868 run_one_fio_job "$(ioengine "psync")" --iodepth=1 --rw=randwrite --bs=$bs\
191d1d1a
BVA
869 --offset=$((first_sequential_zone_sector * 512)) \
870 --size="$zone_size" --do_verify=1 --verify=md5 2>&1 |
871 tee -a "${logfile}.${test_number}" |
872 grep -q "fio: first I/O failed. If .* is a zoned block device, consider --zonemode=zbd"
873}
874
bc596cbc
DLM
875# Random write to sequential zones, libaio, 8 jobs, queue depth 64 per job
876test46() {
877 local size
878
b34eb155 879 prep_write
bc596cbc 880 size=$((4 * zone_size))
6dcb098d 881 run_fio_on_seq "$(ioengine "libaio")" --iodepth=64 --rw=randwrite --bs=4K \
bc596cbc
DLM
882 --group_reporting=1 --numjobs=8 \
883 >> "${logfile}.${test_number}" 2>&1 || return $?
884 check_written $((size * 8)) || return $?
885}
886
4d37720a
DLM
887# Check whether fio handles --zonemode=zbd --zoneskip=1 correctly.
888test47() {
889 local bs
890
b34eb155 891 prep_write
4d37720a 892 bs=$((logical_block_size))
e0424151 893 run_fio_on_seq "$(ioengine "psync")" --rw=write --bs=$bs --zoneskip=1 \
4d37720a
DLM
894 >> "${logfile}.${test_number}" 2>&1 && return 1
895 grep -q 'zoneskip 1 is not a multiple of the device zone size' "${logfile}.${test_number}"
896}
897
3bd2078b
NA
898# Multiple overlapping random write jobs for the same drive and with a
899# limited number of open zones. This is similar to test29, but uses libaio
900# to stress test zone locking.
901test48() {
902 local i jobs=16 off opts=()
903
904 off=$((first_sequential_zone_sector * 512 + 64 * zone_size))
905 size=$((16*zone_size))
b34eb155 906 prep_write
3bd2078b
NA
907 opts=("--aux-path=/tmp" "--allow_file_create=0" "--significant_figures=10")
908 opts+=("--debug=zbd")
6dcb098d 909 opts+=("$(ioengine "libaio")" "--rw=randwrite" "--direct=1")
3bd2078b
NA
910 opts+=("--time_based" "--runtime=30")
911 opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
912 opts+=("--max_open_zones=4")
913 for ((i=0;i<jobs;i++)); do
914 opts+=("--name=job$i" "--filename=$dev" "--offset=$off" "--bs=16K")
915 opts+=("--io_size=$zone_size" "--iodepth=256" "--thread=1")
916 opts+=("--group_reporting=1")
7ce7422a
SK
917 # max_open_zones is already specified
918 opts+=($(job_var_opts_exclude "--max_open_zones"))
3bd2078b
NA
919 done
920
921 fio=$(dirname "$0")/../../fio
922
923 { echo; echo "fio ${opts[*]}"; echo; } >>"${logfile}.${test_number}"
924
925 timeout -v -s KILL 45s \
926 "${dynamic_analyzer[@]}" "$fio" "${opts[@]}" \
927 >> "${logfile}.${test_number}" 2>&1 || return $?
928}
929
5c0400e7
HH
930# Check if fio handles --zonecapacity on a normal block device correctly
931test49() {
932
933 if [ -n "$is_zbd" ]; then
934 echo "$dev is not a regular block device" \
935 >>"${logfile}.${test_number}"
936 return 0
937 fi
938
939 size=$((2 * zone_size))
940 capacity=$((zone_size * 3 / 4))
941
942 run_one_fio_job "$(ioengine "psync")" --rw=write \
943 --zonemode=zbd --zonesize="${zone_size}" \
944 --zonecapacity=${capacity} \
945 --verify=md5 --size=${size} >>"${logfile}.${test_number}" 2>&1 ||
946 return $?
693403eb 947 check_written $((capacity * 2)) || return $?
5c0400e7
HH
948 check_read $((capacity * 2)) || return $?
949}
950
191d1d1a
BVA
951tests=()
952dynamic_analyzer=()
953reset_all_zones=
6dcb098d
DF
954use_libzbc=
955zbd_debug=
7ce7422a 956max_open_zones_opt=
191d1d1a
BVA
957
958while [ "${1#-}" != "$1" ]; do
959 case "$1" in
960 -d) dynamic_analyzer=(valgrind "--read-var-info=yes" "--tool=drd"
961 "--show-confl-seg=no");
962 shift;;
963 -e) dynamic_analyzer=(valgrind "--read-var-info=yes" "--tool=helgrind");
964 shift;;
6dcb098d 965 -l) use_libzbc=1; shift;;
191d1d1a
BVA
966 -r) reset_all_zones=1; shift;;
967 -t) tests+=("$2"); shift; shift;;
7ce7422a 968 -o) max_open_zones_opt="${2}"; shift; shift;;
191d1d1a
BVA
969 -v) dynamic_analyzer=(valgrind "--read-var-info=yes");
970 shift;;
6dcb098d 971 -z) zbd_debug=1; shift;;
191d1d1a
BVA
972 --) shift; break;;
973 esac
974done
975
976if [ $# != 1 ]; then
977 usage
978 exit 1
979fi
980
981# shellcheck source=functions
982source "$(dirname "$0")/functions" || exit $?
983
7ce7422a
SK
984global_var_opts=()
985job_var_opts=()
6dcb098d 986if [ -n "$zbd_debug" ]; then
7ce7422a 987 global_var_opts+=("--debug=zbd")
6dcb098d 988fi
191d1d1a
BVA
989dev=$1
990realdev=$(readlink -f "$dev")
991basename=$(basename "$realdev")
6dcb098d
DF
992
993if [[ -b "$realdev" ]]; then
994 major=$((0x$(stat -L -c '%t' "$realdev"))) || exit $?
995 minor=$((0x$(stat -L -c '%T' "$realdev"))) || exit $?
996 disk_size=$(($(<"/sys/dev/block/$major:$minor/size")*512))
997
998 # When the target is a partition device, get basename of its
999 # holder device to access sysfs path of the holder device
1000 if [[ -r "/sys/dev/block/$major:$minor/partition" ]]; then
1001 realsysfs=$(readlink "/sys/dev/block/$major:$minor")
1002 basename=$(basename "${realsysfs%/*}")
1003 fi
1004 logical_block_size=$(<"/sys/block/$basename/queue/logical_block_size")
1005 case "$(<"/sys/class/block/$basename/queue/zoned")" in
1006 host-managed|host-aware)
1007 is_zbd=true
552e214c
SK
1008 if ! check_blkzone "${dev}"; then
1009 exit 1
1010 fi
6dcb098d
DF
1011 if ! result=($(first_sequential_zone "$dev")); then
1012 echo "Failed to determine first sequential zone"
1013 exit 1
1014 fi
1015 first_sequential_zone_sector=${result[0]}
1016 sectors_per_zone=${result[1]}
1017 zone_size=$((sectors_per_zone * 512))
1018 if ! max_open_zones=$(max_open_zones "$dev"); then
1019 echo "Failed to determine maximum number of open zones"
1020 exit 1
1021 fi
1022 set_io_scheduler "$basename" deadline || exit $?
1023 if [ -n "$reset_all_zones" ]; then
1024 reset_zone "$dev" -1
1025 fi
1026 ;;
1027 *)
1028 first_sequential_zone_sector=$(((disk_size / 2) &
1029 (logical_block_size - 1)))
1030 zone_size=$(max 65536 "$logical_block_size")
1031 sectors_per_zone=$((zone_size / 512))
1032 max_open_zones=128
1033 set_io_scheduler "$basename" none || exit $?
1034 ;;
1035 esac
1036elif [[ -c "$realdev" ]]; then
1037 # For an SG node, we must have libzbc option specified
1038 if [[ ! -n "$use_libzbc" ]]; then
1039 echo "Character device files can only be used with -l (libzbc) option"
1040 exit 1
1041 fi
1042
1043 if ! $(is_zbc "$dev"); then
1044 echo "Device is not a ZBC disk"
1045 exit 1
1046 fi
191d1d1a 1047 is_zbd=true
6dcb098d
DF
1048
1049 if ! disk_size=($(( $(zbc_disk_sectors "$dev") * 512))); then
1050 echo "Failed to determine disk size"
1051 exit 1
1052 fi
1053 if ! logical_block_size=($(zbc_logical_block_size "$dev")); then
1054 echo "Failed to determine logical block size"
1055 exit 1
1056 fi
191d1d1a 1057 if ! result=($(first_sequential_zone "$dev")); then
6dcb098d
DF
1058 echo "Failed to determine first sequential zone"
1059 exit 1
191d1d1a
BVA
1060 fi
1061 first_sequential_zone_sector=${result[0]}
1062 sectors_per_zone=${result[1]}
1063 zone_size=$((sectors_per_zone * 512))
1064 if ! max_open_zones=$(max_open_zones "$dev"); then
6dcb098d
DF
1065 echo "Failed to determine maximum number of open zones"
1066 exit 1
191d1d1a 1067 fi
191d1d1a 1068 if [ -n "$reset_all_zones" ]; then
6dcb098d 1069 reset_zone "$dev" -1
191d1d1a 1070 fi
6dcb098d
DF
1071fi
1072
7ce7422a
SK
1073if [[ -n ${max_open_zones_opt} ]]; then
1074 # Override max_open_zones with the script option value
1075 max_open_zones="${max_open_zones_opt}"
1076 job_var_opts+=("--max_open_zones=${max_open_zones_opt}")
1077fi
1078
6dcb098d
DF
1079echo -n "First sequential zone starts at sector $first_sequential_zone_sector;"
1080echo " zone size: $((zone_size >> 20)) MB"
191d1d1a
BVA
1081
1082if [ "${#tests[@]}" = 0 ]; then
106a71cd
SK
1083 readarray -t tests < <(declare -F | grep "test[0-9]*" | \
1084 tr -c -d "[:digit:]\n" | sort -n)
191d1d1a
BVA
1085fi
1086
1087logfile=$0.log
1088
72176dc7
BVA
1089passed=0
1090failed=0
332fa178
DF
1091if [ -t 1 ]; then
1092 red="\e[1;31m"
1093 green="\e[1;32m"
1094 end="\e[m"
1095else
1096 red=""
1097 green=""
1098 end=""
1099fi
191d1d1a 1100rc=0
332fa178 1101
c96b385b
DF
1102intr=0
1103trap 'intr=1' SIGINT
1104
191d1d1a
BVA
1105for test_number in "${tests[@]}"; do
1106 rm -f "${logfile}.${test_number}"
332fa178 1107 echo -n "Running test $(printf "%02d" $test_number) ... "
0d578085 1108 if eval "test$test_number" && check_log $test_number; then
191d1d1a 1109 status="PASS"
332fa178 1110 cc_status="${green}${status}${end}"
72176dc7 1111 ((passed++))
191d1d1a
BVA
1112 else
1113 status="FAIL"
332fa178 1114 cc_status="${red}${status}${end}"
72176dc7 1115 ((failed++))
191d1d1a
BVA
1116 rc=1
1117 fi
332fa178 1118 echo -e "$cc_status"
191d1d1a 1119 echo "$status" >> "${logfile}.${test_number}"
c96b385b 1120 [ $intr -ne 0 ] && exit 1
191d1d1a
BVA
1121done
1122
72176dc7
BVA
1123echo "$passed tests passed"
1124if [ $failed -gt 0 ]; then
1125 echo " and $failed tests failed"
1126fi
191d1d1a 1127exit $rc