All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests 00/15] Add SRP initiator driver tests
@ 2018-06-22 22:19 Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 01/15] common/rc: Fix _have_tracepoint() Bart Van Assche
                   ` (16 more replies)
  0 siblings, 17 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Hello Omar,

As promised during LSF/MM, I have converted the srp-tests software to the
blktests framework. This patch series included all blktests patches I postd
a few days ago. Please consider this patch series for inclusion in the
official blktests repository. Note: this patch series is also available as
a github pull request, namely https://github.com/osandov/blktests/pull/24.

Thanks,

Bart.

Bart Van Assche (15):
  common/rc: Fix _have_tracepoint()
  Annotate include statements in shell scripts where the source file is
    a variable
  check, tests/meta/012: Use array["index"] instead of array[index]
  Suppress shellcheck complaints about global variables
  check: Avoid that shellcheck complains that $FULL appears unused
  Multiple tests: remove unused and undefined variables
  Avoid passing tests/block/002 arguments to _init_scsi_debug
  check: Suppress a shellcheck warning about the DMESG_FILTER
    initialization
  Makefile: Do not suppress useful shellcheck warnings
  tests/meta/group: Fix shellcheck complaints
  make check: Also check tests/*/group files
  check: Make TMPDIR absolute
  src/Makefile: Fix pattern rule
  Add the discontiguous-io test program
  Add tests for the SRP initiator and target drivers

 Makefile                 |   16 +-
 check                    |   53 +-
 common/cpuhotplug        |    2 +
 common/fio               |    2 +
 common/iopoll            |    2 +
 common/loop              |    1 +
 common/nbd               |    2 +
 common/nvme              |    2 +
 common/rc                |    2 +
 common/scsi              |    2 +
 common/scsi_debug        |    3 +
 common/shellcheck        |    4 +
 new                      |    2 +
 src/.gitignore           |    1 +
 src/Makefile             |    6 +-
 src/discontiguous-io.cpp |  340 ++++++++++
 tests/block/001          |    1 +
 tests/block/002          |    3 +-
 tests/block/003          |    2 +
 tests/block/004          |    2 +
 tests/block/005          |    2 +
 tests/block/006          |    2 +
 tests/block/007          |    1 +
 tests/block/009          |    1 +
 tests/block/010          |    2 +
 tests/block/011          |    2 +
 tests/block/012          |    2 +
 tests/block/013          |    2 +
 tests/block/014          |    2 +
 tests/block/015          |    2 +
 tests/block/016          |    2 +
 tests/block/017          |    2 +
 tests/block/018          |    2 +
 tests/block/019          |    2 +
 tests/block/020          |    2 +
 tests/block/021          |    2 +
 tests/loop/001           |    2 +
 tests/loop/003           |    5 +-
 tests/loop/005           |    2 +
 tests/meta/001           |    2 +
 tests/meta/002           |    2 +
 tests/meta/003           |    2 +
 tests/meta/004           |    2 +
 tests/meta/005           |    2 +
 tests/meta/006           |    2 +
 tests/meta/007           |    2 +
 tests/meta/008           |    2 +
 tests/meta/009           |    2 +
 tests/meta/010           |    2 +
 tests/meta/011           |    2 +
 tests/meta/012           |    6 +-
 tests/meta/group         |    6 +-
 tests/nbd/001            |    2 +
 tests/nbd/002            |    2 +
 tests/nvme/001           |    2 +
 tests/nvme/002           |    2 +
 tests/nvme/003           |    2 +
 tests/nvme/004           |    2 +
 tests/nvme/005           |    2 +
 tests/nvme/006           |    2 +
 tests/nvme/007           |    2 +
 tests/nvme/008           |    2 +
 tests/nvme/009           |    2 +
 tests/nvme/010           |    5 +-
 tests/nvme/011           |    5 +-
 tests/nvme/012           |    3 +-
 tests/nvme/013           |    3 +-
 tests/scsi/001           |    2 +
 tests/scsi/002           |    2 +
 tests/scsi/003           |    2 +
 tests/scsi/004           |    1 +
 tests/srp/001            |   72 +++
 tests/srp/001.out        |    8 +
 tests/srp/002            |   50 ++
 tests/srp/002.out        |    7 +
 tests/srp/003            |   51 ++
 tests/srp/003.out        |    7 +
 tests/srp/004            |   51 ++
 tests/srp/004.out        |    7 +
 tests/srp/005            |   41 ++
 tests/srp/005.out        |    7 +
 tests/srp/006            |   41 ++
 tests/srp/006.out        |    7 +
 tests/srp/007            |   41 ++
 tests/srp/007.out        |    7 +
 tests/srp/008            |   40 ++
 tests/srp/008.out        |    7 +
 tests/srp/009            |   41 ++
 tests/srp/009.out        |    7 +
 tests/srp/010            |   41 ++
 tests/srp/010.out        |    7 +
 tests/srp/011            |   45 ++
 tests/srp/011.out        |    7 +
 tests/srp/012            |   53 ++
 tests/srp/012.out        |    8 +
 tests/srp/013            |   49 ++
 tests/srp/013.out        |    8 +
 tests/srp/functions      | 1288 ++++++++++++++++++++++++++++++++++++++
 tests/srp/group          |   37 ++
 99 files changed, 2548 insertions(+), 53 deletions(-)
 create mode 100644 common/shellcheck
 create mode 100644 src/discontiguous-io.cpp
 create mode 100755 tests/srp/001
 create mode 100644 tests/srp/001.out
 create mode 100755 tests/srp/002
 create mode 100644 tests/srp/002.out
 create mode 100755 tests/srp/003
 create mode 100644 tests/srp/003.out
 create mode 100755 tests/srp/004
 create mode 100644 tests/srp/004.out
 create mode 100755 tests/srp/005
 create mode 100644 tests/srp/005.out
 create mode 100755 tests/srp/006
 create mode 100644 tests/srp/006.out
 create mode 100755 tests/srp/007
 create mode 100644 tests/srp/007.out
 create mode 100755 tests/srp/008
 create mode 100644 tests/srp/008.out
 create mode 100755 tests/srp/009
 create mode 100644 tests/srp/009.out
 create mode 100755 tests/srp/010
 create mode 100644 tests/srp/010.out
 create mode 100755 tests/srp/011
 create mode 100644 tests/srp/011.out
 create mode 100755 tests/srp/012
 create mode 100644 tests/srp/012.out
 create mode 100755 tests/srp/013
 create mode 100644 tests/srp/013.out
 create mode 100755 tests/srp/functions
 create mode 100755 tests/srp/group

-- 
2.17.1

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH blktests 01/15] common/rc: Fix _have_tracepoint()
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 02/15] Annotate include statements in shell scripts where the source file is a variable Bart Van Assche
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Make sure that _have_tracepoint() uses the argument passed to that
function instead of using an undefined variable.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 common/rc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/rc b/common/rc
index 7f1728025364..7592400dda82 100644
--- a/common/rc
+++ b/common/rc
@@ -112,6 +112,8 @@ _have_tracefs() {
 }
 
 _have_tracepoint() {
+	local event=$1
+
 	if [[ ! -d /sys/kernel/debug/tracing/events/${event} ]]; then
 		SKIP_REASON="tracepoint ${event} does not exist"
 		return 1
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 02/15] Annotate include statements in shell scripts where the source file is a variable
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 01/15] common/rc: Fix _have_tracepoint() Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 03/15] check, tests/meta/012: Use array["index"] instead of array[index] Bart Van Assche
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This causes shellcheck to stop complaining about these include statements.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 check | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/check b/check
index 4baa8dde2436..5e1ba7bc8401 100755
--- a/check
+++ b/check
@@ -23,6 +23,7 @@ _found_test() {
 
 	unset DESCRIPTION QUICK TIMED requires device_requires test test_device
 
+	# shellcheck disable=SC1090
 	if ! . "tests/${test_name}"; then
 		return 1
 	fi
@@ -392,6 +393,7 @@ _run_test() {
 	CHECK_DMESG=1
 	DMESG_FILTER=cat
 
+	# shellcheck disable=SC1090
 	. "tests/${TEST_NAME}"
 
 	if declare -fF test >/dev/null; then
@@ -432,6 +434,7 @@ _run_group() {
 	local tests=("$@")
 	local group="${tests[0]%/*}"
 
+	# shellcheck disable=SC1090
 	. "tests/${group}/group"
 
 	if declare -fF group_requires >/dev/null && ! group_requires; then
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 03/15] check, tests/meta/012: Use array["index"] instead of array[index]
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 01/15] common/rc: Fix _have_tracepoint() Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 02/15] Annotate include statements in shell scripts where the source file is a variable Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 04/15] Suppress shellcheck complaints about global variables Bart Van Assche
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This causes shellcheck to stop complaining about these array element
accesses.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 check          | 44 ++++++++++++++++++++++----------------------
 tests/meta/012 |  4 ++--
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/check b/check
index 5e1ba7bc8401..1774be4fe1a7 100755
--- a/check
+++ b/check
@@ -156,11 +156,11 @@ declare -A TEST_RUN
 _read_last_test_run() {
 	local seqres="${RESULTS_DIR}/${TEST_NAME}"
 
-	LAST_TEST_RUN[date]=""
-	LAST_TEST_RUN[status]=""
-	LAST_TEST_RUN[reason]=""
-	LAST_TEST_RUN[exit_status]=""
-	LAST_TEST_RUN[runtime]=""
+	LAST_TEST_RUN["date"]=""
+	LAST_TEST_RUN["status"]=""
+	LAST_TEST_RUN["reason"]=""
+	LAST_TEST_RUN["exit_status"]=""
+	LAST_TEST_RUN["runtime"]=""
 
 	if [[ ! -e $seqres ]]; then
 		return
@@ -247,9 +247,9 @@ _output_test_run() {
 	fi
 
 	if [[ -v TEST_DEV ]]; then
-		_output_status "$TEST_NAME => $(basename "$TEST_DEV")" "${TEST_RUN[status]}ed"
+		_output_status "$TEST_NAME => $(basename "$TEST_DEV")" "${TEST_RUN["status"]}ed"
 	else
-		_output_status "$TEST_NAME" "${TEST_RUN[status]}ed"
+		_output_status "$TEST_NAME" "${TEST_RUN["status"]}ed"
 	fi
 
 	(
@@ -306,14 +306,14 @@ _call_test() {
 	_read_last_test_run
 	_output_last_test_run
 
-	TEST_RUN[date]="$(date "+%F %T")"
+	TEST_RUN["date"]="$(date "+%F %T")"
 
 	mkdir -p "$(dirname "$seqres")"
 	# Remove leftovers from last time.
 	rm -f "${seqres}" "${seqres}."*
 
 	if [[ -w /dev/kmsg ]]; then
-		local dmesg_marker="run blktests $TEST_NAME at ${TEST_RUN[date]}"
+		local dmesg_marker="run blktests $TEST_NAME at ${TEST_RUN["date"]}"
 		echo "$dmesg_marker" >> /dev/kmsg
 	else
 		local dmesg_marker=""
@@ -328,35 +328,35 @@ _call_test() {
 	TIMEFORMAT="%Rs"
 	pushd . >/dev/null || return
 	{ time "$test_func" >"${seqres}.out" 2>&1; } 2>"${seqres}.runtime"
-	TEST_RUN[exit_status]=$?
+	TEST_RUN["exit_status"]=$?
 	popd >/dev/null || return
-	TEST_RUN[runtime]="$(cat "${seqres}.runtime")"
+	TEST_RUN["runtime"]="$(cat "${seqres}.runtime")"
 	rm -f "${seqres}.runtime"
 
 	_cleanup
 
 	if ! diff "tests/${TEST_NAME}.out" "${seqres}.out" >/dev/null; then
 		mv "${seqres}.out" "${seqres}.out.bad"
-		TEST_RUN[status]=fail
-		TEST_RUN[reason]=output
-	elif [[ ${TEST_RUN[exit_status]} -ne 0 ]]; then
-		TEST_RUN[status]=fail
-		TEST_RUN[reason]="exit"
+		TEST_RUN["status"]=fail
+		TEST_RUN["reason"]=output
+	elif [[ ${TEST_RUN["exit_status"]} -ne 0 ]]; then
+		TEST_RUN["status"]=fail
+		TEST_RUN["reason"]="exit"
 	elif ! _check_dmesg "$dmesg_marker"; then
-		TEST_RUN[status]=fail
-		TEST_RUN[reason]=dmesg
+		TEST_RUN["status"]=fail
+		TEST_RUN["reason"]=dmesg
 	else
-		TEST_RUN[status]=pass
+		TEST_RUN["status"]=pass
 	fi
 	rm -f "${seqres}.out"
 
 	_write_test_run
 	_output_test_run
 
-	if [[ ${TEST_RUN[status]} = pass ]]; then
+	if [[ ${TEST_RUN["status"]} = pass ]]; then
 		return 0
 	else
-		case "${TEST_RUN[reason]}" in
+		case "${TEST_RUN["reason"]}" in
 		output)
 			diff -u "tests/${TEST_NAME}.out" "${seqres}.out.bad" | awk "
 			{
@@ -369,7 +369,7 @@ _call_test() {
 			}"
 			;;
 		exit)
-			echo "    exited with status ${TEST_RUN[exit_status]}"
+			echo "    exited with status ${TEST_RUN["exit_status"]}"
 			;;
 		dmesg)
 			echo "    something found in dmesg:"
diff --git a/tests/meta/012 b/tests/meta/012
index fcf8fbdde2aa..ab8c2a73eaa5 100755
--- a/tests/meta/012
+++ b/tests/meta/012
@@ -22,8 +22,8 @@ DESCRIPTION="record pid and random junk"
 test() {
 	echo "Running ${TEST_NAME}"
 	sleep 1
-	TEST_RUN[pid]=$$
-	TEST_RUN[random]="$(od -N $((4 * (RANDOM % 4))) -An -vtx1 /dev/urandom | tr -d ' \n')"
+	TEST_RUN["pid"]=$$
+	TEST_RUN["random"]="$(od -N $((4 * (RANDOM % 4))) -An -vtx1 /dev/urandom | tr -d ' \n')"
 	TEST_RUN[$$]=hello
 	echo "Test complete"
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 04/15] Suppress shellcheck complaints about global variables
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (2 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 03/15] check, tests/meta/012: Use array["index"] instead of array[index] Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 05/15] check: Avoid that shellcheck complains that $FULL appears unused Bart Van Assche
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Add a new file common/shellcheck and include it in all test scripts
that use global variables. The file common/shellcheck contains a
statement that stops shellcheck to complain about global variables:

echo "$CHECK_DMESG ${CPUS_ONLINE_SAVED[*]} $DESCRIPTION $DMESG_FILTER $FIO_PERF_FIELDS $FIO_PERF_PREFIX $RESTORE_CPUS_ONLINE $QUICK $SKIP_REASON ${TEST_RUN[*]} $TIMED" >/dev/null

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 common/cpuhotplug | 2 ++
 common/fio        | 2 ++
 common/iopoll     | 2 ++
 common/loop       | 1 +
 common/nbd        | 2 ++
 common/nvme       | 2 ++
 common/scsi       | 2 ++
 common/shellcheck | 4 ++++
 new               | 2 ++
 tests/block/001   | 1 +
 tests/block/002   | 1 +
 tests/block/003   | 2 ++
 tests/block/004   | 2 ++
 tests/block/005   | 2 ++
 tests/block/006   | 2 ++
 tests/block/007   | 1 +
 tests/block/009   | 1 +
 tests/block/010   | 2 ++
 tests/block/011   | 2 ++
 tests/block/012   | 2 ++
 tests/block/013   | 2 ++
 tests/block/014   | 2 ++
 tests/block/015   | 2 ++
 tests/block/016   | 2 ++
 tests/block/017   | 2 ++
 tests/block/018   | 2 ++
 tests/block/019   | 2 ++
 tests/block/020   | 2 ++
 tests/block/021   | 2 ++
 tests/loop/001    | 2 ++
 tests/loop/003    | 2 ++
 tests/loop/005    | 2 ++
 tests/meta/001    | 2 ++
 tests/meta/002    | 2 ++
 tests/meta/003    | 2 ++
 tests/meta/004    | 2 ++
 tests/meta/005    | 2 ++
 tests/meta/006    | 2 ++
 tests/meta/007    | 2 ++
 tests/meta/008    | 2 ++
 tests/meta/009    | 2 ++
 tests/meta/010    | 2 ++
 tests/meta/011    | 2 ++
 tests/meta/012    | 2 ++
 tests/nbd/001     | 2 ++
 tests/nbd/002     | 2 ++
 tests/nvme/001    | 2 ++
 tests/nvme/002    | 2 ++
 tests/nvme/003    | 2 ++
 tests/nvme/004    | 2 ++
 tests/nvme/005    | 2 ++
 tests/nvme/006    | 2 ++
 tests/nvme/007    | 2 ++
 tests/nvme/008    | 2 ++
 tests/nvme/009    | 2 ++
 tests/nvme/010    | 2 ++
 tests/nvme/011    | 2 ++
 tests/nvme/012    | 2 ++
 tests/nvme/013    | 2 ++
 tests/scsi/001    | 2 ++
 tests/scsi/002    | 2 ++
 tests/scsi/003    | 2 ++
 tests/scsi/004    | 1 +
 63 files changed, 122 insertions(+)
 create mode 100644 common/shellcheck

diff --git a/common/cpuhotplug b/common/cpuhotplug
index 70b284f7b7aa..9f43615a8f64 100644
--- a/common/cpuhotplug
+++ b/common/cpuhotplug
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 # Also initializes the ALL_CPUS and HOTPLUGGABLE_CPUS arrays.
 _have_cpu_hotplug() {
 	ALL_CPUS=()
diff --git a/common/fio b/common/fio
index 0f93632c0382..949796810a0c 100644
--- a/common/fio
+++ b/common/fio
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 _have_fio() {
 	if ! _have_program fio; then
 		return 1
diff --git a/common/iopoll b/common/iopoll
index affdd4332dc2..10ebd16923ad 100644
--- a/common/iopoll
+++ b/common/iopoll
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 _have_fio_with_poll() {
 	if ! _have_fio; then
 		return 1
diff --git a/common/loop b/common/loop
index 16cc3212a028..28071840ed9b 100644
--- a/common/loop
+++ b/common/loop
@@ -17,6 +17,7 @@
 # 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/shellcheck
 
 _have_loop_set_block_size() {
 	src/loblksize "$(losetup -f)" 512 &>/dev/null
diff --git a/common/nbd b/common/nbd
index 320f456e0bd8..2e0186482989 100644
--- a/common/nbd
+++ b/common/nbd
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 _have_nbd() {
 	if ! _have_module nbd; then
 		return 1
diff --git a/common/nvme b/common/nvme
index 044d7fe94c65..0060f3e29573 100644
--- a/common/nvme
+++ b/common/nvme
@@ -19,6 +19,8 @@
 
 NVMET_CFS="/sys/kernel/config/nvmet/"
 
+. common/shellcheck
+
 _test_dev_is_nvme() {
 	if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
 		SKIP_REASON="$TEST_DEV is not a NVMe device"
diff --git a/common/scsi b/common/scsi
index d9fcc0e15909..eb5a3ddc708f 100644
--- a/common/scsi
+++ b/common/scsi
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 _have_scsi_generic() {
 	_have_module sg
 }
diff --git a/common/shellcheck b/common/shellcheck
new file mode 100644
index 000000000000..1ec759976dd7
--- /dev/null
+++ b/common/shellcheck
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Suppress shellcheck complaints about global variables used in test scripts.
+echo "$CHECK_DMESG ${CPUS_ONLINE_SAVED[*]} $DESCRIPTION $DMESG_FILTER $FIO_PERF_FIELDS $FIO_PERF_PREFIX $RESTORE_CPUS_ONLINE $QUICK $SKIP_REASON ${TEST_RUN[*]} $TIMED" >/dev/null
diff --git a/new b/new
index 923d6b737986..334092498c52 100755
--- a/new
+++ b/new
@@ -159,6 +159,8 @@ cat << EOF > "tests/${test_name}"
 # 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/shellcheck
+
 # TODO: fill in a very brief description of what this test does. The
 # description should complete the sentence "This test will...". For example,
 # "run a mixed read/write workload" would be a good description.
diff --git a/tests/block/001 b/tests/block/001
index 7411a0cf04f6..8016265d11e3 100755
--- a/tests/block/001
+++ b/tests/block/001
@@ -20,6 +20,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . common/scsi_debug
+. common/shellcheck
 
 DESCRIPTION="stress device hotplugging"
 TIMED=1
diff --git a/tests/block/002 b/tests/block/002
index 57b4f8984095..32a0f818b95b 100755
--- a/tests/block/002
+++ b/tests/block/002
@@ -19,6 +19,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . common/scsi_debug
+. common/shellcheck
 
 DESCRIPTION="remove a device while running blktrace"
 QUICK=1
diff --git a/tests/block/003 b/tests/block/003
index 87e30a36e8c2..e73e4fc60fbe 100755
--- a/tests/block/003
+++ b/tests/block/003
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run various discard sizes"
 TIMED=1
 
diff --git a/tests/block/004 b/tests/block/004
index 754d30260d63..59e157b1c337 100755
--- a/tests/block/004
+++ b/tests/block/004
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run lots of flushes"
 TIMED=1
 
diff --git a/tests/block/005 b/tests/block/005
index fae59272f90b..2e6dd38cc931 100755
--- a/tests/block/005
+++ b/tests/block/005
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="switch schedulers while doing IO"
 TIMED=1
 
diff --git a/tests/block/006 b/tests/block/006
index 0a472935a481..be4b6c7560b3 100755
--- a/tests/block/006
+++ b/tests/block/006
@@ -20,6 +20,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run null-blk in blocking mode"
 TIMED=1
 
diff --git a/tests/block/007 b/tests/block/007
index e35649ad96cd..15709fffd4fd 100755
--- a/tests/block/007
+++ b/tests/block/007
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . common/iopoll
+. common/shellcheck
 
 DESCRIPTION="test classic and hybrid IO polling"
 TIMED=1
diff --git a/tests/block/009 b/tests/block/009
index cbeeb70701fa..7d6afe9694eb 100755
--- a/tests/block/009
+++ b/tests/block/009
@@ -22,6 +22,7 @@
 DESCRIPTION="check page-cache coherency after BLKDISCARD"
 
 . common/scsi_debug
+. common/shellcheck
 
 requires() {
 	_have_scsi_debug && _have_program xfs_io
diff --git a/tests/block/010 b/tests/block/010
index 97891d229c0f..bbe714101aee 100644
--- a/tests/block/010
+++ b/tests/block/010
@@ -20,6 +20,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run I/O on null_blk with shared and non-shared tags"
 TIMED=1
 
diff --git a/tests/block/011 b/tests/block/011
index 24614420461e..ab02f90f2069 100755
--- a/tests/block/011
+++ b/tests/block/011
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="disable PCI device while doing I/O"
 TIMED=1
 
diff --git a/tests/block/012 b/tests/block/012
index baabdd68b655..2c1b761ba063 100755
--- a/tests/block/012
+++ b/tests/block/012
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="check that a read-only block device fails writes"
 TIMED=1
 
diff --git a/tests/block/013 b/tests/block/013
index 415b34dcc5ef..8f386313cd2b 100755
--- a/tests/block/013
+++ b/tests/block/013
@@ -23,6 +23,8 @@
 # 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/shellcheck
+
 DESCRIPTION="try BLKRRPART on a mounted device"
 QUICK=1
 
diff --git a/tests/block/014 b/tests/block/014
index 882a9b9f5015..f5503ee9683c 100755
--- a/tests/block/014
+++ b/tests/block/014
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run null-blk with timeout injection configured"
 
 requires() {
diff --git a/tests/block/015 b/tests/block/015
index b236a6d36bf8..0c9daa6be13e 100755
--- a/tests/block/015
+++ b/tests/block/015
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run null-blk on different schedulers with requeue injection configured"
 
 QUICK=1
diff --git a/tests/block/016 b/tests/block/016
index 6ccfe98f54ce..5a1ff33c34fb 100755
--- a/tests/block/016
+++ b/tests/block/016
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="send a signal to a process waiting on a frozen queue"
 QUICK=1
 
diff --git a/tests/block/017 b/tests/block/017
index 436a8f336155..e9ca282750ba 100755
--- a/tests/block/017
+++ b/tests/block/017
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="do I/O and check the inflight counter"
 QUICK=1
 
diff --git a/tests/block/018 b/tests/block/018
index 548f1baeaf59..21421b869c18 100755
--- a/tests/block/018
+++ b/tests/block/018
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="do I/O and check iostats times"
 QUICK=1
 
diff --git a/tests/block/019 b/tests/block/019
index 00830d02b67a..f099d9392688 100755
--- a/tests/block/019
+++ b/tests/block/019
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="break PCI link device while doing I/O"
 QUICK=1
 
diff --git a/tests/block/020 b/tests/block/020
index 36140136369b..7db1b5a0d422 100755
--- a/tests/block/020
+++ b/tests/block/020
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="run null-blk on different schedulers with only one hardware tag"
 QUICK=1
 
diff --git a/tests/block/021 b/tests/block/021
index 74fa709a8e04..df5dc9b101ba 100755
--- a/tests/block/021
+++ b/tests/block/021
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="read/write nr_requests on null-blk with different schedulers"
 QUICK=1
 
diff --git a/tests/loop/001 b/tests/loop/001
index 1f009bdd1439..83103dc5e9c9 100755
--- a/tests/loop/001
+++ b/tests/loop/001
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="scan loop device partitions"
 QUICK=1
 
diff --git a/tests/loop/003 b/tests/loop/003
index fe4e2e1ed19b..353d4fcfa33c 100755
--- a/tests/loop/003
+++ b/tests/loop/003
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="time opening and closing an unbound loop device"
 QUICK=1
 
diff --git a/tests/loop/005 b/tests/loop/005
index b57ddb3d6f1a..d00f4bd06f73 100755
--- a/tests/loop/005
+++ b/tests/loop/005
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="call LOOP_GET_STATUS{,64} with a NULL arg"
 
 QUICK=1
diff --git a/tests/meta/001 b/tests/meta/001
index 454fb22554a3..d5b8c0665f7b 100755
--- a/tests/meta/001
+++ b/tests/meta/001
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="do nothing"
 
 test() {
diff --git a/tests/meta/002 b/tests/meta/002
index 5a2cd53f2318..50cdd5a3487c 100755
--- a/tests/meta/002
+++ b/tests/meta/002
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="do nothing"
 
 test_device() {
diff --git a/tests/meta/003 b/tests/meta/003
index eb79bca15ffb..e07e01efd697 100755
--- a/tests/meta/003
+++ b/tests/meta/003
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="exit with non-zero status"
 
 test() {
diff --git a/tests/meta/004 b/tests/meta/004
index bafe6c5e8da8..37d0e4649d56 100755
--- a/tests/meta/004
+++ b/tests/meta/004
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="exit with non-zero status"
 
 test_device() {
diff --git a/tests/meta/005 b/tests/meta/005
index c9909c64c022..1a4018af2d21 100755
--- a/tests/meta/005
+++ b/tests/meta/005
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="produce bad output"
 
 test() {
diff --git a/tests/meta/006 b/tests/meta/006
index 9d28bdce01d8..4d0786177555 100755
--- a/tests/meta/006
+++ b/tests/meta/006
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="produce lots of bad output"
 
 test() {
diff --git a/tests/meta/007 b/tests/meta/007
index 2516796a333d..13acfdb8ef42 100755
--- a/tests/meta/007
+++ b/tests/meta/007
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="skip in requires()"
 
 requires() {
diff --git a/tests/meta/008 b/tests/meta/008
index 5d24669b290e..acea355c4d91 100755
--- a/tests/meta/008
+++ b/tests/meta/008
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="skip in device_requires()"
 
 device_requires() {
diff --git a/tests/meta/009 b/tests/meta/009
index abeb56e6ad4f..989ce8ccf053 100755
--- a/tests/meta/009
+++ b/tests/meta/009
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="check dmesg"
 
 requires() {
diff --git a/tests/meta/010 b/tests/meta/010
index c179dad3d7c7..1e7e9da7d3fa 100755
--- a/tests/meta/010
+++ b/tests/meta/010
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="disable check dmesg"
 CHECK_DMESG=0
 
diff --git a/tests/meta/011 b/tests/meta/011
index 010ba4b142b8..df1f7e584622 100755
--- a/tests/meta/011
+++ b/tests/meta/011
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="filter dmesg"
 DMESG_FILTER="grep -v BUG"
 
diff --git a/tests/meta/012 b/tests/meta/012
index ab8c2a73eaa5..ecc1db296f32 100755
--- a/tests/meta/012
+++ b/tests/meta/012
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 DESCRIPTION="record pid and random junk"
 
 test() {
diff --git a/tests/nbd/001 b/tests/nbd/001
index 73ccaec1305a..cee62412599a 100644
--- a/tests/nbd/001
+++ b/tests/nbd/001
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="resize a connected nbd device"
 QUICK=1
 
diff --git a/tests/nbd/002 b/tests/nbd/002
index c06c94631aab..6d6b3cddf1c6 100644
--- a/tests/nbd/002
+++ b/tests/nbd/002
@@ -24,6 +24,8 @@
 # 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/shellcheck
+
 DESCRIPTION="tests on partition handling for an nbd device"
 QUICK=1
 
diff --git a/tests/nvme/001 b/tests/nvme/001
index 0b5f241efcce..ada60f3b2270 100755
--- a/tests/nvme/001
+++ b/tests/nvme/001
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="enable nvme_setup_nvm_cmd tracepoint and submit I/O to the device"
 
 QUICK=1
diff --git a/tests/nvme/002 b/tests/nvme/002
index 786505e22256..59474f7d7574 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="create many subsystems and test discovery"
 
 requires() {
diff --git a/tests/nvme/003 b/tests/nvme/003
index 96341309baf6..9b168cb48278 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="test if we're sending keep-alives to a discovery controller"
 
 QUICK=1
diff --git a/tests/nvme/004 b/tests/nvme/004
index ad268e2eec83..9d087266bfa1 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -19,6 +19,8 @@
 # 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/shellcheck
+
 DESCRIPTION="test nvme and nvmet UUID NS descriptors"
 QUICK=1
 
diff --git a/tests/nvme/005 b/tests/nvme/005
index f993019aa1d4..5c582bc38707 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="reset local loopback target"
 
 QUICK=1
diff --git a/tests/nvme/006 b/tests/nvme/006
index ecf0c334ae8b..ebdd50f61ff3 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF target with a block device-backed ns"
 QUICK=1
 
diff --git a/tests/nvme/007 b/tests/nvme/007
index 02633131b868..138bfead51bb 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF target with a file-backed ns"
 QUICK=1
 
diff --git a/tests/nvme/008 b/tests/nvme/008
index dd62b25c5335..3b69809bb8fa 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF host with a block device-backed ns"
 QUICK=1
 
diff --git a/tests/nvme/009 b/tests/nvme/009
index 0372788fef39..311e8171ca70 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF host with a file-backed ns"
 QUICK=1
 
diff --git a/tests/nvme/010 b/tests/nvme/010
index 9b31167c4988..956c6597a374 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
diff --git a/tests/nvme/011 b/tests/nvme/011
index 6cd20fa26855..872a99af4f8c 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
diff --git a/tests/nvme/012 b/tests/nvme/012
index 255101101a18..8f632b30734d 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
diff --git a/tests/nvme/013 b/tests/nvme/013
index 4bb49fa8f966..0ccb083b175b 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
diff --git a/tests/scsi/001 b/tests/scsi/001
index 17fc0880e654..08ad78489e0f 100755
--- a/tests/scsi/001
+++ b/tests/scsi/001
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="try triggering a kernel GPF with 0 byte SG reads"
 QUICK=1
 
diff --git a/tests/scsi/002 b/tests/scsi/002
index da2d0cc77aa0..ce037f0bbe79 100755
--- a/tests/scsi/002
+++ b/tests/scsi/002
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="perfom a SG_DXFER_FROM_DEV from the /dev/sg read-write interface"
 QUICK=1
 
diff --git a/tests/scsi/003 b/tests/scsi/003
index 81015f02f6b3..8c08cbdfe6a5 100755
--- a/tests/scsi/003
+++ b/tests/scsi/003
@@ -18,6 +18,8 @@
 # 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/shellcheck
+
 DESCRIPTION="ensure re-reading the partition table keeps its read-only flag"
 QUICK=1
 
diff --git a/tests/scsi/004 b/tests/scsi/004
index 8c61d1e438f3..8bebb18d2554 100755
--- a/tests/scsi/004
+++ b/tests/scsi/004
@@ -26,6 +26,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . common/scsi_debug
+. common/shellcheck
 
 DESCRIPTION="ensure repeated TASK SET FULL results in EIO on timing out command"
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 05/15] check: Avoid that shellcheck complains that $FULL appears unused
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (3 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 04/15] Suppress shellcheck complaints about global variables Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 06/15] Multiple tests: remove unused and undefined variables Bart Van Assche
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

$FULL is a global variable. Avoid that shellcheck complains about it.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 check | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/check b/check
index 1774be4fe1a7..d9ffea6ec1f6 100755
--- a/check
+++ b/check
@@ -301,6 +301,8 @@ _call_test() {
 	local test_func="$1"
 	local seqres="${RESULTS_DIR}/${TEST_NAME}"
 	FULL="${seqres}.full"
+	# Avoid that shellcheck complains that $FULL appears unused.
+	echo "$FULL" >/dev/null
 	declare -A TEST_DEV_QUEUE_SAVED
 
 	_read_last_test_run
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 06/15] Multiple tests: remove unused and undefined variables
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (4 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 05/15] check: Avoid that shellcheck complains that $FULL appears unused Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 07/15] Avoid passing tests/block/002 arguments to _init_scsi_debug Bart Van Assche
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 tests/loop/003 | 3 ---
 tests/nvme/010 | 3 +--
 tests/nvme/011 | 3 +--
 tests/nvme/012 | 1 -
 tests/nvme/013 | 1 -
 5 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/tests/loop/003 b/tests/loop/003
index 353d4fcfa33c..6f6fa8d18ebe 100755
--- a/tests/loop/003
+++ b/tests/loop/003
@@ -28,11 +28,8 @@ requires() {
 }
 
 test() {
-	local loop_dev
 	echo "Running ${TEST_NAME}"
 
-	loop_dev="$(losetup -f)"
-
 	# In a subshell so TIMEFORMAT doesn't get clobbered.
 	(
 	TIMEFORMAT="Test took %0R seconds"
diff --git a/tests/nvme/010 b/tests/nvme/010
index 956c6597a374..b6849dbad375 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -38,7 +38,6 @@ test() {
 	modprobe nvme-loop
 
 	local port
-	local ret=0
 	local nvmedev
 	local loop_dev
 	local file_path="${TMPDIR}/img"
@@ -70,7 +69,7 @@ test() {
 	losetup -d "${loop_dev}"
 
 	rm "${file_path}"
-	rm -f local*verify*state "${fio_out}"
+	rm -f local*verify*state
 
 	modprobe -r nvme_loop
 	modprobe -r nvmet
diff --git a/tests/nvme/011 b/tests/nvme/011
index 872a99af4f8c..f26eb155809c 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -37,7 +37,6 @@ test() {
 	modprobe nvme-loop
 
 	local port
-	local ret=0
 	local nvmedev
 	local file_path
 	local file_path="${TMPDIR}/img"
@@ -65,7 +64,7 @@ test() {
 	_remove_nvmet_port "${port}"
 
 	rm "${file_path}"
-	rm -f local-write-and-verify*state "${fio_out}"
+	rm -f local-write-and-verify*state
 
 	modprobe -r nvme_loop
 	modprobe -r nvmet
diff --git a/tests/nvme/012 b/tests/nvme/012
index 8f632b30734d..e570793dd5db 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -38,7 +38,6 @@ test() {
 	modprobe nvme-loop
 
 	local port
-	local ret=0
 	local nvmedev
 	local loop_dev
 	local mount_dir="/mnt/blktests"
diff --git a/tests/nvme/013 b/tests/nvme/013
index 0ccb083b175b..247fe9f252fa 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -38,7 +38,6 @@ test() {
 	modprobe nvme-loop
 
 	local port
-	local ret=0
 	local nvmedev
 	local mount_dir="/mnt/blktests/"
 	local file_path="${TMPDIR}/img"
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 07/15] Avoid passing tests/block/002 arguments to _init_scsi_debug
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (5 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 06/15] Multiple tests: remove unused and undefined variables Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 08/15] check: Suppress a shellcheck warning about the DMESG_FILTER initialization Bart Van Assche
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This patch avoids that shellcheck reports the following:

tests/block/002:34:7: note: Use _init_scsi_debug "$@" if function's $1 should mean script's $1. [SC2119]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 common/scsi_debug | 3 +++
 tests/block/002   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/scsi_debug b/common/scsi_debug
index e26e85637369..d8e6b71899a3 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -21,7 +21,10 @@ _have_scsi_debug() {
 	_have_module scsi_debug
 }
 
+# The _init_scsi_debug() argument list is passed to modprobe scsi_debug. "--"
+# is filtered out from the start of the argument list.
 _init_scsi_debug() {
+	[ "$1" = "--" ] && shift
 	if ! modprobe -r scsi_debug || ! modprobe scsi_debug "$@"; then
 		return 1
 	fi
diff --git a/tests/block/002 b/tests/block/002
index 32a0f818b95b..10e3f157c018 100755
--- a/tests/block/002
+++ b/tests/block/002
@@ -31,7 +31,7 @@ requires() {
 test() {
 	echo "Running ${TEST_NAME}"
 
-	if ! _init_scsi_debug; then
+	if ! _init_scsi_debug --; then
 		return 1
 	fi
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 08/15] check: Suppress a shellcheck warning about the DMESG_FILTER initialization
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (6 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 07/15] Avoid passing tests/block/002 arguments to _init_scsi_debug Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 09/15] Makefile: Do not suppress useful shellcheck warnings Bart Van Assche
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Avoid that shellcheck reports the following:

check:396:2: warning: Use var=$(command) to assign output (or quote to assign string). [SC2209]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check b/check
index d9ffea6ec1f6..cf2090f546a5 100755
--- a/check
+++ b/check
@@ -393,7 +393,7 @@ _call_test() {
 _run_test() {
 	TEST_NAME="$1"
 	CHECK_DMESG=1
-	DMESG_FILTER=cat
+	DMESG_FILTER="cat"
 
 	# shellcheck disable=SC1090
 	. "tests/${TEST_NAME}"
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 09/15] Makefile: Do not suppress useful shellcheck warnings
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (7 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 08/15] check: Suppress a shellcheck warning about the DMESG_FILTER initialization Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 10/15] tests/meta/group: Fix shellcheck complaints Bart Van Assche
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

All the shellcheck warnings that are currently suppressed are useful.
Additionally, it is easy to avoid false positives for the currently
suppressed categories of shellcheck warnings. Hence stop suppressing
shellcheck warnings. See also commit 17a59e0dc212 ("Fix all shellcheck
warnings").

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 Makefile | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 14ba8341dae5..c4bffa2d3f32 100644
--- a/Makefile
+++ b/Makefile
@@ -4,21 +4,8 @@ all:
 clean:
 	$(MAKE) -C src clean
 
-# SC1090: "Can't follow non-constant source". We use variable sources all over
-# the place.
-# SC2034: "VARIABLE appears unused". All test scripts use this for the test
-# metadata, and many helper functions define global variables.
-# SC2119: "Use foo "$@" if function's $1 should mean script's $1". False
-# positives on helpers like _init_scsi_debug.
-# SC2154: "VARIABLE is referenced but not assigned". False positives on
-# TEST_RUN[foo]=bar.
-# SC2209: "Use var=$(command) to assign output (or quote to assign string)".
-# Warns about DMESG_FILTER=cat, which is not going to confuse anyone who knows
-# how to write shell scripts.
-SHELLCHECK_EXCLUDE := SC1090,SC2034,SC2119,SC2154,SC2209
-
 check:
-	shellcheck -x -e $(SHELLCHECK_EXCLUDE) -f gcc check new common/* tests/*/[0-9]*[0-9]
+	shellcheck -x -f gcc check new common/* tests/*/[0-9]*[0-9]
 	! grep TODO tests/*/[0-9]*[0-9]
 
 .PHONY: all check
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 10/15] tests/meta/group: Fix shellcheck complaints
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (8 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 09/15] Makefile: Do not suppress useful shellcheck warnings Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 11/15] make check: Also check tests/*/group files Bart Van Assche
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Avoid that shellcheck complains about unused global variables.
Avoid that shellcheck complains about using cat instead of
redirection.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 tests/meta/group | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/meta/group b/tests/meta/group
index 4281ea175a78..bae91281c493 100644
--- a/tests/meta/group
+++ b/tests/meta/group
@@ -17,6 +17,8 @@
 # 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/shellcheck
+
 group_requires() {
 	if [[ -v META_REQUIRES_SKIP ]]; then
 		SKIP_REASON="META_REQUIRES_SKIP was set"
@@ -76,7 +78,7 @@ RIP: blk_dev_init+0x4/0x6 RSP: ffffc9000031fe70
 ---[ end trace d9ab35f734a89f58 ]---
 EOF
 
-	cat "$TMPDIR/dmesg" | while IFS= read -r line; do
+	while IFS= read -r line; do
 		echo "$line" >> /dev/kmsg
-	done
+	done < "$TMPDIR/dmesg"
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 11/15] make check: Also check tests/*/group files
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (9 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 10/15] tests/meta/group: Fix shellcheck complaints Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 12/15] check: Make TMPDIR absolute Bart Van Assche
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index c4bffa2d3f32..8031d2ed0eca 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ clean:
 	$(MAKE) -C src clean
 
 check:
-	shellcheck -x -f gcc check new common/* tests/*/[0-9]*[0-9]
+	shellcheck -x -f gcc check new common/* tests/*/group \
+	    tests/*/[0-9]*[0-9]
 	! grep TODO tests/*/[0-9]*[0-9]
 
 .PHONY: all check
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 12/15] check: Make TMPDIR absolute
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (10 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 11/15] make check: Also check tests/*/group files Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 13/15] src/Makefile: Fix pattern rule Bart Van Assche
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This avoids that ${TMPDIR} gets misinterpreted if a test script
modifies the working directory.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check b/check
index cf2090f546a5..a7dd825ad03a 100755
--- a/check
+++ b/check
@@ -323,7 +323,7 @@ _call_test() {
 	fi
 
 	trap _cleanup EXIT
-	if ! TMPDIR="$(mktemp --tmpdir -p results -d "tmpdir.${TEST_NAME//\//.}.XXX")"; then
+	if ! TMPDIR="$(mktemp --tmpdir -p "$PWD/results" -d "tmpdir.${TEST_NAME//\//.}.XXX")"; then
 		return
 	fi
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 13/15] src/Makefile: Fix pattern rule
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (11 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 12/15] check: Make TMPDIR absolute Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-25 22:54   ` Omar Sandoval
  2018-06-22 22:19 ` [PATCH blktests 14/15] Add the discontiguous-io test program Bart Van Assche
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

According to the GNU make documentation, the syntax for pattern rules
is as follows:

<target pattern>+: <source pattern>
	<rule>

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile b/src/Makefile
index 612282d14af8..d7ae832fc4fd 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,7 +13,7 @@ all: $(TARGETS)
 clean:
 	rm -f $(TARGETS)
 
-$(TARGETS): %: %.c
+%: %.c
 	$(CC) -Wall -o $@ $(CPPFLAGS) $(CFLAGS) $^
 
 .PHONY: all clean
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 14/15] Add the discontiguous-io test program
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (12 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 13/15] src/Makefile: Fix pattern rule Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-22 22:19 ` [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers Bart Van Assche
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This test program is used by one of the srp tests.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 src/.gitignore           |   1 +
 src/Makefile             |   4 +
 src/discontiguous-io.cpp | 340 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 345 insertions(+)
 create mode 100644 src/discontiguous-io.cpp

diff --git a/src/.gitignore b/src/.gitignore
index 68da6e6fa69e..d0400392538b 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,4 @@
+/discontiguous-io
 /loblksize
 /loop_get_status_null
 /openclose
diff --git a/src/Makefile b/src/Makefile
index d7ae832fc4fd..57e7126eb2a4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,5 @@
 TARGETS := \
+	discontiguous-io \
 	loblksize \
 	loop_get_status_null \
 	openclose \
@@ -16,4 +17,7 @@ clean:
 %: %.c
 	$(CC) -Wall -o $@ $(CPPFLAGS) $(CFLAGS) $^
 
+%: %.cpp
+	$(CXX) -Wall -Wextra -Wno-sign-compare -Werror -o $@ $(CPPFLAGS) $(CFLAGS) $^
+
 .PHONY: all clean
diff --git a/src/discontiguous-io.cpp b/src/discontiguous-io.cpp
new file mode 100644
index 000000000000..3761cc605576
--- /dev/null
+++ b/src/discontiguous-io.cpp
@@ -0,0 +1,340 @@
+// Copyright (c) 2015 SanDisk Corporation
+// Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+//
+// 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 2
+// 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, write to the Free Software
+// Foundation, Inc.
+
+#include <cassert>
+#include <cstring>     // memset()
+#include <fcntl.h>     // O_RDONLY
+#include <iomanip>
+#include <iostream>
+#include <linux/fs.h>  // BLKSSZGET
+#include <scsi/sg.h>   // sg_io_hdr_t
+#include <sys/ioctl.h>
+#include <unistd.h>    // open()
+#include <vector>
+
+class file_descriptor {
+public:
+	file_descriptor(int fd = -1)
+		: m_fd(fd)
+	{ }
+	~file_descriptor()
+	{ if (m_fd >= 0) close(m_fd); }
+	operator int() const
+	{ return m_fd; }
+
+private:
+	file_descriptor(const file_descriptor &);
+	file_descriptor &operator=(const file_descriptor &);
+
+	int m_fd;
+};
+
+class iovec_t {
+public:
+	iovec_t()
+	{ }
+	~iovec_t()
+	{ }
+	size_t size() const
+	{ return m_v.size(); }
+	const sg_iovec_t& operator[](const int i) const
+	{ return m_v[i]; }
+	sg_iovec_t& operator[](const int i)
+	{ return m_v[i]; }
+	void append(void *addr, size_t len) {
+		m_v.resize(m_v.size() + 1);
+		auto p = m_v.end() - 1;
+		p->iov_base = addr;
+		p->iov_len = len;
+	}
+	const void *address() const {
+		return &*m_v.begin();
+	}
+	size_t data_len() const {
+		size_t len = 0;
+		for (auto p = m_v.begin(); p != m_v.end(); ++p)
+			len += p->iov_len;
+		return len;
+	}
+	void trunc(size_t len) {
+		size_t s = 0;
+		for (auto p = m_v.begin(); p != m_v.end(); ++p) {
+			s += p->iov_len;
+			if (s >= len) {
+				p->iov_len -= s - len;
+				assert(p->iov_len > 0 ||
+				       (p->iov_len == 0 && len == 0));
+				m_v.resize(p - m_v.begin() + 1);
+				break;
+			}
+		}
+	}
+	std::ostream& write(std::ostream& os) const {
+		for (auto p = m_v.begin(); p != m_v.end(); ++p)
+			os.write((const char *)p->iov_base, p->iov_len);
+		return os;
+	}
+
+private:
+	iovec_t(const iovec_t &);
+	iovec_t &operator=(const iovec_t &);
+
+	std::vector<sg_iovec_t> m_v;
+};
+
+static unsigned block_size;
+
+static void dumphex(std::ostream &os, const void *a, size_t len)
+{
+	for (int i = 0; i < len; i += 16) {
+		os << std::hex << std::setfill('0') << std::setw(16)
+		   << (uintptr_t)a + i << ':';
+		for (int j = i; j < i + 16 && j < len; j++) {
+			if (j % 4 == 0)
+				os << ' ';
+			os << std::hex << std::setfill('0') << std::setw(2)
+			   << (unsigned)((uint8_t*)a)[j];
+		}
+		os << "  ";
+		for (int j = i; j < i + 16 && j < len; j++) {
+			unsigned char c = ((uint8_t*)a)[j];
+			os << (c >= ' ' && c < 128 ? (char)c : '.');
+		}
+		os << '\n';
+	}
+}
+
+enum {
+	MAX_READ_WRITE_6_LBA = 0x1fffff,
+	MAX_READ_WRITE_6_LENGTH = 0xff,
+};
+
+static ssize_t sg_read(const file_descriptor &fd, uint32_t lba,
+		       const iovec_t &v)
+{
+	if (lba > MAX_READ_WRITE_6_LBA)
+		return -1;
+
+	if (v.data_len() == 0 || (v.data_len() % block_size) != 0)
+		return -1;
+
+	if (v.data_len() / block_size > MAX_READ_WRITE_6_LENGTH)
+		return -1;
+
+	int sg_version;
+	if (ioctl(fd, SG_GET_VERSION_NUM, &sg_version) < 0 ||
+	    sg_version < 30000)
+		return -1;
+
+	uint8_t read6[6] = {
+		0x08, (uint8_t)(lba >> 16), (uint8_t)(lba >> 8),
+		(uint8_t)(lba), (uint8_t)(v.data_len() / block_size),
+		0
+	};
+	unsigned char sense_buffer[32];
+	sg_io_hdr_t h;
+
+	memset(&h, 0, sizeof(h));
+	h.interface_id = 'S';
+	h.cmdp = read6;
+	h.cmd_len = sizeof(read6);
+	h.dxfer_direction = SG_DXFER_FROM_DEV;
+	h.iovec_count = v.size();
+	h.dxfer_len = v.data_len();
+	h.dxferp = const_cast<void*>(v.address());
+	h.sbp = sense_buffer;
+	h.mx_sb_len = sizeof(sense_buffer);
+	h.timeout = 1000;     /* 1000 millisecs == 1 second */
+	if (ioctl(fd, SG_IO, &h) < 0) {
+		std::cerr << "READ(6) ioctl failed with errno " << errno
+			  << '\n';
+		return -1;
+	}
+	uint32_t result = h.status | (h.msg_status << 8) |
+		(h.host_status << 16) | (h.driver_status << 24);
+	if (result) {
+		std::cerr << "READ(6) failed with status 0x" << std::hex
+			  << result << "\n";
+		if (h.status == 2) {
+			std::cerr << "Sense buffer:\n";
+			dumphex(std::cerr, sense_buffer, h.sb_len_wr);
+		}
+		return -1;
+	}
+	return v.data_len() - h.resid;
+}
+
+static ssize_t sg_write(const file_descriptor &fd, uint32_t lba,
+			const iovec_t &v)
+{
+	if (lba > MAX_READ_WRITE_6_LBA)
+		return -1;
+
+	if (v.data_len() == 0) {
+		std::cerr << "Write buffer is empty.\n";
+		return -1;
+	}
+
+	if ((v.data_len() % block_size) != 0) {
+		std::cerr << "Write buffer size " << v.data_len()
+			  << " is not a multiple of the block size "
+			  << block_size << ".\n";
+		return -1;
+	}
+
+	if (v.data_len() / block_size > MAX_READ_WRITE_6_LENGTH) {
+		std::cerr << "Write buffer size " << v.data_len()
+			  << " > " << MAX_READ_WRITE_6_LENGTH << ".\n";
+		return -1;
+	}
+
+	int sg_version;
+	if (ioctl(fd, SG_GET_VERSION_NUM, &sg_version) < 0) {
+		std::cerr << "SG_GET_VERSION_NUM ioctl failed with errno "
+			  << errno << '\n';
+		return -1;
+	}
+
+	if (sg_version < 30000) {
+		std::cerr << "Error: sg version 3 is not supported\n";
+		return -1;
+	}
+
+	uint8_t write6[6] = {
+		0x0a, (uint8_t)(lba >> 16), (uint8_t)(lba >> 8),
+		(uint8_t)(lba), (uint8_t)(v.data_len() / block_size),
+		0
+	};
+	unsigned char sense_buffer[32];
+	sg_io_hdr_t h;
+
+	memset(&h, 0, sizeof(h));
+	h.interface_id = 'S';
+	h.cmdp = write6;
+	h.cmd_len = sizeof(write6);
+	h.dxfer_direction = SG_DXFER_TO_DEV;
+	h.iovec_count = v.size();
+	h.dxfer_len = v.data_len();
+	h.dxferp = const_cast<void*>(v.address());
+	h.sbp = sense_buffer;
+	h.mx_sb_len = sizeof(sense_buffer);
+	h.timeout = 1000;     /* 1000 millisecs == 1 second */
+	if (ioctl(fd, SG_IO, &h) < 0) {
+		std::cerr << "WRITE(6) ioctl failed with errno " << errno
+			  << '\n';
+		return -1;
+	}
+	uint32_t result = h.status | (h.msg_status << 8) |
+		(h.host_status << 16) | (h.driver_status << 24);
+	if (result) {
+		std::cerr << "WRITE(6) failed with status 0x" << std::hex
+			  << result << "\n";
+		if (h.status == 2) {
+			std::cerr << "Sense buffer:\n";
+			dumphex(std::cerr, sense_buffer, h.sb_len_wr);
+		}
+		return -1;
+	}
+	return v.data_len() - h.resid;
+}
+
+static void usage()
+{
+	std::cout << "Usage: [-h] [-l <length_in_bytes>] [-o <lba_in_bytes>] [-s] [-w] <dev>\n";
+}
+
+int main(int argc, char **argv)
+{
+	bool scattered = false, write = false;
+	uint32_t offs = 0;
+	const char *dev;
+	int c;
+	std::vector<uint8_t> buf;
+	size_t len = 512;
+
+	while ((c = getopt(argc, argv, "hl:o:sw")) != EOF) {
+		switch (c) {
+		case 'l': len = strtoul(optarg, NULL, 0); break;
+		case 'o': offs = strtoul(optarg, NULL, 0); break;
+		case 's': scattered = true; break;
+		case 'w': write = true; break;
+		default: usage(); goto out;
+		}
+	}
+
+	if (argc - optind < 1) {
+		std::cerr << "Too few arguments.\n";
+		goto out;
+	}
+
+	dev = argv[optind];
+	buf.resize(len);
+	{
+		file_descriptor fd(open(dev, O_RDONLY));
+		if (fd < 0) {
+			std::cerr << "Failed to open " << dev << "\n";
+			goto out;
+		}
+		if (ioctl(fd, BLKSSZGET, &block_size) < 0) {
+			std::cerr << "Failed to query block size of " << dev
+				  << "\n";
+			goto out;
+		}
+		if (offs % block_size) {
+			std::cerr << "LBA is not a multiple of the block size.\n";
+			goto out;
+		}
+		iovec_t iov;
+		if (scattered) {
+			buf.resize(buf.size() * 2);
+			unsigned char *p = &*buf.begin();
+			for (int i = 0; i < len / 4; i++)
+				iov.append(p + 4 + i * 8,
+					   std::min(4ul, len - i * 4));
+		} else {
+			iov.append(&*buf.begin(), buf.size());
+		}
+		if (write) {
+			for (int i = 0; i < iov.size(); i++) {
+				sg_iovec_t& e = iov[i];
+				size_t prevgcount = std::cin.gcount();
+				if (!std::cin.read((char *)e.iov_base,
+						   e.iov_len)) {
+					e.iov_len = std::cin.gcount() -
+						prevgcount;
+					break;
+				}
+			}
+			ssize_t len = sg_write(fd, offs / block_size, iov);
+			if (len >= 0)
+				std::cout << "Wrote " << len << "/"
+					  << iov.data_len()
+					  << " bytes of data.\n";
+		} else {
+			ssize_t len = sg_read(fd, offs / block_size, iov);
+			if (len >= 0) {
+				std::cerr << "Read " << len
+					  << " bytes of data:\n";
+				iov.trunc(len);
+				iov.write(std::cout);
+			}
+		}
+	}
+
+ out:
+	return 0;
+}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (13 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 14/15] Add the discontiguous-io test program Bart Van Assche
@ 2018-06-22 22:19 ` Bart Van Assche
  2018-06-26  8:57   ` Johannes Thumshirn
  2018-06-23  3:14 ` [PATCH blktests 00/15] Add SRP initiator driver tests Ming Lei
  2018-06-26 21:02 ` Omar Sandoval
  16 siblings, 1 reply; 30+ messages in thread
From: Bart Van Assche @ 2018-06-22 22:19 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-block, Bart Van Assche

This patch adds the following tests:
001: Create and remove LUNs
002: File I/O on top of multipath concurrently with logout and login (mq)
003: File I/O on top of multipath concurrently with logout and login (sq)
004: File I/O on top of multipath concurrently with logout and login (sq-on-mq)
005: Direct I/O with large transfer sizes, cmd_sg_entries=255 and bs=4M
006: Direct I/O with large transfer sizes, cmd_sg_entries=255 and bs=8M
007: Direct I/O with large transfer sizes, cmd_sg_entries=1 and bs=4M
008: Direct I/O with large transfer sizes, cmd_sg_entries=1 and bs=8M
009: Buffered I/O with large transfer sizes, cmd_sg_entries=255 and bs=4M
010: Buffered I/O with large transfer sizes, cmd_sg_entries=255 and bs=8M
011: Block I/O on top of multipath concurrently with logout and login
012: dm-mpath on top of multiple I/O schedulers
013: Direct I/O using a discontiguous buffer

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 tests/srp/001       |   72 +++
 tests/srp/001.out   |    8 +
 tests/srp/002       |   50 ++
 tests/srp/002.out   |    7 +
 tests/srp/003       |   51 ++
 tests/srp/003.out   |    7 +
 tests/srp/004       |   51 ++
 tests/srp/004.out   |    7 +
 tests/srp/005       |   41 ++
 tests/srp/005.out   |    7 +
 tests/srp/006       |   41 ++
 tests/srp/006.out   |    7 +
 tests/srp/007       |   41 ++
 tests/srp/007.out   |    7 +
 tests/srp/008       |   40 ++
 tests/srp/008.out   |    7 +
 tests/srp/009       |   41 ++
 tests/srp/009.out   |    7 +
 tests/srp/010       |   41 ++
 tests/srp/010.out   |    7 +
 tests/srp/011       |   45 ++
 tests/srp/011.out   |    7 +
 tests/srp/012       |   53 ++
 tests/srp/012.out   |    8 +
 tests/srp/013       |   49 ++
 tests/srp/013.out   |    8 +
 tests/srp/functions | 1288 +++++++++++++++++++++++++++++++++++++++++++
 tests/srp/group     |   37 ++
 28 files changed, 2035 insertions(+)
 create mode 100755 tests/srp/001
 create mode 100644 tests/srp/001.out
 create mode 100755 tests/srp/002
 create mode 100644 tests/srp/002.out
 create mode 100755 tests/srp/003
 create mode 100644 tests/srp/003.out
 create mode 100755 tests/srp/004
 create mode 100644 tests/srp/004.out
 create mode 100755 tests/srp/005
 create mode 100644 tests/srp/005.out
 create mode 100755 tests/srp/006
 create mode 100644 tests/srp/006.out
 create mode 100755 tests/srp/007
 create mode 100644 tests/srp/007.out
 create mode 100755 tests/srp/008
 create mode 100644 tests/srp/008.out
 create mode 100755 tests/srp/009
 create mode 100644 tests/srp/009.out
 create mode 100755 tests/srp/010
 create mode 100644 tests/srp/010.out
 create mode 100755 tests/srp/011
 create mode 100644 tests/srp/011.out
 create mode 100755 tests/srp/012
 create mode 100644 tests/srp/012.out
 create mode 100755 tests/srp/013
 create mode 100644 tests/srp/013.out
 create mode 100755 tests/srp/functions
 create mode 100755 tests/srp/group

diff --git a/tests/srp/001 b/tests/srp/001
new file mode 100755
index 000000000000..928c5cf7133f
--- /dev/null
+++ b/tests/srp/001
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Create and remove LUNs"
+
+# Count the number of LUNs created by start_srpt() from the initiator side.
+count_srp_luns() {
+	local h luns=0 p
+
+	for p in /sys/class/srp_remote_ports/*; do
+		[ -e "$p" ] || continue
+		h="${p##*/}"; h="${h#port-}"; h="${h%:1}";
+		for d in "/sys/class/scsi_device/${h}:"*; do
+			[ -e "$d" ] && ((luns++))
+		done
+		[ "$luns" -gt 0 ] && break
+	done
+	echo $luns
+}
+
+count_nvme_devs() {
+	local d devs=0
+
+	for d in /sys/class/nvme-fabrics/ctl/*/*/device; do
+		[ -d "$d" ] && ((devs++))
+	done
+	echo $devs
+}
+
+count_luns() {
+	if [ -n "$nvme" ]; then
+		count_nvme_devs
+	else
+		count_srp_luns
+	fi
+}
+
+wait_for_luns() {
+	local i luns
+
+	use_blk_mq y y || return $?
+	for ((i=0;i<100;i++)); do
+		luns=$(count_luns)
+		[ "$luns" -ge ${#vdev_path[@]} ] && break
+		sleep .1
+	done
+	echo "count_luns(): $luns <> ${#vdev_path[@]}" >>"$FULL"
+	echo "count_luns(): $luns <> ${#vdev_path[@]}"
+	[ "$luns" -ge ${#vdev_path[@]} ]
+}
+
+test() {
+	setup && wait_for_luns && teardown
+}
diff --git a/tests/srp/001.out b/tests/srp/001.out
new file mode 100644
index 000000000000..eae5d6b0e5b2
--- /dev/null
+++ b/tests/srp/001.out
@@ -0,0 +1,8 @@
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+count_luns(): 3 <> 3
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/002 b/tests/srp/002
new file mode 100755
index 000000000000..9be973aecbc4
--- /dev/null
+++ b/tests/srp/002
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="File I/O on top of multipath concurrently with logout and login (mq)"
+TIMED=1
+
+test_disconnect_repeatedly() {
+	local dev fio_status m
+
+	use_blk_mq y y || return $?
+	dev=$(get_bdev 0) || return $?
+	m=$(mountpoint 0) || return $?
+	create_filesystem "$dev" || return $?
+	mount_and_check "$dev" "$m" || return $?
+	simulate_network_failure_loop "$dev" "$TIMEOUT" &
+	run_fio --verify=md5 -rw=randwrite --bs=4K --loops=$((10**6)) \
+		--iodepth=64 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio --directory="$m" --runtime="${TIMEOUT}" \
+		--name=data-integrity-test-mq --thread --numjobs=16 \
+		--output="${TMPDIR}/fio-output-srp-002.txt" \
+		>/dev/null
+	fio_status=$?
+	wait
+	[ -z "$nvme" ] && log_in
+	[ "$fio_status" = 0 ] || return "$fio_status"
+	unmount_and_check "$m" || return $?
+	return $fio_status
+}
+
+test() {
+	setup && test_disconnect_repeatedly && teardown
+}
diff --git a/tests/srp/002.out b/tests/srp/002.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/002.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/003 b/tests/srp/003
new file mode 100755
index 000000000000..a6b68ded11da
--- /dev/null
+++ b/tests/srp/003
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="File I/O on top of multipath concurrently with logout and login (sq)"
+TIMED=1
+
+test_disconnect_repeatedly() {
+	local dev fio_status m
+
+	use_blk_mq n n || return $?
+	dev=$(get_bdev 0) || return $?
+	m=$(mountpoint 0) || return $?
+	create_filesystem "$dev" || return $?
+	mount_and_check "$dev" "$m" || return $?
+	simulate_network_failure_loop "$dev" "$TIMEOUT" &
+	run_fio --verify=md5 -rw=randwrite --bs=4K --loops=$((10**6)) \
+		--iodepth=64 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio --directory="$m" --runtime="${TIMEOUT}" \
+		--name=data-integrity-test-sq --thread --numjobs=16 \
+		--output="${TMPDIR}/fio-output-srp-003.txt" \
+		>/dev/null
+	fio_status=$?
+	wait
+	[ -z "$nvme" ] && log_in
+	[ "$fio_status" = 0 ] || return "$fio_status"
+	unmount_and_check "$m" || return $?
+	log_out
+	return $fio_status
+}
+
+test() {
+	setup && test_disconnect_repeatedly && teardown
+}
diff --git a/tests/srp/003.out b/tests/srp/003.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/003.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/004 b/tests/srp/004
new file mode 100755
index 000000000000..0de3abb15e31
--- /dev/null
+++ b/tests/srp/004
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="File I/O on top of multipath concurrently with logout and login (sq-on-mq)"
+TIMED=1
+
+test_disconnect_repeatedly() {
+	local dev fio_status m
+
+	use_blk_mq n y || return $?
+	dev=$(get_bdev 0) || return $?
+	m=$(mountpoint 0) || return $?
+	create_filesystem "$dev" || return $?
+	mount_and_check "$dev" "$m" || return $?
+	simulate_network_failure_loop "$dev" "$TIMEOUT" &
+	run_fio --verify=md5 -rw=randwrite --bs=4K --loops=$((10**6)) \
+		--iodepth=64 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio --directory="$m" \
+		--name=data-integrity-test-02-sq-on-mq --thread \
+		--numjobs=16 --runtime="${TIMEOUT}" \
+		--output="${TMPDIR}/fio-output-srp-004.txt" >/dev/null
+	fio_status=$?
+	wait
+	[ -z "$nvme" ] && log_in
+	[ "$fio_status" = 0 ] || return "$fio_status"
+	unmount_and_check "$m" || return $?
+	log_out
+	return $fio_status
+}
+
+test() {
+	setup && test_disconnect_repeatedly && teardown
+}
diff --git a/tests/srp/004.out b/tests/srp/004.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/004.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/005 b/tests/srp/005
new file mode 100755
index 000000000000..a421903b66a1
--- /dev/null
+++ b/tests/srp/005
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Direct I/O with large transfer sizes, cmd_sg_entries=255 and bs=4M"
+QUICK=1
+
+test_large_transfer_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1,queue_size=32,max_cmd_per_lun=32,max_sect=$((1<<17))
+	use_blk_mq y y cmd_sg_entries=255 || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=4M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio \
+		--filename="$dev" --name=large-io-test --thread --numjobs=1 \
+		--runtime=10 --output="${TMPDIR}/fio-output-srp-005.txt" \
+		>/dev/null
+}
+
+test() {
+	setup && test_large_transfer_size && teardown
+}
diff --git a/tests/srp/005.out b/tests/srp/005.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/005.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/006 b/tests/srp/006
new file mode 100755
index 000000000000..f2f70b8f8aac
--- /dev/null
+++ b/tests/srp/006
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Direct I/O with large transfer sizes, cmd_sg_entries=255 and bs=8M"
+QUICK=1
+
+test_large_transfer_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1,queue_size=32,max_cmd_per_lun=32,max_sect=$((1<<17))
+	use_blk_mq y y cmd_sg_entries=255 || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=8M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio \
+		--filename="$dev" --name=large-io-test --thread --numjobs=1 \
+		--runtime=10 --output="${TMPDIR}/fio-output-srp-006.txt" \
+		>/dev/null
+}
+
+test() {
+	setup && test_large_transfer_size && teardown
+}
diff --git a/tests/srp/006.out b/tests/srp/006.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/006.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/007 b/tests/srp/007
new file mode 100755
index 000000000000..0976eb35e8cd
--- /dev/null
+++ b/tests/srp/007
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Direct I/O with large transfer sizes, cmd_sg_entries=1 and bs=4M"
+QUICK=1
+
+test_low_sg_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1
+	use_blk_mq y y "cmd_sg_entries=1" || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=4M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio \
+		--filename="$dev" --name=low-sg-test --thread --numjobs=1 \
+		--size=${ramdisk_size} --runtime=10 \
+		--output="${TMPDIR}/fio-output-srp-007.txt" >/dev/null
+}
+
+test() {
+	setup && test_low_sg_size && teardown
+}
diff --git a/tests/srp/007.out b/tests/srp/007.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/007.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/008 b/tests/srp/008
new file mode 100755
index 000000000000..caae1c972618
--- /dev/null
+++ b/tests/srp/008
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Direct I/O with large transfer sizes, cmd_sg_entries=1 and bs=8M"
+QUICK=1
+
+test_low_sg_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1
+	use_blk_mq y y "cmd_sg_entries=1" || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=8M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=1 \
+		--ioengine=libaio --size=${ramdisk_size} --runtime=10 \
+		--filename="$dev" --name=low-sg-test --thread --numjobs=1 \
+		--output="${TMPDIR}/fio-output-srp-008.txt" >/dev/null
+}
+
+test() {
+	setup && test_low_sg_size && teardown
+}
diff --git a/tests/srp/008.out b/tests/srp/008.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/008.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/009 b/tests/srp/009
new file mode 100755
index 000000000000..847b1e88eaa5
--- /dev/null
+++ b/tests/srp/009
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Buffered I/O with large transfer sizes, cmd_sg_entries=255 and bs=4M"
+QUICK=1
+
+test_large_transfer_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1,queue_size=32,max_cmd_per_lun=32,max_sect=$((1<<17))
+	use_blk_mq y y cmd_sg_entries=255 || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=4M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=0 \
+		--ioengine=libaio \
+		--filename="$dev" --name=large-io-test --thread --numjobs=1 \
+		--runtime=10 --output="${TMPDIR}/fio-output-srp-009.txt" \
+		>/dev/null
+}
+
+test() {
+	setup && test_large_transfer_size && teardown
+}
diff --git a/tests/srp/009.out b/tests/srp/009.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/009.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/010 b/tests/srp/010
new file mode 100755
index 000000000000..7e281d4f4bcc
--- /dev/null
+++ b/tests/srp/010
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Buffered I/O with large transfer sizes, cmd_sg_entries=255 and bs=8M"
+QUICK=1
+
+test_large_transfer_size() {
+	local dev m
+
+	srp_login_params+=ch_count=1,queue_size=32,max_cmd_per_lun=32,max_sect=$((1<<17))
+	use_blk_mq y y cmd_sg_entries=255 || return $?
+	dev=$(get_bdev 0) || return $?
+	run_fio --verify=md5 -rw=randwrite --bs=8M --loops=$((10**6)) \
+		--iodepth=4 --group_reporting --sync=1 --direct=0 \
+		--ioengine=libaio \
+		--filename="$dev" --name=large-io-test --thread --numjobs=1 \
+		--runtime=10 --output="${TMPDIR}/fio-output-srp-010.txt" \
+		>/dev/null
+}
+
+test() {
+	setup && test_large_transfer_size && teardown
+}
diff --git a/tests/srp/010.out b/tests/srp/010.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/010.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/011 b/tests/srp/011
new file mode 100755
index 000000000000..b3c16c1be28a
--- /dev/null
+++ b/tests/srp/011
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Block I/O on top of multipath concurrently with logout and login"
+TIMED=1
+
+test_disconnect_repeatedly() {
+	local dev fio_status m
+
+	use_blk_mq y y || return $?
+	dev=$(get_bdev 0) || return $?
+	simulate_network_failure_loop "$dev" "$TIMEOUT" &
+	run_fio --verify=md5 -rw=randwrite --bs=4K --loops=10000 \
+		--ioengine=libaio --iodepth=64 --iodepth_batch=32 \
+		--group_reporting --sync=1 \ --direct=1 \ --filename="$dev" \
+		--name=data-integrity-test-06 --thread \ --numjobs=1 \
+		--runtime="${TIMEOUT}" --output="${TMPDIR}/fio-output-011.txt" \
+		>/dev/null
+	fio_status=$?
+	wait
+	[ -z "$nvme" ] && log_in
+	return $fio_status
+}
+
+test() {
+	setup && test_disconnect_repeatedly && teardown
+}
diff --git a/tests/srp/011.out b/tests/srp/011.out
new file mode 100644
index 000000000000..6f14079ec4c6
--- /dev/null
+++ b/tests/srp/011.out
@@ -0,0 +1,7 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/012 b/tests/srp/012
new file mode 100755
index 000000000000..446854325662
--- /dev/null
+++ b/tests/srp/012
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Copyright (c) 2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="dm-mpath on top of multiple I/O schedulers"
+QUICK=1
+
+test_io_schedulers() {
+	local dev m
+
+	# Load all I/O scheduler kernel modules
+	for m in "/lib/modules/$(uname -r)/kernel/block/"*.ko; do
+		modprobe "$(basename "$m")" >&/dev/null
+	done
+	for mq in y n; do
+		use_blk_mq ${mq} ${mq} || return $?
+		dev=$(get_bdev 0) || return $?
+		for sched in noop deadline bfq cfq; do
+			set_scheduler "$(basename "$(readlink -f "${dev}")")" $sched \
+				      >>"$FULL" 2>&1 || continue
+			echo "I/O scheduler: $sched; use_blk_mq: $mq" >>"$FULL"
+			run_fio --verify=md5 -rw=randwrite --bs=4K --size=64K \
+				--ioengine=libaio --iodepth=64 \
+				--iodepth_batch=32 --group_reporting --sync=1 \
+				--direct=1 --filename="$dev" \
+				--name=${sched} --thread --numjobs=1 \
+				--output="${RESULTS_DIR}/012-${sched}-${mq}.txt" \
+				>/dev/null ||
+			    return $?
+		done
+	done
+}
+
+test() {
+	setup && test_io_schedulers && teardown
+}
diff --git a/tests/srp/012.out b/tests/srp/012.out
new file mode 100644
index 000000000000..e08ad3b777cf
--- /dev/null
+++ b/tests/srp/012.out
@@ -0,0 +1,8 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/013 b/tests/srp/013
new file mode 100755
index 000000000000..fc70445409f5
--- /dev/null
+++ b/tests/srp/013
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (c) 2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+. tests/srp/functions
+. common/shellcheck
+
+DESCRIPTION="Direct I/O using a discontiguous buffer"
+QUICK=1
+
+discontiguous_io() {
+	local byte bytes dev m
+
+	use_blk_mq y y || return $?
+	dev=$(get_bdev 0) || return $?
+	dd if="${dev}" bs=512 count=1 iflag=direct status=none |
+	    od -An -v -tu1 -w1 |
+	    while read -r byte; do
+		    # shellcheck disable=SC2059
+		    printf "\\x$(printf "%x" $((byte ^ 0xa5)))"
+	    done >"${TMPDIR}/data_block"
+	wc -c < "${TMPDIR}/data_block"
+	src/discontiguous-io -s -w "${dev}" <"${TMPDIR}/data_block" >>"$FULL" ||
+	    return $?
+	dd if="${dev}" bs=512 count=1 iflag=direct status=none |
+	    cmp - "${TMPDIR}/data_block" ||
+	    return $?
+	src/discontiguous-io -s "${dev}" 2>>"$FULL" |
+	    cmp - "${TMPDIR}/data_block" ||
+	    return $?
+}
+
+test() {
+	setup && discontiguous_io && teardown
+}
diff --git a/tests/srp/013.out b/tests/srp/013.out
new file mode 100644
index 000000000000..1058c5aee157
--- /dev/null
+++ b/tests/srp/013.out
@@ -0,0 +1,8 @@
+Unloaded the ib_srp kernel module
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
+Configured SRP target driver
+Unloaded the ib_srp kernel module
+512
+Unloaded the ib_srpt kernel module
+Unloaded the rdma_rxe kernel module
diff --git a/tests/srp/functions b/tests/srp/functions
new file mode 100755
index 000000000000..8fe654711613
--- /dev/null
+++ b/tests/srp/functions
@@ -0,0 +1,1288 @@
+#!/bin/bash
+#
+# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+have_brd() {
+	modinfo brd >/dev/null 2>&1
+}
+
+scsi_debug_dev_path() {
+	local bd d
+
+	for d in /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*/block/*; do
+		[ -e "$d" ] || continue
+		bd=${d/*\//}
+	done
+	[ -n "$bd" ] || return 1
+	echo "/dev/$bd"
+}
+
+vdev_path=(/dev/ram0 /dev/ram1 "$(scsi_debug_dev_path)")
+scsi_serial=(ramdisk1 ramdisk2 scsidbg)
+memtotal=$(sed -n 's/^MemTotal:[[:blank:]]*\([0-9]*\)[[:blank:]]*kB$/\1/p' /proc/meminfo)
+max_ramdisk_size=$((1<<25))
+if have_brd; then
+    ramdisk_size=$((memtotal*(1024/16)))  # in bytes
+    if [ $ramdisk_size -gt $max_ramdisk_size ]; then
+	ramdisk_size=$max_ramdisk_size
+    fi
+elif [ -e /sys/class/block/ram0 ]; then
+    # in bytes
+    ramdisk_size=$(($(</sys/class/block/ram0/size) * 512))
+else
+	echo "Error: could not find /dev/ram0"
+	exit 1
+fi
+
+debug=
+elevator=none
+filesystem_type=ext4
+fio_aux_path=/tmp/fio-state-files
+nvme=
+nvme_subsysnqn="nvme-test"
+nvme_port=7777
+roce=1
+TIMEOUT=${TIMEOUT:-600}
+scsi_timeout=1
+srp_login_params=
+srp_rdma_cm_port=5555
+
+# Log out, set dm and SCSI use_blk_mq parameters and log in. $1: device mapper
+# use_blk_mq mode; $2: SCSI use_blk_mq mode; $3..${$#}: SRP kernel module
+# parameters.
+use_blk_mq() {
+	local dm_mode=$1 scsi_mode=$2 kmod_params
+
+	shift
+	shift
+	kmod_params=("$@")
+
+	(
+		cd /sys/module/dm_mod/parameters || return $?
+		if [ -e use_blk_mq ]; then
+		    echo "$dm_mode" >use_blk_mq || return $?
+		fi
+	)
+	(
+		cd /sys/module/scsi_mod/parameters || return $?
+		echo "$scsi_mode" >use_blk_mq || return $?
+	)
+
+	log_out &&
+	    remove_mpath_devs &&
+	    stop_client &&
+	    start_client indirect_sg_entries=2048 "${kmod_params[@]}" &&
+	    log_in
+}
+
+get_ipv4_addr() {
+	ip -4 -o addr show dev "$1" |
+	    sed -n 's/.*[[:blank:]]inet[[:blank:]]*\([^[:blank:]/]*\).*/\1/p'
+}
+
+expand_ipv6_addr() {
+	awk -F : 'BEGIN{left=1} { for(i=1;i<=NF;i++) { a=substr("0000", 1+length($i)) $i; if ($i == "") left=0; else if (left) pre = pre ":" a; else suf = suf ":" a }; mid=substr(":0000:0000:0000:0000:0000:0000:0000:0000", 1+length(pre)+length(suf)); print substr(pre,2) mid suf}'
+}
+
+get_ipv6_addr() {
+	ip -6 -o addr show dev "$1" |
+	    sed -n 's/.*[[:blank:]]inet6[[:blank:]]*\([^[:blank:]/]*\).*/\1/p'
+}
+
+srp_single_login() {
+	local login=$1 p=$2 status
+
+	if ! status=$(LC_ALL=C; { echo "$login" >"$p"; } 2>&1); then
+		status="${status/*: }"
+		case "$status" in
+			"File exists" | "Invalid argument")
+				;;
+			*)
+				echo "$login >$p failed: $status"
+				return 1
+				;;
+		esac
+	fi
+	return 0
+}
+
+# Arguments: $1: SRP target IOC GUID; $2: IB device to log in to; $3: IB device
+# port to log in to; $4: additional login parameters.
+do_ib_cm_login() {
+	local add_param gid ibdev ioc_guid p port
+
+	ioc_guid=$1
+	ibdev=$2
+	port=$3
+	add_param=$4
+	gid=$(<"/sys/class/infiniband/$ibdev/ports/$port/gids/0")
+	gid=${gid//:}
+	for p in /sys/class/infiniband_srp/*; do
+		[ -e "$p" ] || continue
+		srp_single_login "id_ext=$ioc_guid,ioc_guid=$ioc_guid,dgid=$gid,pkey=7fff,service_id=$ioc_guid,$add_param" "$p/add_target" || return $?
+	done
+}
+
+# Arguments: $1: SRP target IOC GUID; $2: IB device to log in to; $3: additional
+# login parameters.
+do_rdma_cm_login() {
+	local a b add_param d dest dests ibdev ioc_guid pd
+
+	ioc_guid=$1
+	ibdev=$2
+	add_param=$3
+	pd=/sys/class/infiniband/$ibdev/parent
+	if [ -e "$pd" ]; then
+	    d=$(<"$pd")
+	    a=$(get_ipv4_addr "$(basename "$d")")
+	    b=$(get_ipv6_addr "$(basename "$d")")
+	fi
+	[ -n "$a$b" ] || return 1
+	dests=()
+	[ -n "$a" ] && dests+=("${a}:${srp_rdma_cm_port}")
+	[ -n "$b" ] && dests+=("[${b}]:${srp_rdma_cm_port}")
+	for dest in "${dests[@]}"; do
+		for p in /sys/class/infiniband_srp/*; do
+			[ -e "$p" ] || continue
+			srp_single_login "id_ext=$ioc_guid,ioc_guid=$ioc_guid,dest=$dest,$add_param" "$p/add_target" || return $?
+		done
+	done
+}
+
+# Make the SRP initiator driver log in to each SRP target port.
+srp_log_in() {
+	local a add_param=$1 d dest gid ibdev ioc_guid login port p sysfsdir
+
+	ioc_guid=$(</sys/module/ib_srpt/parameters/srpt_service_guid)
+
+	for ((i=0;i<10;i++)); do
+		for d in /sys/class/infiniband_mad/umad*; do
+			[ -e "$d" ] || continue
+			sysfsdir=/sys/class/infiniband_mad/$(basename "$d")
+			ibdev=$(<"$sysfsdir/ibdev")
+			port=$(<"$sysfsdir/port")
+			link_layer=$(<"/sys/class/infiniband/$ibdev/ports/$port/link_layer")
+			case $link_layer in
+				InfiniBand)
+					do_ib_cm_login   "$ioc_guid" "$ibdev" "$port" "$add_param" &&
+					    do_rdma_cm_login "$ioc_guid" "$ibdev" "$add_param";;
+				*)
+					do_rdma_cm_login "$ioc_guid" "$ibdev" "$add_param";;
+			esac || break
+		done
+
+		for p in /sys/class/scsi_host/*/orig_dgid; do
+			[ -e "$p" ] && return 0
+		done
+		sleep .1
+	done
+
+	echo "SRP login failed"
+
+	return 1
+}
+
+# Tell the SRP initiator driver to log out.
+srp_log_out() {
+	local p
+
+	if [ -e /sys/class/srp_remote_ports ]; then
+	    for p in /sys/class/srp_remote_ports/*; do
+		    [ -e "$p" ] && echo 1 >"$p/delete" &
+	    done
+	fi
+	wait
+}
+
+is_number() {
+	[ "$1" -eq "0$1" ] 2>/dev/null
+}
+
+# Check whether a device is an RDMA device. An example argument:
+# /sys/devices/pci0000:00/0000:00:03.0/0000:04:00.0
+is_rdma_device() {
+	local d i inode1 inode2
+
+	inode1=$(stat -c %i "$1")
+	# echo "inode1 = $inode1"
+	for i in /sys/class/infiniband/*; do
+		d=/sys/class/infiniband/"$(readlink "$i")"
+		d=$(dirname "$(dirname "$d")")
+		inode2=$(stat -c %i "$d")
+		# echo "inode2 = $inode2"
+		if [ "$inode1" = "$inode2" ]; then
+		    return
+		fi
+	done
+	false
+}
+
+# Lists RDMA network interface names, e.g. ib0 ib1
+rdma_network_interfaces() {
+	(
+		cd /sys/class/net &&
+		    for i in *; do
+			    [ -e "$i" ] || continue
+			    [ -L "$i/device" ] || continue
+			    d=$(readlink "$i/device" 2>/dev/null)
+			    if [ -n "$d" ] && is_rdma_device "$i/$d"; then
+				echo "$i"
+			    fi
+		    done
+	)
+}
+
+nvme_log_in() {
+	local i ipv4_addr
+
+	[ -c /dev/nvme-fabrics ] &&
+	    for i in $(rdma_network_interfaces); do
+		    ipv4_addr=$(get_ipv4_addr "$i")
+		    if [ -n "${ipv4_addr}" ]; then
+			echo -n "transport=rdma,traddr=${ipv4_addr},trsvcid=${nvme_port},nqn=$nvme_subsysnqn" > /dev/nvme-fabrics
+		    fi
+	    done &&
+	    echo reconfigure | multipathd -k >&/dev/null
+}
+
+nvme_log_out() {
+	local c
+
+	for c in /sys/class/nvme-fabrics/ctl/*/delete_controller; do
+		[ -e "$c" ] && echo 1 > "$c" &
+	done
+	wait
+}
+
+# Log in.
+log_in() {
+	if [ -n "$nvme" ]; then
+		nvme_log_in
+	else
+		srp_log_in "${srp_login_params}"
+	fi
+}
+
+log_out() {
+	if [ -n "$nvme" ]; then
+		nvme_log_out
+	else
+		srp_log_out
+	fi
+}
+
+held_by() {
+	local d e dev=$1
+
+	while [ -L "$dev" ]; do
+		dev=$(realpath "$dev")
+	done
+	dev=${dev%/dev/}
+	for d in /sys/class/block/*/holders/*; do
+		[ -e "$d" ] || continue
+		e=$(basename "$d")
+		if [ "$e" = "$dev" ]; then
+		    echo "/dev/$(basename "$(dirname "$(dirname "$d")")")"
+		fi
+	done
+}
+
+# System uptime in seconds.
+uptime_s() {
+	local a b
+
+	echo "$(</proc/uptime)" | { read -r a b && echo "${a%%.*}"; }
+}
+
+# Sleep until either $1 seconds have elapsed or until the deadline $2 has been
+# reached. Return 1 if and only if the deadline has been met.
+sleep_until() {
+	local duration=$1 deadline=$2 u
+
+	u=$(uptime_s)
+	if [ $((u + duration)) -le "$deadline" ]; then
+		sleep "$duration"
+	else
+		[ "$deadline" -gt "$u" ] && sleep $((deadline - u))
+		return 1
+	fi
+}
+
+# Simulate network failures for device $1 during $2 seconds.
+simulate_network_failure_loop() {
+	local d dev="$1" duration="$2" deadline i rc=0 s
+
+	[ -e "$dev" ] || return $?
+	[ -n "$duration" ] || return $?
+	deadline=$(($(uptime_s) + duration))
+	s=5
+	while [ $rc = 0 ]; do
+		sleep_until 5 ${deadline} || break
+		if [ -n "$nvme" ]; then
+			for d in $(held_by "$dev"); do
+				echo 1 >"$d/device/reset_controller"
+			done
+		else
+			log_out
+			sleep_until $s ${deadline}
+			rc=$?
+			s=$(((((s + 5) & 0xff) ^ 0xa6) * scsi_timeout / 60))
+			log_in
+		fi
+	done
+
+	for ((i=0;i<5;i++)); do
+		log_in && break
+		sleep 1
+	done
+}
+
+stop_bdev_users() {
+	[ -n "$1" ] || return $?
+	lsof -F p "$1" 2>/dev/null | while read -r line; do
+		p="${line#p}"
+		if [ "$p" != "$line" ]; then
+		    echo -n " (pid $p)"
+		    kill -9 "$p"
+		fi
+	done
+}
+
+# RHEL 6 dmsetup accepts mpath<n> but not /dev/dm-<n> as its first argument.
+# Hence this function that converts /dev/dm-<n> into mpath<n>.
+dev_to_mpath() {
+	local d e mm
+
+	d="${1#/dev/mapper/}";
+	if [ "$d" != "$1" ]; then
+		echo "$d"
+		return 0
+	fi
+
+	[ -e "$1" ] || return $?
+
+	if [ -h "$1" ]; then
+		e=$(readlink -f "$1")
+	else
+		e="$1"
+	fi
+	if ! mm=$(stat -c %t:%T "$e"); then
+		echo "stat $1 -> $e failed"
+		return 1
+	fi
+
+	for d in /dev/mapper/mpath*; do
+		if [ -h "$d" ]; then
+			e=$(readlink -f "$d")
+		elif [ -e "$d" ]; then
+			e="$d"
+		else
+			continue
+		fi
+		if [ "$(stat -c %t:%T "$e")" = "$mm" ]; then
+			basename "$d"
+			return 0
+		fi
+	done
+	return 1
+}
+
+remove_mpath_dev() {
+	local cmd dm i output t1 t2
+
+	for ((i=10;i>0;i--)); do
+		cmd="dm=\$(dev_to_mpath \"$1\")"
+		if ! eval "$cmd"; then
+			echo "$cmd: failed"
+		else
+			t1=$(dmsetup table "$dm")
+			cmd="dmsetup message $dm 0 fail_if_no_path"
+			if ! eval "$cmd"; then
+				echo "$cmd: failed"
+			else
+				t2=$(dmsetup table "$dm")
+				if echo "$t2" | grep -qw queue_if_no_path; then
+					echo "$dm: $t1 -> $t2"
+				fi
+				unmount_and_check "/dev/mapper/$dm"
+				cmd="dmsetup remove $dm"
+				if ! output=$(eval "$cmd" 2>&1); then
+					echo "$cmd: $output; retrying"
+				else
+					echo "done"
+					break
+				fi
+			fi
+		fi
+		if [ ! -e "$1" ]; then
+			break
+		fi
+		ls -l "$1"
+		stop_bdev_users "$(readlink -f "$1")"
+		sleep .5
+	done
+	if [ $i = 0 ]; then
+		echo "failed"
+		return 1
+	fi
+}
+
+# Check whether one or more arguments are stale device nodes (/dev/...).
+mpath_has_stale_dev() {
+	local d
+
+	for d in "$@"; do
+		if [ "${d/://}" != "$d" ]; then
+			grep -qw "$d" /sys/class/block/*/dev 2>/dev/null ||
+			    return 0
+		fi
+	done
+
+	return 1
+}
+
+is_qinp_def() {
+	case "$1" in
+		"3 queue_if_no_path queue_mode mq ")
+			return 0;;
+		"1 queue_if_no_path ")
+			return 0;;
+		*)
+			return 1;;
+	esac
+}
+
+remove_srp_mpath_devs() {
+	(
+		cd /sys/class/scsi_host &&
+		    for p in /sys/class/srp_remote_ports/*; do
+			    [ -e "$p" ] || continue
+			    h="${p##*/}"; h="${h#port-}"; h="${h%:1}"
+			    for d in "/sys/class/scsi_device/${h}:"*/device/block/*; do
+				    [ -e "$d" ] || continue
+				    s=$(dirname "$(dirname "$(dirname "$d")")")
+				    b=$(basename "$d")
+				    for h in "/sys/class/block/$b/holders/"*; do
+					    [ -e "$h" ] || continue
+					    dm=/dev/$(basename "$h")
+					    echo -n "SRP LUN $s / $b: removing $dm: "
+					    remove_mpath_dev "$dm" || [ -z "$debug" ] || return 1
+				    done
+			    done
+		    done
+	)
+	# Find all multipaths with one or more deleted devices and remove these
+	dmsetup table | while read -r mpdev fs ls type def; do
+		echo "$fs $ls" >/dev/null
+		# shellcheck disable=SC2086
+		if [ "$type" = multipath ] &&
+		       { is_qinp_def "$def" || mpath_has_stale_dev $def; }; then
+		    echo "${mpdev%:}"
+		fi
+	done |
+	    sort -u |
+	    while read -r mpdev; do
+		    mpdev="/dev/mapper/$mpdev"
+		    echo -n "removing $mpdev: "
+		    remove_mpath_dev "$mpdev" || [ -z "$debug" ] || return 1
+	    done
+}
+
+remove_nvme_mpath_devs() {
+	local dm h
+
+	for h in /sys/class/block/nvme*/holders/*; do
+		[ -e "$h" ] || continue
+		d=$(basename "$(dirname "$(dirname "$h")")")
+		dm=/dev/$(basename "$h")
+		echo -n "NVME dev $d: removing $dm: "
+		dmsetup remove "$(dev_to_mpath "$dm")" && echo "done"
+	done
+}
+
+remove_mpath_devs() {
+	if [ -n "$nvme" ]; then
+		remove_nvme_mpath_devs
+	else
+		remove_srp_mpath_devs
+	fi >>"$FULL" 2>&1
+}
+
+# Arguments: module to unload ($1) and retry count ($2).
+unload_module() {
+	local i m=$1 rc=${2:-1}
+
+	[ ! -e "/sys/module/$m" ] && return 0
+	for ((i=rc;i>0;i--)); do
+		modprobe -r "$m"
+		[ ! -e "/sys/module/$m" ] && return 0
+		sleep .1
+	done
+	return 1
+}
+
+# Load the SRP initiator driver with kernel module parameters $1..$n.
+start_srp() {
+	modprobe scsi_transport_srp || return $?
+	modprobe ib_srp "$@" dyndbg=+pmf || return $?
+}
+
+# Unload the SRP initiator driver.
+stop_srp() {
+	local i
+
+	srp_log_out
+	for ((i=40;i>=0;i--)); do
+		remove_mpath_devs || return $?
+		unload_module ib_srp >/dev/null 2>&1 && break
+		sleep 1
+	done
+	if [ -e /sys/module/ib_srp ]; then
+		echo "Error: unloading kernel module ib_srp failed"
+		return 1
+	fi
+	unload_module scsi_transport_srp || return $?
+	echo "Unloaded the ib_srp kernel module"
+}
+
+start_nvme_client() {
+	modprobe nvme dyndbg=+pmf &&
+	    modprobe nvme-core dyndbg=+pmf &&
+	    modprobe nvme-fabrics dyndbg=+pmf &&
+	    modprobe nvme-rdma dyndbg=+pmf
+}
+
+stop_nvme_client() {
+	unload_module nvme_rdma &&
+	    unload_module nvme
+}
+
+# Load the initiator kernel driver with kernel module parameters $1..$n.
+start_client() {
+	if [ -n "$nvme" ]; then
+		start_nvme_client "$@"
+	else
+		start_srp "$@"
+	fi
+}
+
+stop_client() {
+	if [ -n "$nvme" ]; then
+		stop_nvme_client
+	else
+		stop_srp
+	fi
+}
+
+# Load the configfs kernel module and mount it.
+mount_configfs() {
+	if [ ! -e /sys/module/configfs ]; then
+		modprobe configfs || return $?
+	fi
+	if ! mount | grep -qw configfs; then
+		mount -t configfs none /sys/kernel/config || return $?
+	fi
+}
+
+# Associate the LIO device with name $1/$2 with file $3 and SCSI serial $4.
+configure_lio_vdev() {
+	local dirname=$1 vdev=$2 path=$3 serial=$4
+
+	(
+		cd /sys/kernel/config/target/core &&
+		    mkdir "$dirname" &&
+		    cd "$dirname" &&
+		    mkdir "$vdev" &&
+		    cd "$vdev" &&
+		    if [ -b "$(readlink -f "$path")" ]; then
+			echo "udev_path=$path," >control
+		    elif [ -e "$path" ]; then
+			size=$(stat -c %s "${path}") &&
+			    [ "$size" -gt 0 ] &&
+			    echo "fd_dev_name=$path,fd_dev_size=$size," >control
+		    else
+			    {
+				    ls -l "$path"
+				    readlink -f "$path"
+			    } >>"$FULL" 2>&1
+			    false
+		    fi &&
+		    echo "${serial}" >wwn/vpd_unit_serial &&
+		    echo 1 > enable
+	)
+}
+
+lio_scsi_mpath_id() {
+	local i=$1 hs
+
+	is_number "$i" || return $?
+	hs=$(echo -n "${scsi_serial[i]}" | od -v -tx1 -w99 |
+		 { read -r offset bytes;
+		   echo "${bytes// }";
+		   echo "$offset" > /dev/null
+		 })
+	while [ ${#hs} -lt 25 ]; do
+		hs="${hs}0"
+	done
+	# See also spc_emulate_evpd_83() in drivers/target/target_core_spc.c.
+	echo "36001405$hs"
+}
+
+scsi_mpath_id() {
+	lio_scsi_mpath_id "$@"
+}
+
+get_nvme_bdev() {
+	local i=$1 j=0
+
+	for d in /sys/class/nvme-fabrics/ctl/*/*/device; do
+		[ -d "$d" ] || continue
+		if [ $j -ge "$i" ]; then
+			echo "/dev/$(basename "$(dirname "$d")")"
+			return 0
+		fi
+		((j++))
+	done
+	return 1
+}
+
+# Get a the uuid or wwid of block device number $1 with $1 >= 0. See also
+# the bin/getuid_callout script.
+get_bdev_uid() {
+	local i=$1
+
+	is_number "$i" || return $?
+	if [ -n "$nvme" ]; then
+		bdev=$(get_nvme_bdev "$i") || return $?
+		wwid=$(<"/sys/block/${bdev#/dev/}/wwid")
+		wwid=${wwid#nvme.0000-}
+		echo "${wwid%-4c696e75780000000000000000000000000000000000000000000000000000000000000000000000-00000001}"
+	else
+		scsi_mpath_id "$i"
+	fi
+}
+
+# Set scheduler of $1 to $2
+set_scheduler() {
+	local b=$1 p s=$2
+
+	p=/sys/class/block/$b/queue/scheduler
+	if [ -e "/sys/block/$b/mq" ]; then
+		case "$s" in
+			noop)        s=none;;
+			deadline)    s=mq-deadline;;
+			bfq)         s=bfq;;
+		esac
+	else
+		case "$s" in
+			none)        s=noop;;
+			mq-deadline) s=deadline;;
+			bfq-mq)      s=bfq;;
+		esac
+	fi
+	if ! echo "$s" > "$p"; then
+		echo "Changing scheduler of $b from $(<"$p") into $s failed" >&2
+		return 1
+	fi
+}
+
+# Get a /dev/... path that points at dm device number $1 with $1 >= 0.
+get_bdev() {
+	local b d dev h i=$1 j realdev
+
+	is_number "$i" || return $?
+	echo reconfigure | multipathd -k >&/dev/null
+	dev="/dev/disk/by-id/dm-uuid-mpath-$(get_bdev_uid "$i")" || return $?
+	for ((j=0;j<50;j++)); do
+		[ -e "$dev" ] && break
+		sleep .1
+	done
+	if [ ! -e "$dev" ]; then
+		echo "$dev: not found" >&2
+		return 1
+	fi
+	if [ ! -L "$dev" ]; then
+		echo "$dev: not a soft link" >&2
+		return 1
+	fi
+	realdev=$(readlink "$dev" 2>/dev/null || echo "?")
+	echo "Using $dev -> ${realdev}" >>"$FULL"
+	for ((j=0; j<50; j++)); do
+		blockdev --getbsz "$dev" >&/dev/null && break
+		echo reconfigure | multipathd -k >& /dev/null
+		sleep .1
+	done
+	if ! blockdev --getbsz "$dev" >&/dev/null; then
+		return 1
+	fi
+	b=$(basename "$realdev")
+	set_scheduler "$b" "${elevator}"
+	for d in /sys/class/block/*"/holders/$b"; do
+		[ -e "$d" ] || continue
+		h="$(basename "$(dirname "$(dirname "$d")")")"
+		set_scheduler "$h" "${elevator}"
+		if [ -e "/sys/class/block/$h/device/timeout" ]; then
+			echo $scsi_timeout > "/sys/class/block/$h/device/timeout"
+		fi
+	done
+	echo "$dev"
+}
+
+# Configure zero or more target ports such that these accept connections from
+# zero or more initiator ports. Target and initiator port lists are separated
+# by "--".
+configure_target_ports() {
+	local i ini initiators target_port target_ports
+
+	target_ports=()
+	while [ $# -gt 0 ]; do
+		if [ "$1" = "--" ]; then
+			shift
+			break
+		fi
+		target_ports+=("$1")
+		shift
+	done
+
+	initiators=()
+	while [ $# -gt 0 ]; do
+		initiators+=("$1")
+		shift
+	done
+
+	for target_port in "${target_ports[@]}"; do
+		mkdir "$target_port" || return $?
+		[ -e "$target_port" ] || continue
+		#echo "$target_port"
+		mkdir "$target_port/$target_port" || continue
+		i=0
+		for v in "${vdev[@]}"; do
+			mkdir "$target_port/$target_port/lun/lun_$i" || return $?
+			(
+				cd "$target_port/$target_port/lun/lun_$i" &&
+				    ln -s "../../../../../core/$v" .
+			) || return $?
+			i=$((i+1))
+		done
+		for ini in "${initiators[@]}"; do
+			(
+				cd "$target_port/$target_port/acls" &&
+				    mkdir "${ini}" &&
+				    cd "${ini}" &&
+				    for ((i = 0; i < ${#vdev[@]}; i++)) do
+					(
+						mkdir lun_$i &&
+						    cd lun_$i &&
+						    ln -s ../../../lun/lun_$i .
+					) || return $?
+				    done
+			) || return $?
+		done
+		echo 1 >"$target_port/$target_port/enable"
+	done
+}
+
+function mountpoint() {
+	if [ -z "$TMPDIR" ]; then
+		echo "Error: \$TMPDIR has not been set." 1>&2
+		exit 1
+	fi
+	if [ -z "$1" ]; then
+		echo "Error: missing argument" 1>&2
+		exit 1
+	fi
+	echo "$TMPDIR/mnt$1"
+}
+
+all_primary_gids() {
+	find /sys/devices -name infiniband | while read -r p; do
+		cat "$p"/*/ports/*/gids/0
+	done | grep -v ':0000:0000:0000:0000$'
+}
+
+# Load LIO and configure the SRP target driver and LUNs
+start_lio_srpt() {
+	local b d gid guid i ini_gids ini_guids opts p target_gids target_guids vdev
+
+	target_guids=($(all_primary_gids | sed 's/^fe80:0000:0000:0000://'))
+	target_gids=($(all_primary_gids | sed 's/^/0x/;s/://g'))
+	for p in /sys/class/infiniband/*/ports/*; do
+		[ -e "$p" ] || continue
+		link_layer=$(<"$p/link_layer")
+		case "$link_layer" in
+			InfiniBand)
+				guid=$(<"$p/gids/0")
+				gid=$(echo "${guid}" | sed 's/^fe8/0x000/;s/://g')
+				guid=${guid#fe80:0000:0000:0000:}
+				[ "$guid" = "0000:0000:0000:0000" ] && continue
+				ini_guids+=("$guid")
+				ini_gids+=("$gid")
+				;;
+			*)
+				d=$(<"$(dirname "$(dirname "$p")")/parent")
+				for b in $(get_ipv4_addr "$d") \
+					     $(get_ipv6_addr "$d"|expand_ipv6_addr); do
+					ini_guids+=("$b")
+					ini_gids+=("$b")
+				done
+				;;
+		esac
+	done
+	mount_configfs || return $?
+	modprobe target_core_mod || return $?
+	modprobe target_core_iblock || return $?
+	opts=("srp_max_req_size=4200" "dyndbg=+pmf")
+	if modinfo ib_srpt | grep -q '^parm:[[:blank:]]*rdma_cm_port:'; then
+		opts+=("rdma_cm_port=${srp_rdma_cm_port}")
+	fi
+	insmod "/lib/modules/$(uname -r)/kernel/drivers/infiniband/ulp/srpt/ib_srpt.ko" "${opts[@]}" || return $?
+	i=0
+	for r in "${vdev_path[@]}"; do
+		if [ -b "$(readlink -f "$r")" ]; then
+			oflag=oflag=direct
+		else
+			oflag=
+		fi
+		echo -n "Zero-initializing $r ... " >>"$FULL"
+		dd if=/dev/zero of="${r}" bs=1M count=$((ramdisk_size>>20)) ${oflag} >/dev/null 2>&1 || return $?
+		echo "done" >>"$FULL"
+		mkdir -p "$(mountpoint $i)" || return $?
+		((i++))
+	done
+	vdev=(iblock_0/vdev0 iblock_1/vdev1 iblock_2/vdev2)
+	for ((i=0; i < ${#vdev[@]}; i++)); do
+		d="$(dirname "${vdev[i]}")"
+		b="$(basename "${vdev[i]}")"
+		hs=$(lio_scsi_mpath_id "$i")
+		hs=${hs#36001405}
+		configure_lio_vdev "$d" "$b" "${vdev_path[i]}" "$hs" ||
+		    return $?
+	done
+	(
+		cd /sys/kernel/config/target || return $?
+		mkdir srpt || return $?
+		cd srpt || return $?
+		if [ -e discovery_auth/rdma_cm_port ]; then
+			echo "${srp_rdma_cm_port}" > discovery_auth/rdma_cm_port ||
+			    return $?
+		fi
+		configure_target_ports "${target_guids[@]}" -- "${ini_guids[@]}" || {
+			echo "Retrying with old port name format"
+			configure_target_ports "${target_gids[@]}" -- "${ini_gids[@]}"
+		}
+	)
+}
+
+# Check whether or not an rdma_rxe instance has been associated with network
+# interface $1.
+has_rdma_rxe() {
+	local f
+
+	for f in /sys/class/infiniband/*/parent; do
+		if [ -e "$f" ] && [ "$(<"$f")" = "$1" ]; then
+			return 0
+		fi
+	done
+
+	return 1
+}
+
+# Load the rdma_rxe kernel module and associate it with all network interfaces
+# except "lo".
+start_rdma_rxe() {
+	if [ -n "$roce" ]; then
+		modprobe rdma_rxe || return $?
+		(
+			cd /sys/class/net &&
+			    for i in *; do
+				    if [ -e "$i" ] && [ "$i" != "lo" ] &&
+					   ! has_rdma_rxe "$i"; then
+					echo "$i" > /sys/module/rdma_rxe/parameters/add
+				    fi
+			    done
+		)
+		{
+			echo -n "SoftRoCE network interfaces:"
+			(
+				cd /sys/class/infiniband &&
+				    for i in rxe*; do
+					    [ -e "$i" ] && echo -n " $i"
+				    done
+			)
+			echo
+		} >>"$FULL"
+	fi
+}
+
+# Dissociate the rdma_rxe kernel module from all network interfaces and unload
+# the rdma_rxe kernel module.
+stop_rdma_rxe() {
+	(
+		cd /sys/class/net &&
+		    for i in *; do
+			    if [ -e "$i" ] && has_rdma_rxe "$i"; then
+				{ echo "$i" > /sys/module/rdma_rxe/parameters/remove; } \
+				    2>/dev/null
+			    fi
+		    done
+	)
+	if ! unload_module rdma_rxe; then
+		echo "Unloading rdma_rxe failed"
+		return 1
+	fi
+}
+
+# Unload the LIO SRP target driver.
+stop_lio_srpt() {
+	local e hca m
+
+	mount_configfs
+	for e in /sys/kernel/config/target/srpt/$hca/$hca/enable; do
+		if [ -e "$e" ]; then
+			echo 0 >"$e"
+		fi
+	done
+
+	if [ -e /sys/kernel/config/target/srpt ]; then
+	    (
+		    cd /sys/kernel/config/target/srpt && (
+			    for d in */*/acls/*/*/lun*; do [ -L "$d" ] && rm "$d"; done
+			    for d in */*/acls/*/lun*; do [ -d "$d" ] && rmdir "$d"; done
+			    for d in */*/acls/*; do [ -d "$d" ] && rmdir "$d"; done
+			    for d in */*/lun/lun*/*; do [ -L "$d" ] && rm "$d"; done
+			    for d in */*/lun/lun*; do [ -d "$d" ] && rmdir "$d"; done
+			    for d in */*; do [ -e "$d/lun" ] && rmdir "$d"; done
+			    for d in *; do [ -e "$d/fabric_statistics" ] && rmdir "$d"; done
+			    true
+		    ) &&
+			cd .. &&
+			for ((i=0;i<10;i++)); do
+				rmdir srpt
+				[ -e srpt ] || break
+				sleep .1
+			done &&
+			[ ! -e srpt ] &&
+			unload_module ib_srpt 10
+	    ) || return $?
+	fi
+
+	rmdir /sys/kernel/config/target/core/*/* >&/dev/null
+	rmdir /sys/kernel/config/target/core/* >&/dev/null
+
+	for m in ib_srpt target_core_pscsi target_core_iblock target_core_file \
+			 target_core_stgt target_core_user target_core_mod
+	do
+		unload_module $m 10 || return $?
+	done
+}
+
+# Load and configure the SRP target driver
+start_srpt() {
+	local bd i
+
+	have_brd &&
+	    modprobe brd rd_nr=${#vdev_path[@]} rd_size=$((ramdisk_size>>10))
+	modprobe scsi_debug delay=0 dif=3 dix=1 dev_size_mb=$((ramdisk_size>>20))
+	for ((i=0;i<10;i++)); do
+		bd=$(scsi_debug_dev_path) && break
+		sleep .1
+	done
+	if [ -z "$bd" ]; then
+		echo "scsi_debug device instance not found"
+		return 1
+	fi
+	vdev_path[2]=$bd
+	modprobe ib_uverbs
+	modprobe ib_umad
+	modprobe rdma_cm
+	start_lio_srpt || return $?
+	echo "Configured SRP target driver"
+}
+
+# Unload the SRP target driver.
+stop_srpt() {
+	stop_lio_srpt || return $?
+	unload_module scsi_debug
+	if have_brd; then
+		unload_module brd || return $?
+		rm -f "${vdev_path[@]}"
+	fi
+	echo "Unloaded the ib_srpt kernel module"
+}
+
+configure_nvmet_port() {
+	local p=$1 ipv4_addr=$2 i
+
+	echo "Configuring $p with address $ipv4_addr as an NVMeOF target port"
+	(
+		cd /sys/kernel/config/nvmet/ports &&
+		    for ((i=1;;i++)); do [ -e "$i" ] || break; done &&
+			     mkdir "$i" &&
+			     cd "$i" &&
+			     echo ipv4            > addr_adrfam &&
+			     echo rdma            > addr_trtype &&
+			     echo -n "$ipv4_addr" > addr_traddr &&
+			     echo -n ${nvme_port} > addr_trsvcid
+	)
+}
+
+start_nvme_target() {
+	local d i ipv4_addr num_ports=0 nvme_dev=1
+
+	if have_brd; then
+		modprobe brd rd_nr=${#vdev_path[@]} rd_size=$((ramdisk_size>>10))
+	fi &&
+	    modprobe nvme dyndbg=+pmf &&
+	    modprobe nvmet-rdma dyndbg=+pmf &&
+	    sleep .1 &&
+	    (
+		    cd /sys/kernel/config/nvmet/subsystems &&
+			mkdir ${nvme_subsysnqn} &&
+			cd ${nvme_subsysnqn} &&
+			cd namespaces &&
+			mkdir "${nvme_dev}" &&
+			cd "${nvme_dev}" &&
+			echo 00000000-0000-0000-0000-000000000000 >device_nguid &&
+			echo -n /dev/ram0 >device_path &&
+			echo 1 >enable &&
+			cd ../.. &&
+			echo 1 >attr_allow_any_host
+	    ) && for i in $(rdma_network_interfaces); do
+		    ipv4_addr=$(get_ipv4_addr "$i")
+		    if [ -n "${ipv4_addr}" ]; then
+			configure_nvmet_port "$i" "${ipv4_addr}"
+			((num_ports++))
+			true
+		    fi
+	    done &&
+	    if [ $num_ports = 0 ]; then
+		echo "No NVMeOF target ports"
+		false
+	    fi && (
+		    cd /sys/kernel/config/nvmet/ports &&
+			for i in *; do
+				[ -e "$i" ] && (
+					cd "$i/subsystems" &&
+					    ln -s "../../../subsystems/${nvme_subsysnqn}" .
+				)
+			done
+	    )
+}
+
+stop_nvme_target() {
+	local d
+
+	(
+		cd /sys/kernel/config/nvmet 2>/dev/null &&
+		    rm -f -- ports/*/subsystems/* &&
+		    for d in {*/*/*/*,*/*}; do
+			    [ -e "$d" ] && rmdir "$d"
+		    done
+	)
+	unload_module nvmet_rdma &&
+	    unload_module nvmet &&
+	    have_brd && unload_module brd
+}
+
+start_target() {
+	start_rdma_rxe
+	if [ -n "$nvme" ]; then
+		start_nvme_target
+	else
+		start_srpt
+	fi
+}
+
+stop_target() {
+	if [ -n "$nvme" ]; then
+		stop_nvme_target
+	else
+		stop_srpt
+	fi
+	stop_rdma_rxe || return $?
+	echo "Unloaded the rdma_rxe kernel module"
+}
+
+# Look up the block device below the filesystem on which directory $1 exists.
+block_dev_of_dir() {
+	df "$1" | {
+		read -r header
+		echo "$header" >/dev/null
+		read -r blockdev rest
+		echo "$blockdev"
+	}
+}
+
+create_filesystem() {
+	local dev=$1
+
+	case "$filesystem_type" in
+		ext4)
+			mkfs.ext4 -F -O ^has_journal -q "$dev";;
+		xfs)
+			mkfs.xfs -f -q "$dev";;
+		*)
+			return 1;;
+	esac
+}
+
+is_mountpoint() {
+	[ -n "$1" ] &&
+	    [ -d "$1" ] &&
+	    [ "$(block_dev_of_dir "$1")" != \
+					 "$(block_dev_of_dir "$(dirname "$1")")" ]
+}
+
+mount_and_check() {
+	local dir last
+
+	dir=$(for last; do :; done; echo "$last")
+	mount "$@"
+	if ! is_mountpoint "$dir"; then
+		echo "Error: mount $* failed"
+		return 1
+	fi
+}
+
+unmount_and_check() {
+	local bd m=$1 mp
+
+	if is_mountpoint "$m"; then
+		bd=$(block_dev_of_dir "$m")
+		mp=$(dev_to_mpath "$bd") 2>/dev/null
+		if [ -n "$mp" ]; then
+			dmsetup message "$mp" 0 fail_if_no_path
+		fi
+		echo "Unmounting $m from $bd" >> "$FULL"
+		umount "$m"
+	fi
+	if is_mountpoint "$m"; then
+		echo "Error: unmounting $m failed"
+		return 1
+	fi
+}
+
+# Test whether fio supports command-line options "$@"
+test_fio_opt() {
+	local opt
+
+	for opt in "$@"; do
+		opt=${opt//=*}
+		fio --help |& grep -q -- "${opt}=" && continue
+		opt=${opt#--}
+		fio --cmdhelp=all |& grep -q "^${opt}[[:blank:]]" && continue
+		return 1
+	done
+}
+
+run_fio() {
+	local a args avail_kb bd d j opt
+
+	args=("$@")
+	j=1
+	for opt in "${args[@]}"; do
+		case "$opt" in
+			--directory=*) d="${opt#--directory=}";;
+			--filename=*)  bd="${opt#--filename=}";;
+			--numjobs=*)   j="${opt#--numjobs=}";;
+		esac
+	done
+	if [ -n "$d" ]; then
+		a=$(df "$d" | grep "^/" |
+		    {
+			    if read -r fs blocks used avail use mnt; then
+				echo "$avail"
+				echo "$fs $blocks $used $use $mnt" >/dev/null
+			    fi
+		    }
+		 )
+		avail_kb=$a
+	fi
+	if [ -n "$bd" ]; then
+		avail_kb=$(("$(blockdev --getsz "$bd")" / 2))
+	fi
+	if [ -n "$avail_kb" ]; then
+		args+=("--size=$(((avail_kb * 1024 * 7 / 10) / j & ~4095))")
+	fi
+	for opt in --exitall_on_error=1 --gtod_reduce=1 --aux-path=${fio_aux_path}
+	do
+		if test_fio_opt "$opt"; then
+			args+=("$opt")
+		fi
+	done
+	mkdir -p "${fio_aux_path}"
+	echo "fio ${args[*]}" >>"${FULL}"
+	fio "${args[@]}" 2>&1
+	if [ -n "$output" ]; then
+		# Return exit code 1 if no I/O has been performed.
+		grep -q ', io=[0-9].*, run=[0-9]' "$output"
+	fi
+}
+
+shutdown_client() {
+	remove_mpath_devs &&
+	    log_out &&
+	    stop_client
+}
+
+# Undo setup()
+teardown() {
+	stop_target
+}
+
+# Set up test configuration
+setup() {
+	local i m
+
+	if [ -e /etc/init.d/srpd ]; then
+		/etc/init.d/srpd stop >/dev/null 2>&1
+	else
+		systemctl stop srp_daemon
+	fi >>"$FULL" 2>&1
+	if pidof srp_daemon >/dev/null; then
+		echo "Error: failed to stop srp_daemon"
+		return 1
+	fi
+
+	shutdown_client || return $?
+
+	if ! teardown; then
+		echo "teardown() failed"
+		return 1
+	fi
+
+	[ -e /sys/module/scsi_mod ] || modprobe scsi_mod
+	[ -e /sys/module/dm_mod   ] || modprobe dm_mod
+	# Load configfs
+	grep -wq configfs /proc/filesystems || modprobe configfs || return $?
+
+	# Load the I/O scheduler kernel modules
+	(
+		cd "/lib/modules/$(uname -r)/kernel/block" &&
+		    for m in *.ko; do
+			    modprobe "${m%.ko}"
+		    done
+	)
+
+	if [ -d /sys/kernel/debug/dynamic_debug ]; then
+		for m in ; do
+			echo "module $m +pmf" >/sys/kernel/debug/dynamic_debug/control
+		done
+	fi
+
+	start_target
+}
diff --git a/tests/srp/group b/tests/srp/group
new file mode 100755
index 000000000000..a56486e4f5cd
--- /dev/null
+++ b/tests/srp/group
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Copyright (c) 2018 Western Digital Corporation or its affiliates
+#
+# 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 2
+# 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, write to the Free Software
+# Foundation, Inc.
+
+group_requires() {
+	_have_configfs || return $?
+	_have_module dm_multipath || return $?
+	_have_module ib_srp || return $?
+	_have_module ib_srpt || return $?
+	_have_module sd_mod || return $?
+	_have_program mkfs.ext4 || return $?
+	_have_program mkfs.xfs || return $?
+	_have_program multipath || return $?
+	_have_program multipathd || return $?
+	_have_program pidof || return $?
+	_have_program sg_reset || return $?
+	_have_root || return $?
+
+	if ! pidof multipathd >/dev/null; then
+	    echo "Error: multipathd is not running"
+            return 1
+	fi
+}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (14 preceding siblings ...)
  2018-06-22 22:19 ` [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers Bart Van Assche
@ 2018-06-23  3:14 ` Ming Lei
  2018-06-23  3:19   ` Ming Lei
  2018-06-25 17:05   ` Bart Van Assche
  2018-06-26 21:02 ` Omar Sandoval
  16 siblings, 2 replies; 30+ messages in thread
From: Ming Lei @ 2018-06-23  3:14 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Omar Sandoval, linux-block, Ming Lei

On Sat, Jun 23, 2018 at 6:19 AM, Bart Van Assche <bart.vanassche@wdc.com> wrote:
> Hello Omar,
>
> As promised during LSF/MM, I have converted the srp-tests software to the
> blktests framework. This patch series included all blktests patches I postd
> a few days ago. Please consider this patch series for inclusion in the
> official blktests repository. Note: this patch series is also available as
> a github pull request, namely https://github.com/osandov/blktests/pull/24.
>
> Thanks,
>
> Bart.
>
> Bart Van Assche (15):
>   common/rc: Fix _have_tracepoint()
>   Annotate include statements in shell scripts where the source file is
>     a variable
>   check, tests/meta/012: Use array["index"] instead of array[index]
>   Suppress shellcheck complaints about global variables
>   check: Avoid that shellcheck complains that $FULL appears unused
>   Multiple tests: remove unused and undefined variables
>   Avoid passing tests/block/002 arguments to _init_scsi_debug
>   check: Suppress a shellcheck warning about the DMESG_FILTER
>     initialization
>   Makefile: Do not suppress useful shellcheck warnings
>   tests/meta/group: Fix shellcheck complaints
>   make check: Also check tests/*/group files
>   check: Make TMPDIR absolute
>   src/Makefile: Fix pattern rule
>   Add the discontiguous-io test program
>   Add tests for the SRP initiator and target drivers
>
>  Makefile                 |   16 +-
>  check                    |   53 +-
>  common/cpuhotplug        |    2 +
>  common/fio               |    2 +
>  common/iopoll            |    2 +
>  common/loop              |    1 +
>  common/nbd               |    2 +
>  common/nvme              |    2 +
>  common/rc                |    2 +
>  common/scsi              |    2 +
>  common/scsi_debug        |    3 +
>  common/shellcheck        |    4 +
>  new                      |    2 +
>  src/.gitignore           |    1 +
>  src/Makefile             |    6 +-
>  src/discontiguous-io.cpp |  340 ++++++++++
>  tests/block/001          |    1 +
>  tests/block/002          |    3 +-
>  tests/block/003          |    2 +
>  tests/block/004          |    2 +
>  tests/block/005          |    2 +
>  tests/block/006          |    2 +
>  tests/block/007          |    1 +
>  tests/block/009          |    1 +
>  tests/block/010          |    2 +
>  tests/block/011          |    2 +
>  tests/block/012          |    2 +
>  tests/block/013          |    2 +
>  tests/block/014          |    2 +
>  tests/block/015          |    2 +
>  tests/block/016          |    2 +
>  tests/block/017          |    2 +
>  tests/block/018          |    2 +
>  tests/block/019          |    2 +
>  tests/block/020          |    2 +
>  tests/block/021          |    2 +
>  tests/loop/001           |    2 +
>  tests/loop/003           |    5 +-
>  tests/loop/005           |    2 +
>  tests/meta/001           |    2 +
>  tests/meta/002           |    2 +
>  tests/meta/003           |    2 +
>  tests/meta/004           |    2 +
>  tests/meta/005           |    2 +
>  tests/meta/006           |    2 +
>  tests/meta/007           |    2 +
>  tests/meta/008           |    2 +
>  tests/meta/009           |    2 +
>  tests/meta/010           |    2 +
>  tests/meta/011           |    2 +
>  tests/meta/012           |    6 +-
>  tests/meta/group         |    6 +-
>  tests/nbd/001            |    2 +
>  tests/nbd/002            |    2 +
>  tests/nvme/001           |    2 +
>  tests/nvme/002           |    2 +
>  tests/nvme/003           |    2 +
>  tests/nvme/004           |    2 +
>  tests/nvme/005           |    2 +
>  tests/nvme/006           |    2 +
>  tests/nvme/007           |    2 +
>  tests/nvme/008           |    2 +
>  tests/nvme/009           |    2 +
>  tests/nvme/010           |    5 +-
>  tests/nvme/011           |    5 +-
>  tests/nvme/012           |    3 +-
>  tests/nvme/013           |    3 +-
>  tests/scsi/001           |    2 +
>  tests/scsi/002           |    2 +
>  tests/scsi/003           |    2 +
>  tests/scsi/004           |    1 +
>  tests/srp/001            |   72 +++
>  tests/srp/001.out        |    8 +
>  tests/srp/002            |   50 ++
>  tests/srp/002.out        |    7 +
>  tests/srp/003            |   51 ++
>  tests/srp/003.out        |    7 +
>  tests/srp/004            |   51 ++
>  tests/srp/004.out        |    7 +
>  tests/srp/005            |   41 ++
>  tests/srp/005.out        |    7 +
>  tests/srp/006            |   41 ++
>  tests/srp/006.out        |    7 +
>  tests/srp/007            |   41 ++
>  tests/srp/007.out        |    7 +
>  tests/srp/008            |   40 ++
>  tests/srp/008.out        |    7 +
>  tests/srp/009            |   41 ++
>  tests/srp/009.out        |    7 +
>  tests/srp/010            |   41 ++
>  tests/srp/010.out        |    7 +
>  tests/srp/011            |   45 ++
>  tests/srp/011.out        |    7 +
>  tests/srp/012            |   53 ++
>  tests/srp/012.out        |    8 +
>  tests/srp/013            |   49 ++
>  tests/srp/013.out        |    8 +
>  tests/srp/functions      | 1288 ++++++++++++++++++++++++++++++++++++++
>  tests/srp/group          |   37 ++
>  99 files changed, 2548 insertions(+), 53 deletions(-)
>  create mode 100644 common/shellcheck
>  create mode 100644 src/discontiguous-io.cpp
>  create mode 100755 tests/srp/001
>  create mode 100644 tests/srp/001.out
>  create mode 100755 tests/srp/002
>  create mode 100644 tests/srp/002.out
>  create mode 100755 tests/srp/003
>  create mode 100644 tests/srp/003.out
>  create mode 100755 tests/srp/004
>  create mode 100644 tests/srp/004.out
>  create mode 100755 tests/srp/005
>  create mode 100644 tests/srp/005.out
>  create mode 100755 tests/srp/006
>  create mode 100644 tests/srp/006.out
>  create mode 100755 tests/srp/007
>  create mode 100644 tests/srp/007.out
>  create mode 100755 tests/srp/008
>  create mode 100644 tests/srp/008.out
>  create mode 100755 tests/srp/009
>  create mode 100644 tests/srp/009.out
>  create mode 100755 tests/srp/010
>  create mode 100644 tests/srp/010.out
>  create mode 100755 tests/srp/011
>  create mode 100644 tests/srp/011.out
>  create mode 100755 tests/srp/012
>  create mode 100644 tests/srp/012.out
>  create mode 100755 tests/srp/013
>  create mode 100644 tests/srp/013.out
>  create mode 100755 tests/srp/functions
>  create mode 100755 tests/srp/group
>
> --
> 2.17.1
>

Good progress, seems it is starting working.

Just tried srp/001

[root@ktest-04 blktests]# ./check srp/001
srp/001 (Create and remove LUNs)                             [failed]
    runtime  0.912s  ...  18.358s
    --- tests/srp/001.out 2018-06-23 02:41:33.267925950 +0000
    +++ results/nodev/srp/001.out.bad 2018-06-23 03:11:30.062799405 +0000
    @@ -1,8 +1,27 @@
    -Unloaded the ib_srpt kernel module
    +Unloaded the ib_srp kernel module
    +modprobe: FATAL: Module target_core_mod is in use.
    +modprobe: FATAL: Module target_core_mod is in use.
    +modprobe: FATAL: Module target_core_mod is in use.
    +modprobe: FATAL: Module target_core_mod is in use.
    +modprobe: FATAL: Module target_core_mod is in use.
    ...
    (Run 'diff -u tests/srp/001.out results/nodev/srp/001.out.bad' to
see the entire diff)

[root@ktest-04 blktests]# lsmod | grep target
iscsi_target_mod      303104  1 ib_isert
target_core_mod       356352  2 iscsi_target_mod,ib_isert



Thanks,
Ming Lei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-23  3:14 ` [PATCH blktests 00/15] Add SRP initiator driver tests Ming Lei
@ 2018-06-23  3:19   ` Ming Lei
  2018-06-25 17:05   ` Bart Van Assche
  1 sibling, 0 replies; 30+ messages in thread
