]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: 028: block integrity funtion test
authorMing Lei <ming.lei@redhat.com>
Thu, 17 Jan 2019 03:44:25 +0000 (11:44 +0800)
committerOmar Sandoval <osandov@fb.com>
Tue, 22 Jan 2019 23:21:39 +0000 (15:21 -0800)
Use scsi_debug's dif/dix to cover block layer's integrity function
test, then it can serve as block integrity regeression test.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
[Omar: fix some shellcheck errors]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/block/028 [new file with mode: 0755]
tests/block/028.out [new file with mode: 0644]

diff --git a/tests/block/028 b/tests/block/028
new file mode 100755 (executable)
index 0000000..7bee691
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Ming Lei <ming.lei@redhat.com>
+#
+# Basic DIF/DIX smoke test. Regression test for commit 7809167da5c86fd6
+# ("block: don't lose track of REQ_INTEGRITY flag").
+
+. tests/block/rc
+. common/scsi_debug
+
+DESCRIPTION="do I/O on scsi_debug with DIF/DIX enabled"
+
+requires() {
+       _have_scsi_debug
+}
+
+test_pi() {
+       if ! _init_scsi_debug dev_size_mb=128 dix="$1" dif="$2" delay=0; then
+               return 1
+       fi
+
+       local dev="/dev/${SCSI_DEBUG_DEVICES[0]}"
+       local nr_sects
+       
+       nr_sects="$(blockdev --getsz "$dev")"
+       dd if=/dev/urandom of="$dev" bs=512 count="$nr_sects" status=none
+       dd if="$dev" of=/dev/null bs=512 status=none
+
+       _exit_scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       local dix dif
+       for ((dix = 0; dix <= 1; dix++)); do
+               for ((dif = 0; dif <= 3; dif++)); do
+                       test_pi "$dix" "$dif"
+                       echo "Test(dix:$dix dif:$dif) complete"
+               done
+       done
+
+       rm -f "$FULL"
+}
diff --git a/tests/block/028.out b/tests/block/028.out
new file mode 100644 (file)
index 0000000..d251233
--- /dev/null
@@ -0,0 +1,9 @@
+Running block/028
+Test(dix:0 dif:0) complete
+Test(dix:0 dif:1) complete
+Test(dix:0 dif:2) complete
+Test(dix:0 dif:3) complete
+Test(dix:1 dif:0) complete
+Test(dix:1 dif:1) complete
+Test(dix:1 dif:2) complete
+Test(dix:1 dif:3) complete