dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
22a545
From 748fbfa9b1bb3b64b3fbc6b1e51d260d8376c791 Mon Sep 17 00:00:00 2001
22a545
From: Karel Zak <kzak@redhat.com>
22a545
Date: Mon, 4 Mar 2019 17:10:04 +0100
22a545
Subject: [PATCH 16/19] tests: add --use-system-commands
22a545
22a545
This change allows to use commands from $PATH rather than from
22a545
$top_builddir. There two basic use cases:
22a545
22a545
* check differences between installed and git version
22a545
  run.sh --use-system-command --show-diff
22a545
22a545
* check system binaries by upstream tests (for example tests from
22a545
  src.rpm package)
22a545
22a545
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
22a545
Upstream: http://github.com/karelzak/util-linux/commit/43b4a4d3c720a4e65fe9de884cd73e0b1b94fbe
22a545
Signed-off-by: Karel Zak <kzak@redhat.com>
22a545
---
22a545
 tests/commands.sh  | 194 ++++++++++++++++++++++-----------------------
22a545
 tests/functions.sh |  34 ++++++--
22a545
 tests/run.sh       |  33 +++++---
22a545
 3 files changed, 146 insertions(+), 115 deletions(-)
22a545
22a545
diff --git a/tests/commands.sh b/tests/commands.sh
22a545
index 1be2d25b4..93100caf6 100644
22a545
--- a/tests/commands.sh
22a545
+++ b/tests/commands.sh
22a545
@@ -2,105 +2,105 @@
22a545
 TS_TESTUSER=${TS_TESTUSER:-"nobody"}
22a545
 
22a545
 # helpers
22a545
-TS_HELPER_BYTESWAP="$top_builddir/test_byteswap"
22a545
-TS_HELPER_CPUSET="$top_builddir/test_cpuset"
22a545
-TS_HELPER_DMESG="$top_builddir/test_dmesg"
22a545
-TS_HELPER_ISLOCAL="$top_builddir/test_islocal"
22a545
-TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted"
22a545
-TS_HELPER_LIBFDISK_GPT="$top_builddir/test_fdisk_gpt"
22a545
-TS_HELPER_LIBFDISK_MKPART="$top_builddir/sample-fdisk-mkpart"
22a545
-TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context"
22a545
-TS_HELPER_LIBFDISK_MKPART_FULLSPEC="$top_builddir/sample-fdisk-mkpart-fullspec"
22a545
-TS_HELPER_LIBMOUNT_LOCK="$top_builddir/test_mount_lock"
22a545
-TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr"
22a545
-TS_HELPER_LIBMOUNT_TABDIFF="$top_builddir/test_mount_tab_diff"
22a545
-TS_HELPER_LIBMOUNT_TAB="$top_builddir/test_mount_tab"
22a545
-TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/test_mount_tab_update"
22a545
-TS_HELPER_LIBMOUNT_UTILS="$top_builddir/test_mount_utils"
22a545
-TS_HELPER_LIBMOUNT_DEBUG="$top_builddir/test_mount_debug"
22a545
-TS_HELPER_LIBSMARTCOLS_FROMFILE="$top_builddir/sample-scols-fromfile"
22a545
-TS_HELPER_LIBSMARTCOLS_TITLE="$top_builddir/sample-scols-title"
22a545
+TS_HELPER_BYTESWAP="${ts_helpersdir}test_byteswap"
22a545
+TS_HELPER_CPUSET="${ts_helpersdir}test_cpuset"
22a545
+TS_HELPER_DMESG="${ts_helpersdir}test_dmesg"
22a545
+TS_HELPER_ISLOCAL="${ts_helpersdir}test_islocal"
22a545
+TS_HELPER_ISMOUNTED="${ts_helpersdir}test_ismounted"
22a545
+TS_HELPER_LIBFDISK_GPT="${ts_helpersdir}test_fdisk_gpt"
22a545
+TS_HELPER_LIBFDISK_MKPART="${ts_helpersdir}sample-fdisk-mkpart"
22a545
+TS_HELPER_LIBMOUNT_CONTEXT="${ts_helpersdir}test_mount_context"
22a545
+TS_HELPER_LIBFDISK_MKPART_FULLSPEC="${ts_helpersdir}sample-fdisk-mkpart-fullspec"
22a545
+TS_HELPER_LIBMOUNT_LOCK="${ts_helpersdir}test_mount_lock"
22a545
+TS_HELPER_LIBMOUNT_OPTSTR="${ts_helpersdir}test_mount_optstr"
22a545
+TS_HELPER_LIBMOUNT_TABDIFF="${ts_helpersdir}test_mount_tab_diff"
22a545
+TS_HELPER_LIBMOUNT_TAB="${ts_helpersdir}test_mount_tab"
22a545
+TS_HELPER_LIBMOUNT_UPDATE="${ts_helpersdir}test_mount_tab_update"
22a545
+TS_HELPER_LIBMOUNT_UTILS="${ts_helpersdir}test_mount_utils"
22a545
+TS_HELPER_LIBMOUNT_DEBUG="${ts_helpersdir}test_mount_debug"
22a545
+TS_HELPER_LIBSMARTCOLS_FROMFILE="${ts_helpersdir}sample-scols-fromfile"
22a545
+TS_HELPER_LIBSMARTCOLS_TITLE="${ts_helpersdir}sample-scols-title"
22a545
 TS_HELPER_PYLIBMOUNT_CONTEXT="$top_srcdir/libmount/python/test_mount_context.py"
