Skip to content

Commit 6f3faaa

Browse files
authored
Merge pull request #206 from bvanassche/master
Test scsi_debug timeout and abort handling to scsi/007. Also improve common scripts.
2 parents b4a3a24 + 8044f71 commit 6f3faaa

File tree

4 files changed

+84
-21
lines changed

4 files changed

+84
-21
lines changed

common/multipath-over-rdma

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ mpath_has_stale_dev() {
267267
# Check whether multipath definition $1 includes the queue_if_no_path keyword.
268268
is_qinp_def() {
269269
case "$1" in
270-
*" 3 queue_if_no_path queue_mode mq "*)
271-
return 0;;
272-
*" 1 queue_if_no_path "*)
270+
*" queue_if_no_path "*)
273271
return 0;;
274272
*)
275273
return 1;;

common/rc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,35 @@ _have_kernel_config_file() {
198198
return 0
199199
}
200200

201-
# Check if the specified kernel option is defined.
202-
_check_kernel_option() {
203-
local f opt=$1
201+
# Retrieve the value of kernel option $1.
202+
_get_kernel_option() {
203+
local f opt=$1 result
204204

205205
for f in /proc/config.gz /boot/config-$(uname -r); do
206206
[ -e "$f" ] || continue
207-
if zgrep -q "^CONFIG_${opt}=[my]$" "$f"; then
207+
if result=$(zgrep "^CONFIG_${opt}=" "$f"); then
208+
echo "${result#*=}"
208209
return 0
209210
fi
210211
done
211212

212213
return 1
213214
}
214215

216+
# Check if kernel option $1 is defined.
217+
_check_kernel_option() {
218+
local value
219+
220+
case "$(_get_kernel_option "$1")" in
221+
y|m)
222+
return 0;;
223+
esac
224+
225+
return 1
226+
}
227+
215228
# Combine _have_kernel_config_file() and _check_kernel_option().
216-
# Set SKIP_RESAON when _check_kernel_option() returns false.
229+
# Set SKIP_REASONS when _check_kernel_option() returns false.
217230
_have_kernel_option() {
218231
local opt=$1
219232

@@ -343,7 +356,10 @@ _test_dev_queue_set() {
343356
${SYSFS_QUEUE_SAVED["$path"]-unset} == unset ]]; then
344357
SYSFS_QUEUE_SAVED["$path"]="$(_test_dev_queue_get "$1")"
345358
fi
346-
echo "$2" >"$path"
359+
if ! echo "$2" >"$path"; then
360+
echo "echo $2 > $path failed"
361+
return 1
362+
fi
347363
}
348364

349365
_test_dev_set_scheduler() {

common/scsi_debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ _configure_scsi_debug() {
145145
fi
146146
done
147147

148-
# Modify parameters specifeid with key=value arguments
148+
# Modify parameters specified with key=value arguments
149149
for o in "$@"; do
150150
key=${o%=*}
151151
value=${o#*=}

tests/scsi/007

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,45 @@ requires() {
1515
_have_module scsi_debug
1616
}
1717

18-
config_hz() {
19-
if [ -e /proc/config.gz ]; then
20-
zcat /proc/config.gz
21-
else
22-
cat "/boot/config-$(uname -r)"
23-
fi | sed -n 's/^CONFIG_HZ=//p'
18+
start_tracing() {
19+
if [ -e /sys/kernel/tracing/tracing_on ]; then
20+
(
21+
set -e
22+
cd /sys/kernel/tracing
23+
echo 1024 > buffer_size_kb
24+
echo function > current_tracer
25+
echo 0 > tracing_on
26+
echo > trace
27+
{
28+
echo scsi_error_handler
29+
echo "scsi_eh_*"
30+
echo scsi_timeout
31+
echo scsi_try_host_reset
32+
} > set_ftrace_filter
33+
echo 0 > events/enable
34+
echo 1 > tracing_on
35+
)
36+
fi
2437
}
2538

26-
test() {
27-
local dev freq delay_s jdelay
39+
stop_tracing() {
40+
if [ -e /sys/kernel/tracing/tracing_on ]; then
41+
(
42+
set -e
43+
cd /sys/kernel/tracing
44+
cat trace >> "${FULL}"
45+
if ! grep -qw scsi_timeout trace; then
46+
echo "Unexpected: scsi_timeout() has not been called"
47+
fi
48+
echo 0 > tracing_on
49+
)
50+
fi
51+
}
2852

29-
echo "Running ${TEST_NAME}"
53+
run_test() {
54+
set -e
55+
56+
local dev freq delay_s jdelay
3057

3158
if ! _init_scsi_debug; then
3259
return 1
@@ -42,21 +69,43 @@ test() {
4269
echo "I/O timeout = $(<"/sys/class/block/$dev/queue/io_timeout")" >>"$FULL"
4370
# Change the scsi_debug delay to 3 seconds.
4471
delay_s=3
45-
freq=$(config_hz)
72+
freq=$(_get_kernel_option HZ)
4673
jdelay=$((delay_s * "${freq}"))
4774
echo "CONFIG_HZ=${freq} jdelay=${jdelay}" >>"$FULL"
4875
echo "$jdelay" > /sys/module/scsi_debug/parameters/delay
76+
77+
start_tracing
78+
79+
set +e
80+
4981
if dd if="/dev/$dev" of=/dev/null bs=512 count=1 \
5082
iflag=direct >&/dev/null; then
5183
echo "Reading from scsi_debug succeeded"
5284
else
5385
echo "Reading from scsi_debug failed"
5486
fi
5587

88+
stop_tracing
89+
5690
# Disable SCSI error handler logging
5791
echo 0 > /sys/module/scsi_mod/parameters/scsi_logging_level
92+
}
93+
94+
test() {
95+
echo "Running ${TEST_NAME}"
96+
97+
(
98+
run_test
99+
)
100+
# shellcheck disable=SC2181
101+
(($? != 0)) && fail=true
58102

59103
_exit_scsi_debug
60104

61-
echo "Test complete"
105+
if [ -z "$fail" ]; then
106+
echo "Test complete"
107+
else
108+
echo "Test failed"
109+
return 1
110+
fi
62111
}

0 commit comments

Comments
 (0)