xref: /linux/tools/testing/selftests/ublk/test_generic_17.sh (revision 7fe6ac157b7e15c8976bd62ad7cb98e248884e83)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5
6ERR_CODE=0
7
8_prep_test "fault_inject" "teardown after incomplete recovery"
9
10# First start and stop a ublk server with device configured for recovery
11dev_id=$(_add_ublk_dev -t fault_inject -r 1)
12_check_add_dev $TID $?
13state=$(__ublk_kill_daemon "${dev_id}" "QUIESCED")
14if [ "$state" != "QUIESCED" ]; then
15        echo "device isn't quiesced($state) after $action"
16        ERR_CODE=255
17fi
18
19# Then recover the device, but use --die_during_fetch to have the ublk
20# server die while a queue has some (but not all) I/Os fetched
21${UBLK_PROG} recover -n "${dev_id}" --foreground -t fault_inject --die_during_fetch 1
22RECOVER_RES=$?
23# 137 is the result when dying of SIGKILL
24if (( RECOVER_RES != 137 )); then
25        echo "recover command exited with unexpected code ${RECOVER_RES}!"
26        ERR_CODE=255
27fi
28
29# Clean up the device. This can only succeed once teardown of the above
30# exited ublk server completes. So if teardown never completes, we will
31# time out here
32_ublk_del_dev "${dev_id}"
33
34_cleanup_test "fault_inject"
35_show_result $TID $ERR_CODE
36