From: Andreas Schneider Date: Thu, 22 Dec 2022 07:36:26 +0000 (+0100) Subject: testprogs: Add system_or_builddir_binary() X-Git-Tag: talloc-2.4.0~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5910d2895ed6f7665f79876de433b861bfdb237;p=thirdparty%2Fsamba.git testprogs: Add system_or_builddir_binary() This should be used if we use a system or builddir binary. Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- diff --git a/testprogs/blackbox/common_test_fns.inc b/testprogs/blackbox/common_test_fns.inc index a9e94b82e99..4b9a6a481aa 100755 --- a/testprogs/blackbox/common_test_fns.inc +++ b/testprogs/blackbox/common_test_fns.inc @@ -124,3 +124,31 @@ remove_directory() rm -rf "$xdir" } + +# This function should be used to either use a system tool or one of our +# build dir if available. +# +# Examples: +# +# system_or_builddir_binary ldbsearch ${BUILDDIR} +# system_or_builddir_binary kinit ${BUILDDIR} samba4kinit +# +system_or_builddir_binary() +{ + _bin_name="${1}" + _build_dir="${2}" + _alt_bin_name="${3}" + + _bin="$(command -v ${_bin_name})" + _bin_build_path="${_build_dir}/${_bin_name}" + + if [ -n "${_alt_bin_name}" ]; then + _bin_build_path="${_build_dir}/${_alt_bin_name}" + fi + + if [ -x "${_bin_build_path}" ]; then + _bin="${_bin_build_path}" + fi + + echo "${_bin}" +} diff --git a/testprogs/blackbox/test_password_settings.sh b/testprogs/blackbox/test_password_settings.sh index a757f80700c..609e26dee74 100755 --- a/testprogs/blackbox/test_password_settings.sh +++ b/testprogs/blackbox/test_password_settings.sh @@ -23,11 +23,6 @@ failed=0 samba_bindir="$BINDIR" -samba_kinit=kinit -if test -x $samba_bindir/samba4kinit; then - samba_kinit=$samba_bindir/samba4kinit -fi - smbclient="$samba_bindir/smbclient" samba_tool="$samba_bindir/samba-tool" smbpasswd="$samba_bindir/smbpasswd" @@ -39,6 +34,8 @@ SMB_UNC="//$SERVER/tmp" . $(dirname $0)/subunit.sh . $(dirname $0)/common_test_fns.inc +samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit) + do_kinit() { principal="$1"