Skip to contentSkip to conversation

blktests: Re-enable shellcheck warnings

PATCH In review Bart Van Assche 3 participants 20 messages Jun 19, 2018 – Jun 25, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover blktests: Re-enable shellcheck warnings

Hello Omar,

Since I noticed that several useful shellcheck warnings are suppressed in the blktests project, I came up with this patch series that reenables all shellcheck warnings and also suppresses false positive shellcheck reports. It would be appreciated if you could have a look at this patch series.

Thanks,

Bart.

Bart Van Assche (9):
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

 Makefile          | 15 +-------------
 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               |  1 +
 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/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 +
 67 files changed, 161 insertions(+), 50 deletions(-)
 create mode 100644 common/shellcheck
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/9 common/rc: Fix _have_tracepoint()

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

---
 common/rc | 2 ++
 1 file changed, 2 insertions(+)
common/rc +2 -0
index 7f1728025364..7592400dda82 100644
@@ -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
Signature · 1 line
2.17.1
Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] common/rc: Fix _have_tracepoint()

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#3 lore raw

PATCH 2/9 Annotate include statements in shell scripts where the source file is a variable

In reply to Bart Van Assche

This causes shellcheck to stop complaining about these include statements.

---
 check | 3 +++
 1 file changed, 3 insertions(+)
check +3 -0
index 4baa8dde2436..5e1ba7bc8401 100755
@@ -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
Signature · 1 line
2.17.1
Reviewed-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] Annotate include statements in shell scripts where the source file is a variable

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#5 lore raw

PATCH 3/9 check, tests/meta/012: Use array["index"] instead of array[index]

In reply to Bart Van Assche

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

---
 check          | 46 +++++++++++++++++++++++-----------------------
 tests/meta/012 |  4 ++--
 2 files changed, 25 insertions(+), 25 deletions(-)
check +23 -23
index 5e1ba7bc8401..5f53fa105f72 100755
@@ -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:"
@@ -432,7 +432,7 @@ _run_test() {
 
 _run_group() {
 	local tests=("$@")
-	local group="${tests[0]%/*}"
+	local group="${tests["0"]%/*}"
 
 	# shellcheck disable=SC1090
 	. "tests/${group}/group"
tests/meta/012 +2 -2
index fcf8fbdde2aa..ab8c2a73eaa5 100755
@@ -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"
 }
Signature · 1 line
2.17.1
Reviewed-by on v1 3/9
#6 lore raw

Re: [PATCH 3/9] check, tests/meta/012: Use array["index"] instead of array[index]

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#7 lore raw

PATCH 4/9 Suppress shellcheck complaints about global variables

In reply to 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

---
 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               | 1 +
 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, 121 insertions(+)
 create mode 100644 common/shellcheck
common/cpuhotplug +2 -0
index 70b284f7b7aa..9f43615a8f64 100644
@@ -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=()
common/fio +2 -0
index 0f93632c0382..949796810a0c 100644
@@ -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
common/iopoll +2 -0
index affdd4332dc2..10ebd16923ad 100644
@@ -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
common/loop +1 -0
index 16cc3212a028..28071840ed9b 100644
@@ -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
common/nbd +2 -0
index 320f456e0bd8..2e0186482989 100644
@@ -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
common/nvme +2 -0
index 044d7fe94c65..0060f3e29573 100644
@@ -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"
common/scsi +2 -0
index d9fcc0e15909..eb5a3ddc708f 100644
@@ -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
 }
common/shellcheck new file +4 -0
new file mode 100644
index 000000000000..1ec759976dd7
@@ -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
new +1 -0
index 923d6b737986..d8a0ad34b8df 100755
@@ -18,6 +18,7 @@
 set -e
 
 . common/rc