22a545
 TS_HELPER_PYLIBMOUNT_TAB="$top_srcdir/libmount/python/test_mount_tab.py"
22a545
 TS_HELPER_PYLIBMOUNT_UPDATE="$top_srcdir/libmount/python/test_mount_tab_update.py"
22a545
-TS_HELPER_LOGGER="$top_builddir/test_logger"
22a545
-TS_HELPER_LOGINDEFS="$top_builddir/test_logindefs"
22a545
-TS_HELPER_MD5="$top_builddir/test_md5"
22a545
-TS_HELPER_SHA1="$top_builddir/test_sha1"
22a545
-TS_HELPER_MKFS_MINIX="$top_builddir/test_mkfs_minix"
22a545
-TS_HELPER_MORE=${TS_HELPER_MORE-"$top_builddir/test_more"}
22a545
-TS_HELPER_PARTITIONS="$top_builddir/sample-partitions"
22a545
-TS_HELPER_PATHS="$top_builddir/test_pathnames"
22a545
-TS_HELPER_SCRIPT="$top_builddir/test_script"
22a545
-TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive"
22a545
-TS_HELPER_STRUTILS="$top_builddir/test_strutils"
22a545
-TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
22a545
-TS_HELPER_TIOCSTI="$top_builddir/test_tiocsti"
22a545
-TS_HELPER_UUID_PARSER="$top_builddir/test_uuid_parser"
22a545
-TS_HELPER_UUID_NAMESPACE="$top_builddir/test_uuid_namespace"
22a545
-TS_HELPER_MBSENCODE="$top_builddir/test_mbsencode"
22a545
-TS_HELPER_CAL="$top_builddir/test_cal"
22a545
+TS_HELPER_LOGGER="${ts_helpersdir}test_logger"
22a545
+TS_HELPER_LOGINDEFS="${ts_helpersdir}test_logindefs"
22a545
+TS_HELPER_MD5="${ts_helpersdir}test_md5"
22a545
+TS_HELPER_SHA1="${ts_helpersdir}test_sha1"
22a545
+TS_HELPER_MKFS_MINIX="${ts_helpersdir}test_mkfs_minix"
22a545
+TS_HELPER_MORE=${TS_HELPER_MORE-"${ts_helpersdir}test_more"}
22a545
+TS_HELPER_PARTITIONS="${ts_helpersdir}sample-partitions"
22a545
+TS_HELPER_PATHS="${ts_helpersdir}test_pathnames"
22a545
+TS_HELPER_SCRIPT="${ts_helpersdir}test_script"
22a545
+TS_HELPER_SIGRECEIVE="${ts_helpersdir}test_sigreceive"
22a545
+TS_HELPER_STRUTILS="${ts_helpersdir}test_strutils"
22a545
+TS_HELPER_SYSINFO="${ts_helpersdir}test_sysinfo"
22a545
+TS_HELPER_TIOCSTI="${ts_helpersdir}test_tiocsti"
22a545
+TS_HELPER_UUID_PARSER="${ts_helpersdir}test_uuid_parser"
22a545
+TS_HELPER_UUID_NAMESPACE="${ts_helpersdir}test_uuid_namespace"
22a545
+TS_HELPER_MBSENCODE="${ts_helpersdir}test_mbsencode"
22a545
+TS_HELPER_CAL="${ts_helpersdir}test_cal"
22a545
 
