blktests: Re-enable shellcheck warnings
Subsystems (2)
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
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
@@ -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
PATCH 7/9 Avoid passing tests/block/002 arguments to _init_scsi_debug
In reply to Bart Van AsscheThis 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
@@ -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
@@ -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
PATCH 9/9 Makefile: Do not suppress useful shellcheck warnings
In reply to Bart Van AsscheAll 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
@@ -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
PATCH 2/9 Annotate include statements in shell scripts where the source file is a variable
In reply to Bart Van AsscheThis causes shellcheck to stop complaining about these include statements.
--- check | 3 +++ 1 file changed, 3 insertions(+)
check +3 -0
@@ -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
PATCH 3/9 check, tests/meta/012: Use array["index"] instead of array[index]
In reply to Bart Van AsscheThis 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
@@ -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
@@ -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
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
@@ -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
PATCH 6/9 Multiple tests: remove unused and undefined variables
In reply to Bart Van Assche--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 4/9 Suppress shellcheck complaints about global variables
In reply to Bart Van AsscheAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -18,6 +18,7 @@ set -e . common/rc +. common/shellcheck prompt_yes_no() { if [[ $2 =~ ^[Yy] ]]; then
tests/block/001 +1 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 8/9 check: Suppress a shellcheck warning about the DMESG_FILTER initialization
In reply to Bart Van AsscheAvoid 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
@@ -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
Re: [PATCH 1/9] common/rc: Fix _have_tracepoint()
In reply to Bart Van AsscheLooks 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
Re: [PATCH 2/9] Annotate include statements in shell scripts where the source file is a variable
In reply to Bart Van AsscheLooks 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
Re: [PATCH 3/9] check, tests/meta/012: Use array["index"] instead of array[index]
In reply to Bart Van AsscheLooks 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
Re: [PATCH 4/9] Suppress shellcheck complaints about global variables
In reply to Bart Van AsscheLooks 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
Re: [PATCH 5/9] check: Avoid that shellcheck complains that $FULL appears unused
In reply to Bart Van AsscheLooks 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
Re: [PATCH 6/9] Multiple tests: remove unused and undefined variables
In reply to Bart Van AsscheLooks 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
Re: [PATCH 7/9] Avoid passing tests/block/002 arguments to _init_scsi_debug
In reply to Bart Van AsscheLooks 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
Re: [PATCH 8/9] check: Suppress a shellcheck warning about the DMESG_FILTER initialization
In reply to Bart Van AsscheLooks 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
Re: [PATCH 9/9] Makefile: Do not suppress useful shellcheck warnings
In reply to Bart Van AsscheLooks 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
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/shellcheckSignature · 1 line
2.17.1