diff --git a/agent/bench-scripts/pbench-fio b/agent/bench-scripts/pbench-fio index f28b04453b..c9875ecbae 100755 --- a/agent/bench-scripts/pbench-fio +++ b/agent/bench-scripts/pbench-fio @@ -527,8 +527,7 @@ function fio_pre_check() { fi if [[ ${do_local_pre_check} -eq 1 ]]; then debug_log "Running pre-check locally" - local_pre_check "${devs}" "${ver}" "${match}" - rc=${?} + local_pre_check "${devs}" "${ver}" "${match}" || rc=${?} fi if [[ ${rc} -ne 0 ]]; then error_log "pre-check(s) failed, exiting" diff --git a/agent/bench-scripts/pbench-uperf b/agent/bench-scripts/pbench-uperf index fd9384e77b..7289fa22fa 100755 --- a/agent/bench-scripts/pbench-uperf +++ b/agent/bench-scripts/pbench-uperf @@ -197,11 +197,11 @@ function local_pre_check { local _ver="${1}" local _match="${2}" - resolve_benchmark_bin_err="$(resolve_benchmark_bin "${benchmark}" 2>&1)" - if [[ ${?} -ne 0 ]]; then - error_log "${script_name}: ${benchmark} executable not found, '${resolve_benchmark_bin_err}'" - exit 1 - fi + resolve_benchmark_bin_err="$(resolve_benchmark_bin "${benchmark}" 2>&1)" + if [[ ${?} -ne 0 ]]; then + error_log "${script_name}: ${benchmark} executable not found, '${resolve_benchmark_bin_err}'" + exit 1 + fi local ver_installed=$(${benchmark} -V | awk 'NR==1 {print $3}') vercmp "${benchmark}" "${_match}" "${_ver}" "${ver_installed}" diff --git a/agent/bench-scripts/test-bin/fio b/agent/bench-scripts/test-bin/fio index 257ca8b14b..d12aee42cd 100755 --- a/agent/bench-scripts/test-bin/fio +++ b/agent/bench-scripts/test-bin/fio @@ -5,7 +5,7 @@ echo "$0 $*" >> $_testlog # Mock fio command behaviors. if [[ "${1%%=*}" == "--client" ]]; then client_file=${1##*=} - for line in $(cat ${client_file}); do + for line in $(< ${client_file}); do ip_name="${line%%,*}" client="${ip_name#*:}" if [[ "${client%%.*}" == "hist" ]]; then diff --git a/agent/bench-scripts/test-bin/mock-cmd b/agent/bench-scripts/test-bin/mock-cmd index 100952d126..5a6ff11154 100755 --- a/agent/bench-scripts/test-bin/mock-cmd +++ b/agent/bench-scripts/test-bin/mock-cmd @@ -8,13 +8,6 @@ fi prog="$(basename "${0}")" args=( "${@}" ) -lastidx=$((${#args[@]} - 1)) -# avoid "bad array subscript" error -if [[ "${lastidx}" -lt 0 ]] ;then - exit 0 -fi - -last=${args[${lastidx}]} if [[ "${prog}" == "pbench-tool-meister-start" ]]; then echo [pbench] > ${benchmark_run_dir}/metadata.log elif [[ "${prog}" == "cat" && "${args[0]}" == "/proc/cmdline" ]]; then diff --git a/agent/bench-scripts/test-bin/which b/agent/bench-scripts/test-bin/which index ebfbdf170e..c6bdd0cb37 100755 --- a/agent/bench-scripts/test-bin/which +++ b/agent/bench-scripts/test-bin/which @@ -1,12 +1,14 @@ #!/bin/bash -args=( "${@}" ) -lastidx=$((${#args[@]} - 1)) -# avoid "bad array subscript" error -if [[ "${lastidx}" -lt 0 ]] ;then - exit 0 +# Mock the operation of `which` so that the value of `PATH` is never emitted +# during the test runs, thus avoiding it landing in a gold file. + +if [[ $# -eq 0 ]] ;then + echo "$0 requires at least one argument" >&2 + exit 255 fi -last=${args[${lastidx}]} +args=( "${@}" ) +last=${args[-1]} stdout=$(/usr/bin/which ${last} 2> /dev/null) res=${?} diff --git a/agent/bench-scripts/unittests b/agent/bench-scripts/unittests index f2e3a991cb..8d31185820 100755 --- a/agent/bench-scripts/unittests +++ b/agent/bench-scripts/unittests @@ -171,7 +171,7 @@ function _dump_logs { for f in $(find . -name results.html 2> /dev/null | sort); do _dump_file ${rundir} ${f:2} done - for f in $(find . \( -name '*--client_start.sh' -o -name '*--server_start.sh' \) 2> /dev/null | sort); do + for f in $(find . -name '*--client_start.sh' -o -name '*--server_start.sh' 2> /dev/null | sort); do _dump_file ${rundir} ${f:2} done fi