22a545
 # paths to commands
22a545
-TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
22a545
-TS_CMD_DELPART=${TS_CMD_DELPART:-"$top_builddir/delpart"}
22a545
-TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"$top_builddir/blkdiscard"}
22a545
-TS_CMD_BLKID=${TS_CMD_BLKID-"$top_builddir/blkid"}
22a545
-TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"}
22a545
-TS_CMD_COLCRT=${TS_CMD_COLCRT:-"$top_builddir/colcrt"}
22a545
-TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"}
22a545
-TS_CMD_COL=${TS_CMD_COL:-"$top_builddir/col"}
22a545
-TS_CMD_COLUMN=${TS_CMD_COLUMN:-"$top_builddir/column"}
22a545
-TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/eject"}
22a545
-TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"$top_builddir/fallocate"}
22a545
-TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"}
22a545
-TS_CMD_FLOCK=${TS_CMD_FLOCK-"$top_builddir/flock"}
22a545
-TS_CMD_SFDISK=${TS_CMD_SFDISK-"$top_builddir/sfdisk"}
22a545
-TS_CMD_FINCORE=${TS_CMD_FINCORE-"$top_builddir/fincore"}
22a545
-TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"$top_builddir/findmnt"}
22a545
-TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"$top_builddir/fsck.cramfs"}
22a545
-TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"$top_builddir/fsck.minix"}
22a545
-TS_CMD_GETOPT=${TS_CMD_GETOPT-"$top_builddir/getopt"}
22a545
-TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"$top_builddir/hexdump"}
22a545
-TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$top_builddir/hwclock"}
22a545
-TS_CMD_IONICE=${TS_CMD_IONICE-"$top_builddir/ionice"}
22a545
-TS_CMD_IPCMK=${TS_CMD_IPCMK-"$top_builddir/ipcmk"}
22a545
-TS_CMD_IPCRM=${TS_CMD_IPCRM-"$top_builddir/ipcrm"}
22a545
-TS_CMD_IPCS=${TS_CMD_IPCS:-"$top_builddir/ipcs"}
22a545
-TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"$top_builddir/isosize"}
22a545
-TS_CMD_KILL=${TS_CMD_KILL-"$top_builddir/kill"}
22a545
-TS_CMD_LAST=${TS_CMD_LAST-"$top_builddir/last"}
22a545
-TS_CMD_LINE=${TS_CMD_LINE-"$top_builddir/line"}
22a545
-TS_CMD_LOOK=${TS_CMD_LOOK-"$top_builddir/look"}
22a545
-TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"$top_builddir/losetup"}
22a545
-TS_CMD_LSBLK=${TS_CMD_LSBLK-"$top_builddir/lsblk"}
22a545
-TS_CMD_LSCPU=${TS_CMD_LSCPU-"$top_builddir/lscpu"}
22a545
-TS_CMD_LSMEM=${TS_CMD_LSMEM-"$top_builddir/lsmem"}
22a545
-TS_CMD_LSNS=${TS_CMD_LSNS-"$top_builddir/lsns"}
22a545
-TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"$top_builddir/mcookie"}
22a545
-TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"$top_builddir/mkfs.cramfs"}
22a545
-TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"$top_builddir/mkfs.minix"}
22a545
-TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"$top_builddir/mkswap"}
22a545
-TS_CMD_MOUNT=${TS_CMD_MOUNT:-"$top_builddir/mount"}
22a545
-TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"$top_builddir/mountpoint"}
22a545
-TS_CMD_NAMEI=${TS_CMD_NAMEI-"$top_builddir/namei"}
22a545
-TS_CMD_PARTX=${TS_CMD_PARTX-"$top_builddir/partx"}
22a545
-TS_CMD_RENAME=${TS_CMD_RENAME-"$top_builddir/rename"}
22a545
-TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"$top_builddir/runuser"}
22a545
-TS_CMD_REV=${TS_CMD_REV:-"$top_builddir/rev"}
22a545
-TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"$top_builddir/script"}
22a545
-TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"$top_builddir/scriptreplay"}
22a545
-TS_CMD_SETARCH=${TS_CMD_SETARCH-"$top_builddir/setarch"}
22a545
-TS_CMD_SETSID=${TS_CMD_SETSID-"$top_builddir/setsid"}
22a545
-TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"$top_builddir/swaplabel"}
22a545
-TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"$top_builddir/swapoff"}
22a545
-TS_CMD_SWAPON=${TS_CMD_SWAPON:-"$top_builddir/swapon"}
22a545
-TS_CMD_UL=${TS_CMD_UL-"$top_builddir/ul"}
22a545
-TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"$top_builddir/umount"}
22a545
-TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"$top_builddir/utmpdump"}
22a545
-TS_CMD_UUIDD=${TS_CMD_UUIDD-"$top_builddir/uuidd"}
22a545
-TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"$top_builddir/uuidgen"}
22a545
-TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"$top_builddir/uuidparse"}
22a545
-TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"$top_builddir/whereis"}
22a545
-TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"$top_builddir/wipefs"}
22a545
-TS_CMD_CHRT=${TS_CMD_CHRT-"$top_builddir/chrt"}
22a545
+TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"}
22a545
+TS_CMD_DELPART=${TS_CMD_DELPART:-"${ts_commandsdir}delpart"}
22a545
+TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"${ts_commandsdir}blkdiscard"}
22a545
+TS_CMD_BLKID=${TS_CMD_BLKID-"${ts_commandsdir}blkid"}
22a545
+TS_CMD_CAL=${TS_CMD_CAL-"${ts_commandsdir}cal"}
22a545
+TS_CMD_COLCRT=${TS_CMD_COLCRT:-"${ts_commandsdir}colcrt"}
22a545
+TS_CMD_COLRM=${TS_CMD_COLRM:-"${ts_commandsdir}colrm"}
22a545
+TS_CMD_COL=${TS_CMD_COL:-"${ts_commandsdir}col"}
22a545
+TS_CMD_COLUMN=${TS_CMD_COLUMN:-"${ts_commandsdir}column"}
22a545
+TS_CMD_EJECT=${TS_CMD_EJECT-"${ts_commandsdir}eject"}
22a545
+TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"${ts_commandsdir}fallocate"}
22a545
+TS_CMD_FDISK=${TS_CMD_FDISK-"${ts_commandsdir}fdisk"}
22a545
+TS_CMD_FLOCK=${TS_CMD_FLOCK-"${ts_commandsdir}flock"}
22a545
+TS_CMD_SFDISK=${TS_CMD_SFDISK-"${ts_commandsdir}sfdisk"}
22a545
+TS_CMD_FINCORE=${TS_CMD_FINCORE-"${ts_commandsdir}fincore"}
22a545
+TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"${ts_commandsdir}findmnt"}
22a545
+TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"${ts_commandsdir}fsck.cramfs"}
22a545
+TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"${ts_commandsdir}fsck.minix"}
22a545
+TS_CMD_GETOPT=${TS_CMD_GETOPT-"${ts_commandsdir}getopt"}
22a545
+TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"${ts_commandsdir}hexdump"}
22a545
+TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"${ts_commandsdir}hwclock"}
22a545
+TS_CMD_IONICE=${TS_CMD_IONICE-"${ts_commandsdir}ionice"}
22a545
+TS_CMD_IPCMK=${TS_CMD_IPCMK-"${ts_commandsdir}ipcmk"}
22a545
+TS_CMD_IPCRM=${TS_CMD_IPCRM-"${ts_commandsdir}ipcrm"}
22a545
+TS_CMD_IPCS=${TS_CMD_IPCS:-"${ts_commandsdir}ipcs"}
22a545
+TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"${ts_commandsdir}isosize"}
22a545
+TS_CMD_KILL=${TS_CMD_KILL-"${ts_commandsdir}kill"}
22a545
+TS_CMD_LAST=${TS_CMD_LAST-"${ts_commandsdir}last"}
22a545
+TS_CMD_LINE=${TS_CMD_LINE-"${ts_commandsdir}line"}
22a545
+TS_CMD_LOOK=${TS_CMD_LOOK-"${ts_commandsdir}look"}
22a545
+TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"${ts_commandsdir}losetup"}
22a545
+TS_CMD_LSBLK=${TS_CMD_LSBLK-"${ts_commandsdir}lsblk"}
22a545
+TS_CMD_LSCPU=${TS_CMD_LSCPU-"${ts_commandsdir}lscpu"}
22a545
+TS_CMD_LSMEM=${TS_CMD_LSMEM-"${ts_commandsdir}lsmem"}
22a545
+TS_CMD_LSNS=${TS_CMD_LSNS-"${ts_commandsdir}lsns"}
22a545
+TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"${ts_commandsdir}mcookie"}
22a545
+TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"${ts_commandsdir}mkfs.cramfs"}
22a545
+TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"${ts_commandsdir}mkfs.minix"}
22a545
+TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"${ts_commandsdir}mkswap"}
22a545
+TS_CMD_MOUNT=${TS_CMD_MOUNT:-"${ts_commandsdir}mount"}
22a545
+TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"${ts_commandsdir}mountpoint"}
22a545
+TS_CMD_NAMEI=${TS_CMD_NAMEI-"${ts_commandsdir}namei"}
22a545
+TS_CMD_PARTX=${TS_CMD_PARTX-"${ts_commandsdir}partx"}
22a545
+TS_CMD_RENAME=${TS_CMD_RENAME-"${ts_commandsdir}rename"}
22a545
+TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"${ts_commandsdir}runuser"}
22a545
+TS_CMD_REV=${TS_CMD_REV:-"${ts_commandsdir}rev"}
22a545
+TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"${ts_commandsdir}script"}
22a545
+TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"${ts_commandsdir}scriptreplay"}
22a545
+TS_CMD_SETARCH=${TS_CMD_SETARCH-"${ts_commandsdir}setarch"}
22a545
+TS_CMD_SETSID=${TS_CMD_SETSID-"${ts_commandsdir}setsid"}
22a545
+TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"${ts_commandsdir}swaplabel"}
22a545
+TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"${ts_commandsdir}swapoff"}
22a545
+TS_CMD_SWAPON=${TS_CMD_SWAPON:-"${ts_commandsdir}swapon"}
22a545
+TS_CMD_UL=${TS_CMD_UL-"${ts_commandsdir}ul"}
22a545
+TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"${ts_commandsdir}umount"}
22a545
+TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"${ts_commandsdir}utmpdump"}
22a545
+TS_CMD_UUIDD=${TS_CMD_UUIDD-"${ts_commandsdir}uuidd"}
22a545
+TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"${ts_commandsdir}uuidgen"}
22a545
+TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"${ts_commandsdir}uuidparse"}
22a545
+TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"${ts_commandsdir}whereis"}
22a545
+TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"${ts_commandsdir}wipefs"}
22a545
+TS_CMD_CHRT=${TS_CMD_CHRT-"${ts_commandsdir}chrt"}
22a545
diff --git a/tests/functions.sh b/tests/functions.sh
22a545
index 2fb0ddb5f..ab607c4ce 100644
22a545
--- a/tests/functions.sh
22a545
+++ b/tests/functions.sh
22a545
@@ -75,9 +75,19 @@ function ts_report {
22a545
 }