From: Ming Lei @ 2018-06-23  3:19 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Omar Sandoval, linux-block, Ming Lei

On Sat, Jun 23, 2018 at 11:14 AM, Ming Lei <tom.leiming@gmail.com> wrote:
> On Sat, Jun 23, 2018 at 6:19 AM, Bart Van Assche <bart.vanassche@wdc.com> wrote:
>> Hello Omar,
>>
>> As promised during LSF/MM, I have converted the srp-tests software to the
>> blktests framework. This patch series included all blktests patches I postd
>> a few days ago. Please consider this patch series for inclusion in the
>> official blktests repository. Note: this patch series is also available as
>> a github pull request, namely https://github.com/osandov/blktests/pull/24.
>>
>> Thanks,
>>
>> Bart.
>>
>> Bart Van Assche (15):
>>   common/rc: Fix _have_tracepoint()
>>   Annotate include statements in shell scripts where the source file is
>>     a variable
>>   check, tests/meta/012: Use array["index"] instead of array[index]
>>   Suppress shellcheck complaints about global variables
>>   check: Avoid that shellcheck complains that $FULL appears unused
>>   Multiple tests: remove unused and undefined variables
>>   Avoid passing tests/block/002 arguments to _init_scsi_debug
>>   check: Suppress a shellcheck warning about the DMESG_FILTER
>>     initialization
>>   Makefile: Do not suppress useful shellcheck warnings
>>   tests/meta/group: Fix shellcheck complaints
>>   make check: Also check tests/*/group files
>>   check: Make TMPDIR absolute
>>   src/Makefile: Fix pattern rule
>>   Add the discontiguous-io test program
>>   Add tests for the SRP initiator and target drivers
>>
>>  Makefile                 |   16 +-
>>  check                    |   53 +-
>>  common/cpuhotplug        |    2 +
>>  common/fio               |    2 +
>>  common/iopoll            |    2 +
>>  common/loop              |    1 +
>>  common/nbd               |    2 +
>>  common/nvme              |    2 +
>>  common/rc                |    2 +
>>  common/scsi              |    2 +
>>  common/scsi_debug        |    3 +
>>  common/shellcheck        |    4 +
>>  new                      |    2 +
>>  src/.gitignore           |    1 +
>>  src/Makefile             |    6 +-
>>  src/discontiguous-io.cpp |  340 ++++++++++
>>  tests/block/001          |    1 +
>>  tests/block/002          |    3 +-
>>  tests/block/003          |    2 +
>>  tests/block/004          |    2 +
>>  tests/block/005          |    2 +
>>  tests/block/006          |    2 +
>>  tests/block/007          |    1 +
>>  tests/block/009          |    1 +
>>  tests/block/010          |    2 +
>>  tests/block/011          |    2 +
>>  tests/block/012          |    2 +
>>  tests/block/013          |    2 +
>>  tests/block/014          |    2 +
>>  tests/block/015          |    2 +
>>  tests/block/016          |    2 +
>>  tests/block/017          |    2 +
>>  tests/block/018          |    2 +
>>  tests/block/019          |    2 +
>>  tests/block/020          |    2 +
>>  tests/block/021          |    2 +
>>  tests/loop/001           |    2 +
>>  tests/loop/003           |    5 +-
>>  tests/loop/005           |    2 +
>>  tests/meta/001           |    2 +
>>  tests/meta/002           |    2 +
>>  tests/meta/003           |    2 +
>>  tests/meta/004           |    2 +
>>  tests/meta/005           |    2 +
>>  tests/meta/006           |    2 +
>>  tests/meta/007           |    2 +
>>  tests/meta/008           |    2 +
>>  tests/meta/009           |    2 +
>>  tests/meta/010           |    2 +
>>  tests/meta/011           |    2 +
>>  tests/meta/012           |    6 +-
>>  tests/meta/group         |    6 +-
>>  tests/nbd/001            |    2 +
>>  tests/nbd/002            |    2 +
>>  tests/nvme/001           |    2 +
>>  tests/nvme/002           |    2 +
>>  tests/nvme/003           |    2 +
>>  tests/nvme/004           |    2 +
>>  tests/nvme/005           |    2 +
>>  tests/nvme/006           |    2 +
>>  tests/nvme/007           |    2 +
>>  tests/nvme/008           |    2 +
>>  tests/nvme/009           |    2 +
>>  tests/nvme/010           |    5 +-
>>  tests/nvme/011           |    5 +-
>>  tests/nvme/012           |    3 +-
>>  tests/nvme/013           |    3 +-
>>  tests/scsi/001           |    2 +
>>  tests/scsi/002           |    2 +
>>  tests/scsi/003           |    2 +
>>  tests/scsi/004           |    1 +
>>  tests/srp/001            |   72 +++
>>  tests/srp/001.out        |    8 +
>>  tests/srp/002            |   50 ++
>>  tests/srp/002.out        |    7 +
>>  tests/srp/003            |   51 ++
>>  tests/srp/003.out        |    7 +
>>  tests/srp/004            |   51 ++
>>  tests/srp/004.out        |    7 +
>>  tests/srp/005            |   41 ++
>>  tests/srp/005.out        |    7 +
>>  tests/srp/006            |   41 ++
>>  tests/srp/006.out        |    7 +
>>  tests/srp/007            |   41 ++
>>  tests/srp/007.out        |    7 +
>>  tests/srp/008            |   40 ++
>>  tests/srp/008.out        |    7 +
>>  tests/srp/009            |   41 ++
>>  tests/srp/009.out        |    7 +
>>  tests/srp/010            |   41 ++
>>  tests/srp/010.out        |    7 +
>>  tests/srp/011            |   45 ++
>>  tests/srp/011.out        |    7 +
>>  tests/srp/012            |   53 ++
>>  tests/srp/012.out        |    8 +
>>  tests/srp/013            |   49 ++
>>  tests/srp/013.out        |    8 +
>>  tests/srp/functions      | 1288 ++++++++++++++++++++++++++++++++++++++
>>  tests/srp/group          |   37 ++
>>  99 files changed, 2548 insertions(+), 53 deletions(-)
>>  create mode 100644 common/shellcheck
>>  create mode 100644 src/discontiguous-io.cpp
>>  create mode 100755 tests/srp/001
>>  create mode 100644 tests/srp/001.out
>>  create mode 100755 tests/srp/002
>>  create mode 100644 tests/srp/002.out
>>  create mode 100755 tests/srp/003
>>  create mode 100644 tests/srp/003.out
>>  create mode 100755 tests/srp/004
>>  create mode 100644 tests/srp/004.out
>>  create mode 100755 tests/srp/005
>>  create mode 100644 tests/srp/005.out
>>  create mode 100755 tests/srp/006
>>  create mode 100644 tests/srp/006.out
>>  create mode 100755 tests/srp/007
>>  create mode 100644 tests/srp/007.out
>>  create mode 100755 tests/srp/008
>>  create mode 100644 tests/srp/008.out
>>  create mode 100755 tests/srp/009
>>  create mode 100644 tests/srp/009.out
>>  create mode 100755 tests/srp/010
>>  create mode 100644 tests/srp/010.out
>>  create mode 100755 tests/srp/011
>>  create mode 100644 tests/srp/011.out
>>  create mode 100755 tests/srp/012
>>  create mode 100644 tests/srp/012.out
>>  create mode 100755 tests/srp/013
>>  create mode 100644 tests/srp/013.out
>>  create mode 100755 tests/srp/functions
>>  create mode 100755 tests/srp/group
>>
>> --
>> 2.17.1
>>
>
> Good progress, seems it is starting working.
>
> Just tried srp/001
>
> [root@ktest-04 blktests]# ./check srp/001
> srp/001 (Create and remove LUNs)                             [failed]
>     runtime  0.912s  ...  18.358s
>     --- tests/srp/001.out 2018-06-23 02:41:33.267925950 +0000
>     +++ results/nodev/srp/001.out.bad 2018-06-23 03:11:30.062799405 +0000
>     @@ -1,8 +1,27 @@
>     -Unloaded the ib_srpt kernel module
>     +Unloaded the ib_srp kernel module
>     +modprobe: FATAL: Module target_core_mod is in use.
>     +modprobe: FATAL: Module target_core_mod is in use.
>     +modprobe: FATAL: Module target_core_mod is in use.
>     +modprobe: FATAL: Module target_core_mod is in use.
>     +modprobe: FATAL: Module target_core_mod is in use.
>     ...
>     (Run 'diff -u tests/srp/001.out results/nodev/srp/001.out.bad' to
> see the entire diff)
>
> [root@ktest-04 blktests]# lsmod | grep target
> iscsi_target_mod      303104  1 ib_isert
> target_core_mod       356352  2 iscsi_target_mod,ib_isert


BTW, almost every srp test may report the above failure.


-- 
Ming Lei

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-23  3:14 ` [PATCH blktests 00/15] Add SRP initiator driver tests Ming Lei
  2018-06-23  3:19   ` Ming Lei
@ 2018-06-25 17:05   ` Bart Van Assche
  2018-06-26  1:37     ` Ming Lei
  1 sibling, 1 reply; 30+ messages in thread
From: Bart Van Assche @ 2018-06-25 17:05 UTC (permalink / raw)
  To: Ming Lei; +Cc: Omar Sandoval, linux-block, Ming Lei

On 06/22/18 20:15, Ming Lei wrote:
> Just tried srp/001
> 
> [root@ktest-04 blktests]# ./check srp/001
> srp/001 (Create and remove LUNs)                             [failed]
>      runtime  0.912s  ...  18.358s
>      --- tests/srp/001.out 2018-06-23 02:41:33.267925950 +0000
>      +++ results/nodev/srp/001.out.bad 2018-06-23 03:11:30.062799405 +0000
>      @@ -1,8 +1,27 @@
>      -Unloaded the ib_srpt kernel module
>      +Unloaded the ib_srp kernel module
>      +modprobe: FATAL: Module target_core_mod is in use.
>      +modprobe: FATAL: Module target_core_mod is in use.
>      +modprobe: FATAL: Module target_core_mod is in use.
>      +modprobe: FATAL: Module target_core_mod is in use.
>      +modprobe: FATAL: Module target_core_mod is in use.
>      ...
>      (Run 'diff -u tests/srp/001.out results/nodev/srp/001.out.bad' to
> see the entire diff)
> 
> [root@ktest-04 blktests]# lsmod | grep target
> iscsi_target_mod      303104  1 ib_isert
> target_core_mod       356352  2 iscsi_target_mod,ib_isert

LIO must be unconfigured before the SRP tests are run. The above output 
shows that LIO was already loaded before the SRP tests were started. I 
will add a test that prevents the SRP tests to start if LIO was already 
configured.

Bart.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 13/15] src/Makefile: Fix pattern rule
  2018-06-22 22:19 ` [PATCH blktests 13/15] src/Makefile: Fix pattern rule Bart Van Assche
@ 2018-06-25 22:54   ` Omar Sandoval
  0 siblings, 0 replies; 30+ messages in thread
From: Omar Sandoval @ 2018-06-25 22:54 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Omar Sandoval, linux-block

On Fri, Jun 22, 2018 at 03:19:44PM -0700, Bart Van Assche wrote:
> According to the GNU make documentation, the syntax for pattern rules
> is as follows:
> 
> <target pattern>+: <source pattern>
> 	<rule>

That's because this is a static pattern rule:

https://www.gnu.org/software/make/manual/html_node/Static-Usage.html

So calling this a fix isn't accurate :) I'll fold this change into the
change adding the C++ program.

> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> ---
>  src/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/Makefile b/src/Makefile
> index 612282d14af8..d7ae832fc4fd 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -13,7 +13,7 @@ all: $(TARGETS)
>  clean:
>  	rm -f $(TARGETS)
>  
> -$(TARGETS): %: %.c
> +%: %.c
>  	$(CC) -Wall -o $@ $(CPPFLAGS) $(CFLAGS) $^
>  
>  .PHONY: all clean
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-25 17:05   ` Bart Van Assche
@ 2018-06-26  1:37     ` Ming Lei
  2018-06-26  2:16       ` Bart Van Assche
  0 siblings, 1 reply; 30+ messages in thread
From: Ming Lei @ 2018-06-26  1:37 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Ming Lei, Omar Sandoval, linux-block

On Mon, Jun 25, 2018 at 10:05:41AM -0700, Bart Van Assche wrote:
> On 06/22/18 20:15, Ming Lei wrote:
> > Just tried srp/001
> > 
> > [root@ktest-04 blktests]# ./check srp/001
> > srp/001 (Create and remove LUNs)                             [failed]
> >      runtime  0.912s  ...  18.358s
> >      --- tests/srp/001.out 2018-06-23 02:41:33.267925950 +0000
> >      +++ results/nodev/srp/001.out.bad 2018-06-23 03:11:30.062799405 +0000
> >      @@ -1,8 +1,27 @@
> >      -Unloaded the ib_srpt kernel module
> >      +Unloaded the ib_srp kernel module
> >      +modprobe: FATAL: Module target_core_mod is in use.
> >      +modprobe: FATAL: Module target_core_mod is in use.
> >      +modprobe: FATAL: Module target_core_mod is in use.
> >      +modprobe: FATAL: Module target_core_mod is in use.
> >      +modprobe: FATAL: Module target_core_mod is in use.
> >      ...
> >      (Run 'diff -u tests/srp/001.out results/nodev/srp/001.out.bad' to
> > see the entire diff)
> > 
> > [root@ktest-04 blktests]# lsmod | grep target
> > iscsi_target_mod      303104  1 ib_isert
> > target_core_mod       356352  2 iscsi_target_mod,ib_isert
> 
> LIO must be unconfigured before the SRP tests are run. The above output
> shows that LIO was already loaded before the SRP tests were started. I will
> add a test that prevents the SRP tests to start if LIO was already
> configured.

I run SRP test on Fedora 27, and not run any LIO specific commands
to load it, seems it is done automatically.

So looks it might not a good idea to fail SRP test if LIO is loaded,
just wondering why your SRP test can't make the two co-exist?

Thanks,
Ming

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-26  1:37     ` Ming Lei
@ 2018-06-26  2:16       ` Bart Van Assche
  2018-06-26  7:27         ` Johannes Thumshirn
  0 siblings, 1 reply; 30+ messages in thread
From: Bart Van Assche @ 2018-06-26  2:16 UTC (permalink / raw)
  To: ming.lei; +Cc: osandov, tom.leiming, linux-block

T24gVHVlLCAyMDE4LTA2LTI2IGF0IDA5OjM3ICswODAwLCBNaW5nIExlaSB3cm90ZToNCj4gSSBy
dW4gU1JQIHRlc3Qgb24gRmVkb3JhIDI3LCBhbmQgbm90IHJ1biBhbnkgTElPIHNwZWNpZmljIGNv
bW1hbmRzDQo+IHRvIGxvYWQgaXQsIHNlZW1zIGl0IGlzIGRvbmUgYXV0b21hdGljYWxseS4NCj4g
DQo+IFNvIGxvb2tzIGl0IG1pZ2h0IG5vdCBhIGdvb2QgaWRlYSB0byBmYWlsIFNSUCB0ZXN0IGlm
IExJTyBpcyBsb2FkZWQsDQo+IGp1c3Qgd29uZGVyaW5nIHdoeSB5b3VyIFNSUCB0ZXN0IGNhbid0
IG1ha2UgdGhlIHR3byBjby1leGlzdD8NCg0KVGhlIExJTyBjb25maWd1cmF0aW9uIGlzIHN5c3Rl
bS13aWRlLiBPbmx5IG9uZSBjb25maWd1cmF0aW9uIGNhbiBiZQ0KbG9hZGVkIGF0IGFueSBnaXZl
biB0aW1lLiBJIGRvbid0IHRoaW5rIHRoYXQgdGhlIFNSUCB0ZXN0cyBzaG91bGQgd2lwZQ0KYW55
IGV4aXN0aW5nIExJTyBjb25maWd1cmF0aW9uIGRhdGEgaWYgZS5nLiBibGt0ZXN0cyBpcyBydW4g
YWNjaWRlbnRhbGx5DQpvbiBhIHByb2R1Y3Rpb24gc2VydmVyLiBJIHRoaW5rIHRoYXQgd2lwaW5n
IExJTyBjb25maWd1cmF0aW9uIGRhdGEgc2hvdWxkDQpiZSBhIG1hbnVhbCBzdGVwLg0KDQpCYXJ0
Lg==

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-26  2:16       ` Bart Van Assche
@ 2018-06-26  7:27         ` Johannes Thumshirn
  2018-06-26 15:24           ` Bart Van Assche
  0 siblings, 1 reply; 30+ messages in thread
From: Johannes Thumshirn @ 2018-06-26  7:27 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: ming.lei, osandov, tom.leiming, linux-block

On Tue, Jun 26, 2018 at 02:16:26AM +0000, Bart Van Assche wrote:
> On Tue, 2018-06-26 at 09:37 +0800, Ming Lei wrote:
> > I run SRP test on Fedora 27, and not run any LIO specific commands
> > to load it, seems it is done automatically.
> > 
> > So looks it might not a good idea to fail SRP test if LIO is loaded,
> > just wondering why your SRP test can't make the two co-exist?
> 
> The LIO configuration is system-wide. Only one configuration can be
> loaded at any given time. I don't think that the SRP tests should wipe
> any existing LIO configuration data if e.g. blktests is run accidentally
> on a production server. I think that wiping LIO configuration data should
> be a manual step.

I think this should be handled in requires(). I.e. check if LIO is
already configured and then skip the test if it is.

Byte,
	Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers
  2018-06-22 22:19 ` [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers Bart Van Assche
@ 2018-06-26  8:57   ` Johannes Thumshirn
  2018-06-26 15:25     ` Bart Van Assche
  0 siblings, 1 reply; 30+ messages in thread
From: Johannes Thumshirn @ 2018-06-26  8:57 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Omar Sandoval, linux-block

On Fri, Jun 22, 2018 at 03:19:46PM -0700, Bart Van Assche wrote:
>  tests/srp/functions | 1288 +++++++++++++++++++++++++++++++++++++++++++

Can you please move these into common/srp?

Thanks,
	Johannes

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-26  7:27         ` Johannes Thumshirn
@ 2018-06-26 15:24           ` Bart Van Assche
  2018-06-26 21:00             ` Omar Sandoval
  2018-06-27  7:04             ` Johannes Thumshirn
  0 siblings, 2 replies; 30+ messages in thread
From: Bart Van Assche @ 2018-06-26 15:24 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: ming.lei, osandov, tom.leiming, linux-block

On 06/26/18 00:27, Johannes Thumshirn wrote:
> On Tue, Jun 26, 2018 at 02:16:26AM +0000, Bart Van Assche wrote:
>> On Tue, 2018-06-26 at 09:37 +0800, Ming Lei wrote:
>>> I run SRP test on Fedora 27, and not run any LIO specific commands
>>> to load it, seems it is done automatically.
>>>
>>> So looks it might not a good idea to fail SRP test if LIO is loaded,
>>> just wondering why your SRP test can't make the two co-exist?
>>
>> The LIO configuration is system-wide. Only one configuration can be
>> loaded at any given time. I don't think that the SRP tests should wipe
>> any existing LIO configuration data if e.g. blktests is run accidentally
>> on a production server. I think that wiping LIO configuration data should
>> be a manual step.
> 
> I think this should be handled in requires(). I.e. check if LIO is
> already configured and then skip the test if it is.

As far as I know the requires() function is per test and there is no 
such function at the group level. I prefer to define this test once at 
the group level instead of copy/pasting the same test thirteen times in 
each test.

Bart.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers
  2018-06-26  8:57   ` Johannes Thumshirn
@ 2018-06-26 15:25     ` Bart Van Assche
  2018-06-26 21:01       ` Omar Sandoval
  0 siblings, 1 reply; 30+ messages in thread
From: Bart Van Assche @ 2018-06-26 15:25 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: Omar Sandoval, linux-block

On 06/26/18 01:58, Johannes Thumshirn wrote:
> On Fri, Jun 22, 2018 at 03:19:46PM -0700, Bart Van Assche wrote:
>>   tests/srp/functions | 1288 +++++++++++++++++++++++++++++++++++++++++++
> 
> Can you please move these into common/srp?

Let's do that once other tests than those in tests/srp need one or more 
of the functions defined in that file.

Bart.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-26 15:24           ` Bart Van Assche
@ 2018-06-26 21:00             ` Omar Sandoval
  2018-06-27  7:04             ` Johannes Thumshirn
  1 sibling, 0 replies; 30+ messages in thread
From: Omar Sandoval @ 2018-06-26 21:00 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Johannes Thumshirn, ming.lei, osandov, tom.leiming, linux-block

On Tue, Jun 26, 2018 at 08:24:51AM -0700, Bart Van Assche wrote:
> On 06/26/18 00:27, Johannes Thumshirn wrote:
> > On Tue, Jun 26, 2018 at 02:16:26AM +0000, Bart Van Assche wrote:
> > > On Tue, 2018-06-26 at 09:37 +0800, Ming Lei wrote:
> > > > I run SRP test on Fedora 27, and not run any LIO specific commands
> > > > to load it, seems it is done automatically.
> > > > 
> > > > So looks it might not a good idea to fail SRP test if LIO is loaded,
> > > > just wondering why your SRP test can't make the two co-exist?
> > > 
> > > The LIO configuration is system-wide. Only one configuration can be
> > > loaded at any given time. I don't think that the SRP tests should wipe
> > > any existing LIO configuration data if e.g. blktests is run accidentally
> > > on a production server. I think that wiping LIO configuration data should
> > > be a manual step.
> > 
> > I think this should be handled in requires(). I.e. check if LIO is
> > already configured and then skip the test if it is.
> 
> As far as I know the requires() function is per test and there is no such
> function at the group level. I prefer to define this test once at the group
> level instead of copy/pasting the same test thirteen times in each test.
> 
> Bart.

That's exactly what group_requires() is for, you even defined it :)

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers
  2018-06-26 15:25     ` Bart Van Assche
@ 2018-06-26 21:01       ` Omar Sandoval
  0 siblings, 0 replies; 30+ messages in thread
From: Omar Sandoval @ 2018-06-26 21:01 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Johannes Thumshirn, Omar Sandoval, linux-block

On Tue, Jun 26, 2018 at 08:25:40AM -0700, Bart Van Assche wrote:
> On 06/26/18 01:58, Johannes Thumshirn wrote:
> > On Fri, Jun 22, 2018 at 03:19:46PM -0700, Bart Van Assche wrote:
> > >   tests/srp/functions | 1288 +++++++++++++++++++++++++++++++++++++++++++
> > 
> > Can you please move these into common/srp?
> 
> Let's do that once other tests than those in tests/srp need one or more of
> the functions defined in that file.
> 
> Bart.

I moved things around just now to accomodate this sort of thing.
tests/foo/group is now tests/foo/rc, and that's where group-specific
functions should go, in addition to the group_requires() and
group_device_requires() definitions.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
                   ` (15 preceding siblings ...)
  2018-06-23  3:14 ` [PATCH blktests 00/15] Add SRP initiator driver tests Ming Lei
@ 2018-06-26 21:02 ` Omar Sandoval
  16 siblings, 0 replies; 30+ messages in thread
From: Omar Sandoval @ 2018-06-26 21:02 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Omar Sandoval, linux-block

On Fri, Jun 22, 2018 at 03:19:31PM -0700, Bart Van Assche wrote:
> Hello Omar,
> 
> As promised during LSF/MM, I have converted the srp-tests software to the
> blktests framework. This patch series included all blktests patches I postd
> a few days ago. Please consider this patch series for inclusion in the
> official blktests repository. Note: this patch series is also available as
> a github pull request, namely https://github.com/osandov/blktests/pull/24.
> 
> Thanks,
> 
> Bart.
> 
> Bart Van Assche (15):
>   common/rc: Fix _have_tracepoint()
>   Annotate include statements in shell scripts where the source file is
>     a variable
>   check, tests/meta/012: Use array["index"] instead of array[index]
>   Suppress shellcheck complaints about global variables
>   check: Avoid that shellcheck complains that $FULL appears unused
>   Multiple tests: remove unused and undefined variables
>   Avoid passing tests/block/002 arguments to _init_scsi_debug
>   check: Suppress a shellcheck warning about the DMESG_FILTER
>     initialization
>   Makefile: Do not suppress useful shellcheck warnings
>   tests/meta/group: Fix shellcheck complaints
>   make check: Also check tests/*/group files
>   check: Make TMPDIR absolute