+. common/shellcheck
 
 prompt_yes_no() {
 	if [[ $2 =~ ^[Yy] ]]; then
tests/block/001 +1 -0
index 7411a0cf04f6..8016265d11e3 100755
@@ -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
tests/block/002 +1 -0
index 57b4f8984095..32a0f818b95b 100755
@@ -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
tests/block/003 +2 -0
index 87e30a36e8c2..e73e4fc60fbe 100755
@@ -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
 
tests/block/004 +2 -0
index 754d30260d63..59e157b1c337 100755
@@ -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
 
tests/block/005 +2 -0
index fae59272f90b..2e6dd38cc931 100755
@@ -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
 
tests/block/006 +2 -0
index 0a472935a481..be4b6c7560b3 100755
@@ -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
 
tests/block/007 +1 -0
index e35649ad96cd..15709fffd4fd 100755
@@ -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
tests/block/009 +1 -0
index cbeeb70701fa..7d6afe9694eb 100755
@@ -22,6 +22,7 @@
 DESCRIPTION="check page-cache coherency after BLKDISCARD"
 
 . common/scsi_debug
+. common/shellcheck
 
 requires() {
 	_have_scsi_debug && _have_program xfs_io
tests/block/010 +2 -0
index 97891d229c0f..bbe714101aee 100644
@@ -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
 
tests/block/011 +2 -0
index 24614420461e..ab02f90f2069 100755
@@ -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
 
tests/block/012 +2 -0
index baabdd68b655..2c1b761ba063 100755
@@ -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
 
tests/block/013 +2 -0
index 415b34dcc5ef..8f386313cd2b 100755
@@ -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
 
tests/block/014 +2 -0
index 882a9b9f5015..f5503ee9683c 100755
@@ -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() {
tests/block/015 +2 -0
index b236a6d36bf8..0c9daa6be13e 100755
@@ -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
tests/block/016 +2 -0
index 6ccfe98f54ce..5a1ff33c34fb 100755
@@ -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
 
tests/block/017 +2 -0
index 436a8f336155..e9ca282750ba 100755
@@ -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
 
tests/block/018 +2 -0
index 548f1baeaf59..21421b869c18 100755
@@ -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
 
tests/block/019 +2 -0
index 00830d02b67a..f099d9392688 100755
@@ -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
 
tests/block/020 +2 -0
index 36140136369b..7db1b5a0d422 100755
@@ -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
 
tests/block/021 +2 -0
index 74fa709a8e04..df5dc9b101ba 100755
@@ -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
 
tests/loop/001 +2 -0
index 1f009bdd1439..83103dc5e9c9 100755
@@ -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
 
tests/loop/003 +2 -0
index fe4e2e1ed19b..353d4fcfa33c 100755
@@ -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
 
tests/loop/005 +2 -0
index b57ddb3d6f1a..d00f4bd06f73 100755
@@ -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
tests/meta/001 +2 -0
index 454fb22554a3..d5b8c0665f7b 100755
@@ -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() {
tests/meta/002 +2 -0
index 5a2cd53f2318..50cdd5a3487c 100755
@@ -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() {
tests/meta/003 +2 -0
index eb79bca15ffb..e07e01efd697 100755
@@ -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() {
tests/meta/004 +2 -0
index bafe6c5e8da8..37d0e4649d56 100755
@@ -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() {
tests/meta/005 +2 -0
index c9909c64c022..1a4018af2d21 100755
@@ -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() {
tests/meta/006 +2 -0
index 9d28bdce01d8..4d0786177555 100755
@@ -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() {
tests/meta/007 +2 -0
index 2516796a333d..13acfdb8ef42 100755
@@ -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() {
tests/meta/008 +2 -0
index 5d24669b290e..acea355c4d91 100755
@@ -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() {
tests/meta/009 +2 -0
index abeb56e6ad4f..989ce8ccf053 100755
@@ -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() {
tests/meta/010 +2 -0
index c179dad3d7c7..1e7e9da7d3fa 100755
@@ -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
 
tests/meta/011 +2 -0
index 010ba4b142b8..df1f7e584622 100755
@@ -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"
 
tests/meta/012 +2 -0
index ab8c2a73eaa5..ecc1db296f32 100755
@@ -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() {
tests/nbd/001 +2 -0
index 73ccaec1305a..cee62412599a 100644
@@ -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
 
tests/nbd/002 +2 -0
index c06c94631aab..6d6b3cddf1c6 100644
@@ -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
 
tests/nvme/001 +2 -0
index 0b5f241efcce..ada60f3b2270 100755
@@ -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
tests/nvme/002 +2 -0
index 786505e22256..59474f7d7574 100755
@@ -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() {
tests/nvme/003 +2 -0
index 96341309baf6..9b168cb48278 100755
@@ -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
tests/nvme/004 +2 -0
index ad268e2eec83..9d087266bfa1 100755
@@ -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
 
tests/nvme/005 +2 -0
index f993019aa1d4..5c582bc38707 100755
@@ -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
tests/nvme/006 +2 -0
index ecf0c334ae8b..ebdd50f61ff3 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF target with a block device-backed ns"
 QUICK=1
 
tests/nvme/007 +2 -0
index 02633131b868..138bfead51bb 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF target with a file-backed ns"
 QUICK=1
 
tests/nvme/008 +2 -0
index dd62b25c5335..3b69809bb8fa 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF host with a block device-backed ns"
 QUICK=1
 
tests/nvme/009 +2 -0
index 0372788fef39..311e8171ca70 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="create an NVMeOF host with a file-backed ns"
 QUICK=1
 
tests/nvme/010 +2 -0
index 9b31167c4988..956c6597a374 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
tests/nvme/011 +2 -0
index 6cd20fa26855..872a99af4f8c 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
tests/nvme/012 +2 -0
index 255101101a18..8f632b30734d 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
tests/nvme/013 +2 -0
index 4bb49fa8f966..0ccb083b175b 100755
@@ -20,6 +20,8 @@
 #   Author: Chaitanya Kulkarni <[email protected]>
 #
 
+. common/shellcheck
+
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
tests/scsi/001 +2 -0
index 17fc0880e654..08ad78489e0f 100755
@@ -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
 
tests/scsi/002 +2 -0
index da2d0cc77aa0..ce037f0bbe79 100755
@@ -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
 
tests/scsi/003 +2 -0
index 81015f02f6b3..8c08cbdfe6a5 100755
@@ -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
 
tests/scsi/004 +1 -0
index 8c61d1e438f3..8bebb18d2554 100755
@@ -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"
 
Signature · 1 line
2.17.1
Reviewed-by on v1 4/9
#8 lore raw

Re: [PATCH 4/9] Suppress shellcheck complaints about global variables

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#9 lore raw

PATCH 5/9 check: Avoid that shellcheck complains that $FULL appears unused

In reply to Bart Van Assche

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

---
 check | 2 ++
 1 file changed, 2 insertions(+)
check +2 -0
index 5f53fa105f72..f1feb96b293e 100755
@@ -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
Signature · 1 line
2.17.1
Reviewed-by on v1 5/9
#10 lore raw

Re: [PATCH 5/9] check: Avoid that shellcheck complains that $FULL appears unused

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#11 lore raw

PATCH 6/9 Multiple tests: remove unused and undefined variables

In reply to Bart Van Assche
Cc Chaitanya Kulkarni <[email protected]>
---
 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(-)
tests/loop/003 +0 -3
index 353d4fcfa33c..6f6fa8d18ebe 100755
@@ -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"
tests/nvme/010 +1 -2
index 956c6597a374..b6849dbad375 100755
@@ -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
tests/nvme/011 +1 -2
index 872a99af4f8c..f26eb155809c 100755
@@ -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
tests/nvme/012 +0 -1
index 8f632b30734d..e570793dd5db 100755
@@ -38,7 +38,6 @@ test() {
 	modprobe nvme-loop
 
 	local port
-	local ret=0
 	local nvmedev
 	local loop_dev
 	local mount_dir="/mnt/blktests"
tests/nvme/013 +0 -1
index 0ccb083b175b..247fe9f252fa 100755
@@ -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"
Signature · 1 line
2.17.1
Reviewed-by on v1 6/9
#12 lore raw

Re: [PATCH 6/9] Multiple tests: remove unused and undefined variables

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#13 lore raw

PATCH 7/9 Avoid passing tests/block/002 arguments to _init_scsi_debug

In reply to 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]

---
 common/scsi_debug | 3 +++
 tests/block/002   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
common/scsi_debug +3 -0
index e26e85637369..d8e6b71899a3 100644
@@ -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
tests/block/002 +1 -1
index 32a0f818b95b..10e3f157c018 100755
@@ -31,7 +31,7 @@ requires() {
 test() {
 	echo "Running ${TEST_NAME}"
 
-	if ! _init_scsi_debug; then
+	if ! _init_scsi_debug --; then
 		return 1
 	fi
 
Signature · 1 line
2.17.1
Reviewed-by on v1 7/9
#14 lore raw

Re: [PATCH 7/9] Avoid passing tests/block/002 arguments to _init_scsi_debug

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#15 lore raw

PATCH 8/9 check: Suppress a shellcheck warning about the DMESG_FILTER initialization

In reply to 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]

---
 check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check +1 -1
index f1feb96b293e..e7439e163884 100755
@@ -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}"
Signature · 1 line
2.17.1
Reviewed-by on v1 8/9
#16 lore raw

Re: [PATCH 8/9] check: Suppress a shellcheck warning about the DMESG_FILTER initialization

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#17 lore raw

PATCH 9/9 Makefile: Do not suppress useful shellcheck warnings

In reply to 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").

---
 Makefile | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
Makefile +1 -14
index 14ba8341dae5..c4bffa2d3f32 100644
@@ -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
Signature · 1 line
2.17.1
Reviewed-by on v1 9/9
#18 lore raw

Re: [PATCH 9/9] Makefile: Do not suppress useful shellcheck warnings

Looks good,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +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
#19 lore raw
In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche

Hello Omar,

Since I noticed that several useful shellcheck warnings are suppressed in the blktests project, I came up with this patch series that reenables all shellcheck warnings and also suppresses false positive shellcheck reports. It would be appreciated if you could have a look at this patch series.

Thanks,

Quoted 8 lines

Bart.

Bart Van Assche (9):

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]

Applied these.

Quoted 2 lines

Suppress shellcheck complaints about global variables
check: Avoid that shellcheck complains that $FULL appears unused

These are definitely useful warnings that would be good to reenable, but I'm not a huge fan of this fix. Adding boilerplate for the sake of appeasing the linter is... meh. I think what we can do is make the tests/foo/group and common/rc sourcing explicit and put the workaround stuff in common/rc. Still boilerplate but it at least appears to serve a real purpose. I'll work on that.

Quoted 1 line

Multiple tests: remove unused and undefined variables

Applied this one.

Quoted 1 line

Avoid passing tests/block/002 arguments to _init_scsi_debug

This warning is stupid, I'd prefer to keep it disabled.

Quoted 2 lines

check: Suppress a shellcheck warning about the DMESG_FILTER
initialization

This warning is also pretty pointless, but the fix is so trivial that I applied it anyways.

Quoted 1 line

Makefile: Do not suppress useful shellcheck warnings

Of course, I had to replace this patch since I kept some of the warnings in.

Thanks for the cleanup!

Quoted 73 lines
 Makefile          | 15 +-------------
 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               |  1 +
 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/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 +
 67 files changed, 161 insertions(+), 50 deletions(-)
 create mode 100644 common/shellcheck
Signature · 1 line
2.17.1