test: shellcheck - apply rule SC2002

SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Minor fix in test_converter: don't use python3 as
    config_converter.py is executable.

Change-Id: I250e893b48fa95e94778dcc31deb91e6ac0b39c0
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481600
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Pawel Kaminski 2020-01-14 07:03:17 -05:00 committed by Tomasz Zawadzki
parent 989261d6c3
commit 13c6c8db6e
10 changed files with 23 additions and 23 deletions

View File

@ -240,7 +240,7 @@ if hash shellcheck 2>/dev/null; then
# go to: https://trello.com/c/29Z90j1W
# Error descriptions can also be found at: https://github.com/koalaman/shellcheck/wiki
# This SHCK_EXCLUDE list is out "to do" and we work to fix all of this errors.
SHCK_EXCLUDE="SC2002,SC2010"
SHCK_EXCLUDE="SC2010"
# SPDK fails some error checks which have been deprecated in later versions of shellcheck.
# We will not try to fix these error checks, but instead just leave the error types here
# so that we can still run with older versions of shellcheck.
@ -267,8 +267,8 @@ if hash shellcheck 2>/dev/null; then
# or split robustly with mapfile or read -a.
# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
# SC2223: This default assignment may cause DoS due to globbing. Quote it.
SHCK_EXCLUDE="$SHCK_EXCLUDE,SC1083,SC1090,SC1091,SC2015,SC2016,SC2034,SC2046,SC2086,SC2119,SC2120,\
SC2148,SC2153,SC2154,SC2164,SC2174,SC2001,SC2206,SC2207,SC2223"
SHCK_EXCLUDE="$SHCK_EXCLUDE,SC1083,SC1090,SC1091,SC2015,SC2016,SC2034,SC2046,SC2086,\
SC2119,SC2120,SC2148,SC2153,SC2154,SC2164,SC2174,SC2001,SC2206,SC2207,SC2223"
SHCK_FORMAT="diff"
SHCK_APPLY=true

View File