22a545
 
22a545
 function ts_check_test_command {
22a545
-	if [ ! -x "$1" ]; then
22a545
-		ts_skip "${1##*/} not found"
22a545
-	fi
22a545
+	case "$1" in
22a545
+	*/*)
22a545
+		# paths
22a545
+		if [ ! -x "$1" ]; then
22a545
+			ts_skip "${1##*/} not found"
22a545
+		fi
22a545
+		;;
22a545
+	*)
22a545
+		# just command names (e.g. --use-system-commands)
22a545
+		local cmd=$1
22a545
+		type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
22a545
+		;;
22a545
+	esac
22a545
 }
22a545
 
22a545
 function ts_check_prog {
22a545
@@ -254,8 +264,20 @@ function ts_init_env {
22a545
 	top_srcdir=$(ts_abspath $top_srcdir)
22a545
 	top_builddir=$(ts_abspath $top_builddir)
22a545
 
22a545
-	# some ul commands search other ul commands in $PATH
22a545
-	export PATH="$top_builddir:$PATH"
22a545
+	# We use helpser always from build tree
22a545
+	ts_helpersdir="${top_builddir}/"
22a545
+
22a545
+	TS_USE_SYSTEM_COMMANDS=$(ts_has_option "use-system-commands" "$*")
22a545
+	if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
22a545
+		# Don't define anything, just follow current PATH
22a545
+		ts_commandsdir=""
22a545
+	else
22a545
+		# The default is to use commands from build tree
22a545
+		ts_commandsdir="${top_builddir}/"
22a545
+
22a545
+		# some ul commands search other ul commands in $PATH
22a545
+		export PATH="$ts_commandsdir:$PATH"
22a545
+	fi
22a545
 
22a545
 	TS_SCRIPT="$mydir/$(basename $0)"
22a545
 	TS_SUBDIR=$(dirname $TS_SCRIPT)
22a545
@@ -319,6 +341,8 @@ function ts_init_env {
22a545
 	if [ "$TS_VERBOSE" == "yes" ]; then
22a545
 		echo
22a545
 		echo "     script: $TS_SCRIPT"
22a545
+		echo "   commands: $ts_commandsdir"
22a545
+		echo "    helpers: $ts_helpersdir"
22a545
 		echo "    sub dir: $TS_SUBDIR"
22a545
 		echo "    top dir: $TS_TOPDIR"
22a545
 		echo "       self: $TS_SELF"
22a545
diff --git a/tests/run.sh b/tests/run.sh
22a545
index f40c9f801..28f8ee25a 100755
22a545
--- a/tests/run.sh
22a545
+++ b/tests/run.sh
22a545
@@ -20,6 +20,7 @@ TS_TOPDIR=$(cd ${0%/*} && pwd)
22a545
 SUBTESTS=
22a545
 EXCLUDETESTS=
22a545
 OPTS=
22a545
+SYSCOMMANDS=
22a545
 
22a545
 top_srcdir=
22a545
 top_builddir=
22a545
@@ -68,6 +69,11 @@ while [ -n "$1" ]; do
22a545
 		# these options are simply forwarded to the test scripts
22a545
 		OPTS="$OPTS $1"
22a545
 		;;
22a545
+	--use-system-commands)
22a545
+		OPTS="$OPTS $1"
22a545
+		SYSCOMMANDS="yes"
22a545
+		;;
22a545
+
22a545
 	--nonroot)
22a545
 		if [ $(id -ru) -eq 0 ]; then
22a545
 			echo "Ignore util-linux test suite [non-root UID expected]."
22a545
@@ -98,18 +104,19 @@ while [ -n "$1" ]; do
22a545
 		echo "Usage: "
22a545
 		echo "  $(basename $0) [options] [<component> ...]"
22a545
 		echo "Options:"
22a545
-		echo "  --force              execute demanding tests"
22a545
-		echo "  --fake               do not run, setup tests only"
22a545
-		echo "  --memcheck-valgrind  run with valgrind"
22a545
-		echo "  --memcheck-asan      enable ASAN (requires ./configure --enable-asan)"
22a545
-		echo "  --nolocks            don't use flock to lock resources"
22a545
-		echo "  --verbose            verbose mode"
22a545
-		echo "  --show-diff          show diff from failed tests"
22a545
-		echo "  --nonroot            ignore test suite if user is root"
22a545
-		echo "  --srcdir=<path>      autotools top source directory"
22a545
-		echo "  --builddir=<path>    autotools top build directory"
22a545
-		echo "  --parallel=<num>     number of parallel test jobs, default: num cpus"
22a545
-		echo "  --exclude=<list>     exclude tests by list '<utilname>/<testname> ..'"
22a545
+		echo "  --force               execute demanding tests"
22a545
+		echo "  --fake                do not run, setup tests only"
22a545
+		echo "  --memcheck-valgrind   run with valgrind"
22a545
+		echo "  --memcheck-asan       enable ASAN (requires ./configure --enable-asan)"
22a545
+		echo "  --nolocks             don't use flock to lock resources"
22a545
+		echo "  --verbose             verbose mode"
22a545
+		echo "  --show-diff           show diff from failed tests"
22a545
+		echo "  --nonroot             ignore test suite if user is root"
22a545
+		echo "  --use-system-commands use PATH rather than builddir"
22a545
+		echo "  --srcdir=<path>       autotools top source directory"
22a545
+		echo "  --builddir=<path>     autotools top build directory"
22a545
+		echo "  --parallel=<num>      number of parallel test jobs, default: num cpus"
22a545
+		echo "  --exclude=<list>      exclude tests by list '<utilname>/<testname> ..'"
22a545
 		echo
22a545
 		exit 1
22a545
 		;;
22a545
@@ -148,7 +155,7 @@ if [ -n "$SUBTESTS" ]; then
22a545
 		fi
22a545
 	done
22a545
 else
22a545
-	if [ ! -f "$top_builddir/test_ttyutils" ]; then
22a545
+	if [ -z "$SYSCOMMANDS" -a ! -f "$top_builddir/test_ttyutils" ]; then
22a545
 		echo "Tests not compiled! Run 'make check' to fix the problem."
22a545
 		exit 1
22a545
 	fi
22a545
-- 
22a545
2.20.1
22a545