Skip to content

Commit

Permalink
Replace which with command -v
Browse files Browse the repository at this point in the history
  • Loading branch information
portante committed May 24, 2022
1 parent 877698f commit 42a8d12
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 39 deletions.
6 changes: 4 additions & 2 deletions agent/base
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ function generate_inventory {

function resolve_benchmark_bin {
# Encapsulation of method for resolving the actual benchmark
# binary.
which --skip-alias --skip-functions "${1}"
# binary ignoring `bash` aliases and functions.
unalias "${1}" > /dev/null 2>&1
unset -f "${1}" > /dev/null 2>&1
command -v "${1}"
}

function vercmp {
Expand Down
4 changes: 2 additions & 2 deletions agent/bench-scripts/pbench-fio
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ function local_pre_check() {

debug_log "local_pre_check(devs=\"${devs}\", ver=\"${ver}\", match=\"${match}\")"

resolve_benchmark_bin_err="$(resolve_benchmark_bin "${benchmark}" 2>&1)"
resolve_benchmark_bin "${benchmark}" > /dev/null 2>&1
if [[ ${?} -ne 0 ]]; then
error_log "[${script_name}] ${benchmark} executable not found, '${resolve_benchmark_bin_err}'"
error_log "[${script_name}] ${benchmark} executable not found"
exit 1
fi

Expand Down
4 changes: 2 additions & 2 deletions agent/bench-scripts/pbench-uperf
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ function local_pre_check {
local _ver="${1}"
local _match="${2}"

resolve_benchmark_bin_err="$(resolve_benchmark_bin "${benchmark}" 2>&1)"
resolve_benchmark_bin "${benchmark}" > /dev/null 2>&1
if [[ ${?} -ne 0 ]]; then
error_log "${script_name}: ${benchmark} executable not found, '${resolve_benchmark_bin_err}'"
error_log "${script_name}: ${benchmark} executable not found"
exit 1
fi

Expand Down
20 changes: 0 additions & 20 deletions agent/bench-scripts/test-bin/which

This file was deleted.

4 changes: 2 additions & 2 deletions agent/bench-scripts/tests/pbench-fio/test-22.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+++ Running test-22 pbench-fio
[error][1900-01-01T00:00:00.000000] [pbench-fio] fio executable not found, 'which: no fio in ($PATH)'
[error][1900-01-01T00:00:00.000000] [pbench-fio] fio executable not found
--- Finished test-22 pbench-fio (status=1)
+++ pbench tree state
/var/tmp/pbench-test-bench/pbench-agent
Expand All @@ -15,5 +15,5 @@
[debug][1900-01-01T00:00:00.000000] fio_pre_check(targets="/tmp/fio", clients="", ver="3.21", match="gte")
[debug][1900-01-01T00:00:00.000000] Running pre-check locally
[debug][1900-01-01T00:00:00.000000] local_pre_check(devs="", ver="3.21", match="gte")
[error][1900-01-01T00:00:00.000000] [pbench-fio] fio executable not found, 'which: no fio in ($PATH)'
[error][1900-01-01T00:00:00.000000] [pbench-fio] fio executable not found
--- pbench.log file contents
4 changes: 2 additions & 2 deletions agent/bench-scripts/tests/pbench-uperf/test-02.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+++ Running test-02 pbench-uperf
[error][1900-01-01T00:00:00.000000] pbench-uperf: uperf executable not found, 'which: no uperf in ($PATH)'
[error][1900-01-01T00:00:00.000000] pbench-uperf: uperf executable not found
--- Finished test-02 pbench-uperf (status=1)
+++ pbench tree state
/var/tmp/pbench-test-bench/pbench-agent
Expand All @@ -12,5 +12,5 @@
/var/tmp/pbench-test-bench/pbench-agent/tools-v1-default/testhost.example.com/sar
--- pbench tree state
+++ pbench.log file contents
[error][1900-01-01T00:00:00.000000] pbench-uperf: uperf executable not found, 'which: no uperf in ($PATH)'
[error][1900-01-01T00:00:00.000000] pbench-uperf: uperf executable not found
--- pbench.log file contents
3 changes: 0 additions & 3 deletions agent/bench-scripts/unittests
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ PATH=$(remove_path /opt/pbench-agent/util-scripts ${PATH})
# Allows us to intercept scp, ssh, rsync, etc.
export PATH=${_testopt}/unittest-scripts:${_testopt}/util-scripts:${_testopt}/bench-scripts:${PATH}

# Allow us to intercept "which".
unset -f which

# Fixed timestamp output
export _PBENCH_UNIT_TESTS=1

Expand Down
2 changes: 1 addition & 1 deletion agent/rpm/pbench-agent.spec.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Requires: perl-Time-HiRes

Requires: bc, bzip2, hostname, iproute, iputils, net-tools
Requires: openssh-clients, openssh-server, procps-ng, psmisc, redis
Requires: rpmdevtools, rsync, screen, sos, tar, which, xz
Requires: rpmdevtools, rsync, screen, sos, tar, xz

Obsoletes: pbench <= 0.34
Conflicts: pbench <= 0.34
Expand Down
4 changes: 0 additions & 4 deletions jenkins/ci.fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ RUN \
`# Base command used by CI unit test jobs` \
`#` \
tox \
`#` \
`# Required for pbench-fio and pbench-uperf` \
`#` \
which \
&& \
`#` \
`# Save space in the container image.` \
Expand Down
1 change: 0 additions & 1 deletion jenkins/development.Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ RUN \
screen \
sos \
tar \
which \
xz \
\
`#` \
Expand Down

0 comments on commit 42a8d12

Please sign in to comment.