xref: /linux/tools/testing/selftests/ublk/test_stress_02.sh (revision c284d3e423382be3591d5b1e402e330e6c3f726c)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5TID="stress_02"
6ERR_CODE=0
7DEV_ID=-1
8
9ublk_io_and_kill_daemon()
10{
11	local size=$1
12	shift 1
13	local backfile=""
14	if echo "$@" | grep -q "loop"; then
15		backfile=${*: -1}
16	fi
17	DEV_ID=$(_add_ublk_dev "$@")
18	_check_add_dev $TID $? "${backfile}"
19
20	[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)"
21	if ! __run_io_and_remove "${DEV_ID}" "${size}" "yes"; then
22		echo "/dev/ublkc${DEV_ID} isn't removed res ${res}"
23		_remove_backfile "${backfile}"
24		exit 255
25	fi
26}
27
28_prep_test "stress" "run IO and kill ublk server"
29
30ublk_io_and_kill_daemon 8G -t null -q 4
31ERR_CODE=$?
32if [ ${ERR_CODE} -ne 0 ]; then
33	_show_result $TID $ERR_CODE
34fi
35
36BACK_FILE=$(_create_backfile 256M)
37ublk_io_and_kill_daemon 256M -t loop -q 4 "${BACK_FILE}"
38ERR_CODE=$?
39if [ ${ERR_CODE} -ne 0 ]; then
40	_show_result $TID $ERR_CODE
41fi
42
43ublk_io_and_kill_daemon 256M -t loop -q 4 -z "${BACK_FILE}"
44ERR_CODE=$?
45_cleanup_test "stress"
46_remove_backfile "${BACK_FILE}"
47_show_result $TID $ERR_CODE
48