xref: /linux/tools/testing/selftests/ublk/test_generic_02.sh (revision 68a052239fc4b351e961f698b824f7654a346091)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5
6TID="generic_02"
7ERR_CODE=0
8
9if ! _have_program bpftrace; then
10	exit "$UBLK_SKIP_CODE"
11fi
12
13if ! _have_program fio; then
14	exit "$UBLK_SKIP_CODE"
15fi
16
17_prep_test "null" "sequential io order for MQ"
18
19dev_id=$(_add_ublk_dev -t null -q 2)
20_check_add_dev $TID $?
21
22dev_t=$(_get_disk_dev_t "$dev_id")
23bpftrace trace/seq_io.bt "$dev_t" "W" 1 > "$UBLK_TMP" 2>&1 &
24btrace_pid=$!
25sleep 2
26
27if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then
28	_cleanup_test "null"
29	exit "$UBLK_SKIP_CODE"
30fi
31
32# run fio over this ublk disk
33fio --name=write_seq \
34    --filename=/dev/ublkb"${dev_id}" \
35    --ioengine=libaio --iodepth=16 \
36    --rw=write \
37    --size=512M \
38    --direct=1 \
39    --bs=4k > /dev/null 2>&1
40ERR_CODE=$?
41kill "$btrace_pid"
42wait
43if grep -q "io_out_of_order" "$UBLK_TMP"; then
44	cat "$UBLK_TMP"
45	ERR_CODE=255
46fi
47_cleanup_test "null"
48_show_result $TID $ERR_CODE
49