summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2019-03-04 17:10:04 +0100
committerKarel Zak2019-03-04 17:14:12 +0100
commit43b4a4d3c720a4e65fe9de884cd73e0b1b94fbef (patch)
tree58a092b0f94bbdad6fcb363e1b55e6241bf81e4a /tests/functions.sh
parenttests: add missing ts_check_test_command calls (diff)
downloadkernel-qcow2-util-linux-43b4a4d3c720a4e65fe9de884cd73e0b1b94fbef.tar.gz
kernel-qcow2-util-linux-43b4a4d3c720a4e65fe9de884cd73e0b1b94fbef.tar.xz
kernel-qcow2-util-linux-43b4a4d3c720a4e65fe9de884cd73e0b1b94fbef.zip
tests: add --use-system-commands
This change allows to use commands from $PATH rather than from $top_builddir. There two basic use cases: * check differences between installed and git version run.sh --use-system-command --show-diff * check system binaries by upstream tests (for example tests from src.rpm package) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh34
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 2fb0ddb5f..ab607c4ce 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -75,9 +75,19 @@ function ts_report {
}
function ts_check_test_command {
- if [ ! -x "$1" ]; then
- ts_skip "${1##*/} not found"
- fi
+ case "$1" in
+ */*)
+ # paths
+ if [ ! -x "$1" ]; then
+ ts_skip "${1##*/} not found"
+ fi
+ ;;
+ *)
+ # just command names (e.g. --use-system-commands)
+ local cmd=$1
+ type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
+ ;;
+ esac
}
function ts_check_prog {
@@ -254,8 +264,20 @@ function ts_init_env {
top_srcdir=$(ts_abspath $top_srcdir)
top_builddir=$(ts_abspath $top_builddir)
- # some ul commands search other ul commands in $PATH
- export PATH="$top_builddir:$PATH"
+ # We use helpser always from build tree
+ ts_helpersdir="${top_builddir}/"
+
+ TS_USE_SYSTEM_COMMANDS=$(ts_has_option "use-system-commands" "$*")
+ if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ # Don't define anything, just follow current PATH
+ ts_commandsdir=""
+ else
+ # The default is to use commands from build tree
+ ts_commandsdir="${top_builddir}/"
+
+ # some ul commands search other ul commands in $PATH
+ export PATH="$ts_commandsdir:$PATH"
+ fi
TS_SCRIPT="$mydir/$(basename $0)"
TS_SUBDIR=$(dirname $TS_SCRIPT)
@@ -319,6 +341,8 @@ function ts_init_env {
if [ "$TS_VERBOSE" == "yes" ]; then
echo
echo " script: $TS_SCRIPT"
+ echo " commands: $ts_commandsdir"
+ echo " helpers: $ts_helpersdir"
echo " sub dir: $TS_SUBDIR"
echo " top dir: $TS_TOPDIR"
echo " self: $TS_SELF"