]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: add test case that runs a workload while switching schedulers
authorJens Axboe <axboe@fb.com>
Fri, 5 May 2017 19:39:22 +0000 (13:39 -0600)
committerOmar Sandoval <osandov@fb.com>
Fri, 5 May 2017 22:14:20 +0000 (15:14 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
[Omar: add _test_dev_is_rotational helper, misc cleanup]
Signed-off-by: Omar Sandoval <osandov@fb.com>
common/rc
tests/block/005 [new file with mode: 0755]
tests/block/005.out [new file with mode: 0644]

index 7dce62d1e663d6eaf28624070f968256c55c74a8..1b9d9f7f1e650cb09620759a2b8818e7fe3a11ed 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -69,3 +69,11 @@ _test_dev_can_discard() {
        fi
        return 0
 }
+
+_test_dev_is_rotational() {
+       if [[ $(cat "${TEST_DEV_SYSFS}/queue/rotational") -eq 0 ]]; then
+               SKIP_REASON="$TEST_DEV is not rotational"
+               return 1
+       fi
+       return 1
+}
diff --git a/tests/block/005 b/tests/block/005
new file mode 100755 (executable)
index 0000000..4ae2761
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# Threads doing IO to a device, while we switch schedulers
+#
+# Copyright (C) 2017 Jens Axboe
+#
+# 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 sched)
+
+prepare() {
+       _have_fio
+}
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       scheds=($(sed 's/[][]//g' "${TEST_DEV_SYSFS}/queue/scheduler"))
+
+       if _test_dev_is_rotational; then
+               size="32m"
+       else
+               size="1g"
+       fi
+
+       # start fio job
+       fio --bs=4k --rw=randread --norandommap --name=reads \
+               --filename="$TEST_DEV" --size="$size" --numjobs=8 --direct=1 \
+               >>"$FULL" &
+
+       # while job is running, switch between schedulers
+       while kill -0 $! 2>/dev/null; do
+               idx=$(($RANDOM % ${#scheds[@]}))
+               echo "${scheds[$idx]}" > ${TEST_DEV_SYSFS}/queue/scheduler
+               sleep .2
+       done
+
+       echo "Test complete"
+}
diff --git a/tests/block/005.out b/tests/block/005.out
new file mode 100644 (file)
index 0000000..c72b9b7
--- /dev/null
@@ -0,0 +1,2 @@
+Running block/005
+Test complete