@ -16,8 +16,8 @@ function on_error_exit() {
trap 'on_error_exit' ERR
cat $CONVERTER_DIR/config.ini | python3 $SPDK_BUILD_DIR/scripts/config_converter.py > $CONVERTER_DIR/config_converter.json
cat $CONVERTER_DIR/config_virtio.ini | python3 $SPDK_BUILD_DIR/scripts/config_converter.py > $CONVERTER_DIR/config_virtio_converter.json
$SPDK_BUILD_DIR/scripts/config_converter.py < $CONVERTER_DIR/config.ini > $CONVERTER_DIR/config_converter.json
$SPDK_BUILD_DIR/scripts/config_converter.py < $CONVERTER_DIR/config_virtio.ini > $CONVERTER_DIR/config_virtio_converter.json
diff -I "cpumask" -I "max_queue_depth" -I "queue_depth" <(jq -S . $CONVERTER_DIR/config_converter.json) <(jq -S . $CONVERTER_DIR/spdk_config.json)
diff <(jq -S . $CONVERTER_DIR/config_virtio_converter.json) <(jq -S . $CONVERTER_DIR/spdk_config_virtio.json)
test_cleanup

View File

@ -105,7 +105,7 @@ do
$rpc_py iscsi_create_target_node Target${i} Target${i}_alias "${bdevs[i]}:0" "$PORTAL_TAG:$INITIATOR_TAG" 64 -d
done
cat $testdir/perf.job | ssh_initiator "cat > perf.job"
ssh_initiator "cat > perf.job" < $testdir/perf.job
rm -f $testdir/perf.job
timing_exit iscsi_config

View File

@ -11,7 +11,7 @@ spdk_tgt_pid=$!
waitforlisten $spdk_tgt_pid
# Test deprecated rpcs in json
cat $testdir/conf.json | $rootdir/scripts/rpc.py load_config -i
$rootdir/scripts/rpc.py load_config -i < $testdir/conf.json
# Test deprecated rpcs in rpc.py
$rootdir/scripts/rpc.py delete_malloc_bdev "Malloc0"

View File

@ -25,8 +25,8 @@ tmp_file_1=$(mktemp /tmp/$(basename ${1}).XXX)
tmp_file_2=$(mktemp /tmp/$(basename ${2}).XXX)
ret=0
cat $1 | $python_cmd $rootdir/test/json_config/config_filter.py -method "sort" > $tmp_file_1
cat $2 | $python_cmd $rootdir/test/json_config/config_filter.py -method "sort" > $tmp_file_2
$python_cmd $rootdir/test/json_config/config_filter.py -method "sort" < $1 > $tmp_file_1
$python_cmd $rootdir/test/json_config/config_filter.py -method "sort" < $2 > $tmp_file_2
if ! diff -u $tmp_file_1 $tmp_file_2; then
ret=1

View File

@ -27,7 +27,7 @@ function replace_defined_variables() {
fi
done
for dep in "${bad_values[@]}"; do
dep_def_arr=($(cat $libdeps_file | grep -v "#" | grep "${dep}" | cut -d "=" -f 2 | xargs))
dep_def_arr=($(grep -v "#" $libdeps_file | grep "${dep}" | cut -d "=" -f 2 | xargs))
new_values=($(replace_defined_variables "${dep_def_arr[@]}"))
good_values=( "${good_values[@]}" "${new_values[@]}" )
done
@ -42,7 +42,7 @@ function confirm_deps() {
#keep the space here to differentiate bdev and bdev_*
lib_shortname=$(basename $lib | sed 's,libspdk_,,g' | sed 's,\.so, ,g')
lib_make_deps=($(cat $libdeps_file | grep "DEPDIRS-${lib_shortname}" | cut -d "=" -f 2 | xargs))
lib_make_deps=($(grep "DEPDIRS-${lib_shortname}" $libdeps_file | cut -d "=" -f 2 | xargs))
lib_make_deps=($(replace_defined_variables "${lib_make_deps[@]}"))
for ign_dep in "${IGNORED_LIBS[@]}"; do

View File

@ -135,7 +135,7 @@ timing_exit wait_for_example
trap - SIGINT SIGTERM EXIT
qemupid=$(cat "$qemu_pidfile" | awk '{printf $0}')
qemupid=$(awk '{printf $0}' "$qemu_pidfile")
kill -9 $qemupid
rm "$qemu_pidfile"
rm "$test_img"

View File

@ -239,42 +239,42 @@ function get_results(){
case "$1" in
iops)
iops=$(cat $NVME_FIO_RESULTS | jq -r '.jobs[] | (.read.iops + .write.iops)')
iops=$(jq -r '.jobs[] | (.read.iops + .write.iops)' $NVME_FIO_RESULTS)
iops=${iops%.*}
echo $iops
;;
mean_lat_usec)
mean_lat=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.lat_ns.mean * $reads_pct + .write.lat_ns.mean * $writes_pct)")
mean_lat=$(jq -r ".jobs[] | (.read.lat_ns.mean * $reads_pct + .write.lat_ns.mean * $writes_pct)" $NVME_FIO_RESULTS)
mean_lat=${mean_lat%.*}
echo $(( mean_lat/100000 ))
;;
p99_lat_usec)
p99_lat=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.clat_ns.percentile.\"99.000000\" * $reads_pct + .write.clat_ns.percentile.\"99.000000\" * $writes_pct)")
p99_lat=$(jq -r ".jobs[] | (.read.clat_ns.percentile.\"99.000000\" * $reads_pct + .write.clat_ns.percentile.\"99.000000\" * $writes_pct)" $NVME_FIO_RESULTS)
p99_lat=${p99_lat%.*}
echo $(( p99_lat/100000 ))
;;
p99_99_lat_usec)
p99_99_lat=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.clat_ns.percentile.\"99.990000\" * $reads_pct + .write.clat_ns.percentile.\"99.990000\" * $writes_pct)")
p99_99_lat=$(jq -r ".jobs[] | (.read.clat_ns.percentile.\"99.990000\" * $reads_pct + .write.clat_ns.percentile.\"99.990000\" * $writes_pct)" $NVME_FIO_RESULTS)
p99_99_lat=${p99_99_lat%.*}
echo $(( p99_99_lat/100000 ))
;;
stdev_usec)
stdev=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.clat_ns.stddev * $reads_pct + .write.clat_ns.stddev * $writes_pct)")
stdev=$(jq -r ".jobs[] | (.read.clat_ns.stddev * $reads_pct + .write.clat_ns.stddev * $writes_pct)" $NVME_FIO_RESULTS)
stdev=${stdev%.*}
echo $(( stdev/100000 ))
;;
mean_slat_usec)
mean_slat=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.slat_ns.mean * $reads_pct + .write.slat_ns.mean * $writes_pct)")
mean_slat=$(jq -r ".jobs[] | (.read.slat_ns.mean * $reads_pct + .write.slat_ns.mean * $writes_pct)" $NVME_FIO_RESULTS)
mean_slat=${mean_slat%.*}
echo $(( mean_slat/100000 ))
;;
mean_clat_usec)
mean_clat=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.clat_ns.mean * $reads_pct + .write.clat_ns.mean * $writes_pct)")
mean_clat=$(jq -r ".jobs[] | (.read.clat_ns.mean * $reads_pct + .write.clat_ns.mean * $writes_pct)" $NVME_FIO_RESULTS)
mean_clat=${mean_clat%.*}
echo $(( mean_clat/100000 ))
;;
bw_Kibs)
bw=$(cat $NVME_FIO_RESULTS | jq -r ".jobs[] | (.read.bw + .write.bw)")
bw=$(jq -r ".jobs[] | (.read.bw + .write.bw)" $NVME_FIO_RESULTS)
bw=${bw%.*}
echo $(( bw ))
;;

View File

@ -990,7 +990,7 @@ function vm_start_fio_server()
for vm_num in "$@"; do
notice "Starting fio server on VM$vm_num"
if [[ $fio_bin != "" ]]; then
cat $fio_bin | vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio'
vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio' < $fio_bin
vm_exec $vm_num /root/fio $readonly --eta=never --server --daemonize=/root/fio.pid
else
vm_exec $vm_num fio $readonly --eta=never --server --daemonize=/root/fio.pid
@ -1092,7 +1092,7 @@ function run_fio()
vm_exec $vm_num cat /root/$job_fname
if ! $run_server_mode; then
if [[ -n "$fio_bin" ]]; then
cat $fio_bin | vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio'
vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio' < $fio_bin
fi
notice "Running local fio on VM $vm_num"

View File

@ -194,7 +194,7 @@ if [[ $run_precondition == true ]]; then
# Using the same precondition routine possible for lvols thanks
# to --clear-method option. Lvols should not UNMAP on creation.
$rootdir/scripts/gen_nvme.sh > $rootdir/nvme.cfg
mapfile -t nvmes < <(cat $rootdir/nvme.cfg | grep -oP "Nvme\d+")
mapfile -t nvmes < <(grep -oP "Nvme\d+" $rootdir/nvme.cfg)
fio_filename=$(printf ":%sn1" "${nvmes[@]}")
fio_filename=${fio_filename:1}
$precond_fio_bin --name="precondition" \