]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: stress test device hotplugging
authorOmar Sandoval <osandov@fb.com>
Mon, 1 May 2017 19:31:16 +0000 (12:31 -0700)
committerOmar Sandoval <osandov@fb.com>
Mon, 1 May 2017 19:32:51 +0000 (12:32 -0700)
Based on my old stress_test_scsi_debug.sh script.

Signed-off-by: Omar Sandoval <osandov@fb.com>
common/rc
tests/block/001 [new file with mode: 0755]
tests/block/001.out [new file with mode: 0644]
tests/block/category [new file with mode: 0644]

index 5593993456c337cc0fef28877003d7086c350d5a..9ba3458bafe5b1d12a273b1981b9d536ef1425fa 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -44,6 +44,10 @@ _have_program() {
        fi
 }
 
+_have_scsi_debug() {
+       _have_module scsi-debug
+}
+
 _have_loop() {
        _have_module loop && _have_program losetup
 }
diff --git a/tests/block/001 b/tests/block/001
new file mode 100755 (executable)
index 0000000..1c7ef2f
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# Stress test device hotplugging. Deletes and rescans several scsi-debug
+# devices in parallel. Regression test for commit 165a5e22fafb ("block: Move
+# bdi_unregister() to del_gendisk()").
+#
+# Copyright (C) 2017 Omar Sandoval
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+TEST_GROUPS=(block auto quick hotplug)
+
+prepare() {
+       _have_scsi_debug
+}
+
+stress_scsi_debug() {
+       modprobe -r scsi_debug
+       modprobe scsi_debug "$@"
+
+       targets=()
+       for host in /sys/class/scsi_host/*; do
+               if [[ "$(cat "${host}/proc_name")" = scsi_debug ]]; then
+                       host="$(basename "${host}")"
+                       for target in "/sys/class/scsi_device/${host#host}:"*; do
+                               targets+=("$(basename "${target}")")
+                       done
+               fi
+       done
+
+       for target in "${targets[@]}"; do
+               (
+               host="${target%%:*}"
+               scan="${target#*:}"
+               scan="${scan//:/ }"
+               for ((i = 0; i < 100; i++)); do
+                       echo "${scan}" > "/sys/class/scsi_host/host${host}/scan"
+                       echo 1 > "/sys/class/scsi_device/${target}/device/delete"
+               done
+               ) &
+       done
+       wait
+       modprobe -r scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       echo "Stressing sd"
+       stress_scsi_debug add_host=4 num_tgts=1 ptype=0
+
+       echo "Stressing sr"
+       stress_scsi_debug add_host=4 num_tgts=1 ptype=5
+
+       echo "Test complete"
+}
diff --git a/tests/block/001.out b/tests/block/001.out
new file mode 100644 (file)
index 0000000..a8e968c
--- /dev/null
@@ -0,0 +1,4 @@
+Running block/001
+Stressing sd
+Stressing sr
+Test complete
diff --git a/tests/block/category b/tests/block/category
new file mode 100644 (file)
index 0000000..92d8e56
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Generic block layer tests.
+#
+# Copyright (C) 2017 Omar Sandoval
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. common/rc
+
+prepare() {
+       return 0
+}
+
+prepare_device() {
+       return 0
+}