I've applied all of these.

>   src/Makefile: Fix pattern rule
>   Add the discontiguous-io test program
>   Add tests for the SRP initiator and target drivers

For these, can you please reroll them with whatever group_requires()
check you need, and with the helper functions moved to tests/srp/rc.
Thanks!

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH blktests 00/15] Add SRP initiator driver tests
  2018-06-26 15:24           ` Bart Van Assche
  2018-06-26 21:00             ` Omar Sandoval
@ 2018-06-27  7:04             ` Johannes Thumshirn
  1 sibling, 0 replies; 30+ messages in thread
From: Johannes Thumshirn @ 2018-06-27  7:04 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: ming.lei, osandov, tom.leiming, linux-block

On Tue, Jun 26, 2018 at 08:24:51AM -0700, Bart Van Assche wrote:
> As far as I know the requires() function is per test and there is no such
> function at the group level. I prefer to define this test once at the group
> level instead of copy/pasting the same test thirteen times in each test.

No actually there is.
There is a group_requires() in the test/XXX/group file (check for
instance tests/group/nvme which has group_requires() calling
_have_root and a group_device_requires() calling _test_dev_is_nvme).

Byte,
	Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2018-06-27  7:04 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22 22:19 [PATCH blktests 00/15] Add SRP initiator driver tests Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 01/15] common/rc: Fix _have_tracepoint() Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 02/15] Annotate include statements in shell scripts where the source file is a variable Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 03/15] check, tests/meta/012: Use array["index"] instead of array[index] Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 04/15] Suppress shellcheck complaints about global variables Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 05/15] check: Avoid that shellcheck complains that $FULL appears unused Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 06/15] Multiple tests: remove unused and undefined variables Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 07/15] Avoid passing tests/block/002 arguments to _init_scsi_debug Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 08/15] check: Suppress a shellcheck warning about the DMESG_FILTER initialization Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 09/15] Makefile: Do not suppress useful shellcheck warnings Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 10/15] tests/meta/group: Fix shellcheck complaints Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 11/15] make check: Also check tests/*/group files Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 12/15] check: Make TMPDIR absolute Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 13/15] src/Makefile: Fix pattern rule Bart Van Assche
2018-06-25 22:54   ` Omar Sandoval
2018-06-22 22:19 ` [PATCH blktests 14/15] Add the discontiguous-io test program Bart Van Assche
2018-06-22 22:19 ` [PATCH blktests 15/15] Add tests for the SRP initiator and target drivers Bart Van Assche
2018-06-26  8:57   ` Johannes Thumshirn
2018-06-26 15:25     ` Bart Van Assche
2018-06-26 21:01       ` Omar Sandoval
2018-06-23  3:14 ` [PATCH blktests 00/15] Add SRP initiator driver tests Ming Lei
2018-06-23  3:19   ` Ming Lei
2018-06-25 17:05   ` Bart Van Assche
2018-06-26  1:37     ` Ming Lei
2018-06-26  2:16       ` Bart Van Assche
2018-06-26  7:27         ` Johannes Thumshirn
2018-06-26 15:24           ` Bart Van Assche
2018-06-26 21:00             ` Omar Sandoval
2018-06-27  7:04             ` Johannes Thumshirn
2018-06-26 21:02 ` Omar Sandoval

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.