]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: apply null_blk helpers
authorGioh Kim <gi-oh.kim@profitbricks.com>
Wed, 4 Jul 2018 10:53:30 +0000 (12:53 +0200)
committerGioh Kim <gi-oh.kim@profitbricks.com>
Wed, 4 Jul 2018 10:53:30 +0000 (12:53 +0200)
use null_blk helpers to load/unload null_blk module

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
tests/block/006
tests/block/010
tests/block/014
tests/block/015
tests/block/016
tests/block/017
tests/block/018
tests/block/020
tests/block/021
tests/block/022

index 2836a1d0508a9b228492eabd2b42cef7236cf30e..02bd924b6ee77285052c032a86177a8ad923b4d0 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run null-blk in blocking mode"
 TIMED=1
 
 requires() {
-       _have_module null_blk && _have_module_param null_blk blocking && _have_fio
+       _have_null_blk && _have_module_param null_blk blocking && _have_fio
 }
 
 test() {
@@ -35,8 +36,7 @@ test() {
        _divide_timeout 2
        FIO_PERF_FIELDS=("read iops")
 
-       modprobe -r null_blk
-       if ! modprobe null_blk queue_mode=2 submit_queues=2 blocking=1; then
+       if ! _init_null_blk queue_mode=2 submit_queues=2 blocking=1; then
                return 1
        fi
 
@@ -49,8 +49,7 @@ test() {
                --rw=randread --norandommap --name=async \
                --filename=/dev/nullb0 --size=5g --direct=1
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index 7f4bf84edadd81a13e3ea21ba16833cd9c78db12..7c73d989fdac066f322a3fa4e0c881164890c524 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run I/O on null_blk with shared and non-shared tags"
 TIMED=1
 
 requires() {
-       _have_module null_blk && _have_module_param null_blk shared_tags && _have_fio
+       _have_null_blk && _have_module_param null_blk shared_tags && _have_fio
 }
 
 run_fio_job() {
@@ -60,8 +61,7 @@ test() {
 
        _divide_timeout 2
 
-       modprobe -r null_blk
-       if ! modprobe null_blk queue_mode=2 submit_queues=16 nr_devices=32; then
+       if ! _init_null_blk queue_mode=2 submit_queues=16 nr_devices=32; then
                return 1
        fi
 
@@ -69,9 +69,8 @@ test() {
        FIO_PERF_FIELDS=("read iops")
        run_fio_job
 
-       udevadm settle
-       modprobe -r null_blk
-       if ! modprobe null_blk queue_mode=2 submit_queues=16 nr_devices=32 shared_tags=1; then
+       _exit_null_blk
+       if ! _init_null_blk queue_mode=2 submit_queues=16 nr_devices=32 shared_tags=1; then
                return 1
        fi
 
@@ -79,7 +78,6 @@ test() {
        FIO_PERF_FIELDS=("read iops")
        run_fio_job
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
        echo "Test complete"
 }
index 7f7798026ae6f6bef495e2c99db6604e871c78a9..5ca58eb2932b5dec112e6f8b9a350e38279aff4d 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run null-blk with blk-mq and timeout injection configured"
 
 requires() {
-       _have_module null-blk && _have_module_param null_blk timeout
+       _have_null_blk && _have_module_param null_blk timeout
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-
        # The format is "<interval>,<probability>,<space>,<times>". Here, we
        # fail 50% of I/Os.
-       modprobe null_blk queue_mode=2 timeout='1,50,0,-1'
+       if ! _init_null_blk queue_mode=2 timeout='1,50,0,-1'; then
+               return 1
+       fi
 
        local scheds
        # shellcheck disable=SC2207
@@ -51,8 +52,7 @@ test() {
                wait
        done
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index 9b0afcd93f92ad2a125f4414571abe153e0c3122..0f770dfc4982280af8edb2fc0d5a563540ec3bf8 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run null-blk on different schedulers with requeue injection configured"
 QUICK=1
 
 requires() {
-       _have_module null-blk && _have_module_param null_blk requeue
+       _have_null_blk && _have_module_param null_blk requeue
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-
        # The format is "<interval>,<probability>,<space>,<times>". Here, we
        # requeue 10% of the time.
-       modprobe null_blk queue_mode=2 requeue='1,10,0,-1'
+       if ! _init_null_blk queue_mode=2 requeue='1,10,0,-1'; then
+               return 1
+       fi
 
        local scheds
        # shellcheck disable=SC2207
@@ -47,8 +48,7 @@ test() {
                        iflag=direct status=none
        done
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index 72150bef11c48db95fecf47ce4f6eb058f338c44..0e6f2e123991471f0882bc241a301c4f44b46b80 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="send a signal to a process waiting on a frozen queue"
 QUICK=1
 
 requires() {
-       _have_module null_blk
+       _have_null_blk
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-
-       modprobe null_blk queue_mode=2 irqmode=2 completion_nsec=2000000000
+       if ! _init_null_blk null_blk queue_mode=2 irqmode=2 completion_nsec=2000000000; then
+               return 1
+       fi
 
        # Start an I/O, which will take two seconds.
        dd if=/dev/nullb0 of=/dev/null bs=512 iflag=direct count=1 status=none &
@@ -53,8 +54,7 @@ test() {
        kill -USR1 $!
        wait
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index c38b6ea097f9beca6296ba14ec592ff32b54b3e6..c7ef8799a301d04d75db408db2663b06c623e56e 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="do I/O and check the inflight counter"
 QUICK=1
 
 requires() {
-       _have_module null_blk
+       _have_null_blk
 }
 
 show_inflight() {
@@ -41,11 +42,10 @@ test() {
        for ((queue_mode = 1; queue_mode <= 2; queue_mode++)) do
                echo "queue mode $queue_mode"
 
-               modprobe -r null_blk
-               modprobe null_blk queue_mode="$queue_mode" irqmode=2 \
-                       completion_nsec=500000000 || continue
-
-               udevadm settle
+               if ! _init_null_blk queue_mode="$queue_mode" irqmode=2 \
+                    completion_nsec=500000000; then
+                       continue
+               fi
 
                dd if=/dev/nullb0 of=/dev/null bs=4096 iflag=direct count=1 status=none &
                sleep 0.1
@@ -58,8 +58,7 @@ test() {
                wait
                show_inflight
 
-               udevadm settle
-               modprobe -r null_blk
+               _exit_null_blk
        done
 
        echo "Test complete"
index 3cf8f8602757de3909172344159cb65367025077..04353507e9b9ff4ab73a5a015429a6ae4a28f2cf 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="do I/O and check iostats times"
 QUICK=1
 
 requires() {
-       _have_module null_blk
+       _have_null_blk
 }
 
 init_times() {
@@ -48,9 +49,10 @@ test() {
 
                echo "queue mode $queue_mode"
 
-               modprobe -r null_blk
-               modprobe null_blk queue_mode="$queue_mode" irqmode=2 \
-                       completion_nsec=1000000000 || continue
+               if ! modprobe null_blk queue_mode="$queue_mode" irqmode=2 \
+                    completion_nsec=1000000000; then
+                       continue
+               fi
 
                udevadm settle
 
@@ -69,8 +71,7 @@ test() {
                wait
                show_times
 
-               udevadm settle
-               modprobe -r null_blk
+               _exit_null_blk
 
                unset init_read_ms init_write_ms read_ms write_ms
        done
index 6fe9ee9e3c3a73d2fc1b7f15056f5d4a4e9381ca..503d200d4013b2d56a987311f95e2f61f9d45a92 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run null-blk on different schedulers with only one hardware tag"
 QUICK=1
 
 requires() {
-       _have_module null_blk && _have_fio
+       _have_null_blk && _have_fio
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-       modprobe null_blk queue_mode=2 irqmode=2 completion_nsec=2000000 \
-               submit_queues=4 hw_queue_depth=1
+       if ! _init_null_blk queue_mode=2 irqmode=2 completion_nsec=2000000 \
+            submit_queues=4 hw_queue_depth=1; then
+               return 1
+       fi
 
        local scheds
        # shellcheck disable=SC2207
@@ -48,8 +50,7 @@ test() {
                        --runtime=10
        done
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index dfdfda22e34f144568581a2eb2610a89db52e518..dd687ada59221fe993d42a30ef88024088698476 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="read/write nr_requests on null-blk with different schedulers"
 QUICK=1
 
 requires() {
-       _have_module null_blk
+       _have_null_blk
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-       modprobe null_blk
+       if ! _init_null_blk; then
+               return 1
+       fi
 
        local max_nr
        local nr
@@ -49,8 +51,7 @@ test() {
                done
        done
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }
index 1cb3ddfd78af2da41e7b396b8014b0a289a3dfd9..f5c460380e4bf8b17704efa2df9002567c4197c1 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . tests/block/rc
+. common/null_blk
 
 DESCRIPTION="run null-blk with legacy blk path and timeout injection configured"
 
 requires() {
-       _have_module null-blk && _have_module_param null_blk timeout
+       _have_null_blk && _have_module_param null_blk timeout
 }
 
 test() {
        echo "Running ${TEST_NAME}"
 
-       modprobe -r null_blk
-
        # The format is "<interval>,<probability>,<space>,<times>". Here, we
        # fail 50% of I/Os.
-       modprobe null_blk queue_mode=1 timeout='1,50,0,-1'
+       if ! _init_null_blk queue_mode=1 timeout='1,50,0,-1'; then
+               return 1
+       fi
 
        local scheds
        # shellcheck disable=SC2207
@@ -51,8 +52,7 @@ test() {
                wait
        done
 
-       udevadm settle
-       modprobe -r null_blk
+       _exit_null_blk
 
        echo "Test complete"
 }