xref: /linux/tools/testing/selftests/ublk/test_stress_02.sh (revision a3d14d1602ca11429d242d230c31af8f822f614f)
1af83ccc7SMing Lei#!/bin/bash
2af83ccc7SMing Lei# SPDX-License-Identifier: GPL-2.0
3af83ccc7SMing Lei
4390174c9SMing Lei. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5af83ccc7SMing LeiTID="stress_02"
6af83ccc7SMing LeiERR_CODE=0
7af83ccc7SMing Lei
8*bb2cabf2SMing Leiif ! _have_program fio; then
9*bb2cabf2SMing Lei	exit "$UBLK_SKIP_CODE"
10*bb2cabf2SMing Leifi
11*bb2cabf2SMing Lei
12af83ccc7SMing Leiublk_io_and_kill_daemon()
13af83ccc7SMing Lei{
14*bb2cabf2SMing Lei	run_io_and_kill_daemon "$@"
15*bb2cabf2SMing Lei	ERR_CODE=$?
16*bb2cabf2SMing Lei	if [ ${ERR_CODE} -ne 0 ]; then
17*bb2cabf2SMing Lei		echo "$TID failure: $*"
18*bb2cabf2SMing Lei		_show_result $TID $ERR_CODE
19af83ccc7SMing Lei	fi
20af83ccc7SMing Lei}
21af83ccc7SMing Lei
22af83ccc7SMing Lei_prep_test "stress" "run IO and kill ublk server"
23af83ccc7SMing Lei
248d31a7e5SMing Lei_create_backfile 0 256M
25*bb2cabf2SMing Lei_create_backfile 1 128M
26*bb2cabf2SMing Lei_create_backfile 2 128M
278d31a7e5SMing Lei
28*bb2cabf2SMing Leifor nr_queue in 1 4; do
29*bb2cabf2SMing Lei	ublk_io_and_kill_daemon 8G -t null -q "$nr_queue" &
30*bb2cabf2SMing Lei	ublk_io_and_kill_daemon 256M -t loop -q "$nr_queue" "${UBLK_BACKFILES[0]}" &
31*bb2cabf2SMing Lei	ublk_io_and_kill_daemon 256M -t stripe -q "$nr_queue" "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
32af83ccc7SMing Lei	wait
33af83ccc7SMing Leidone
34af83ccc7SMing Lei
35_cleanup_test "stress"
36_show_result $TID $ERR_CODE
37