From 14e57111df6f8894ed47841b7471837c9d87c264 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 23 Aug 2016 21:47:54 +0200 Subject: test: Substitute GNU commands for other commands where available We are simply checking for gnuCMD and gCMD for each command we are interested in. Gbp-Dch: ignore --- test/integration/framework | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test/integration/framework') diff --git a/test/integration/framework b/test/integration/framework index ff0df3226..25cabc9f8 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -31,7 +31,6 @@ if [ "${MSGCOLOR:-YES}" = 'YES' ]; then fi fi - if [ "$MSGCOLOR" != 'NO' ]; then CERROR="\033[1;31m" # red CWARNING="\033[1;33m" # yellow @@ -276,8 +275,13 @@ find_project_binary_dir() { fi } setupenvironment() { + # Next check needs a gnu stat, let's figure that out early. + stat=stat + if command -v gnustat >/dev/null 2>&1; then + stat=gnustat + fi # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir) - if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then + if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$($stat --format '%a' "$TMPDIR")" != '1777' ]; then unset TMPDIR fi TMPWORKINGDIRECTORY="$(mktemp -d)" @@ -290,6 +294,18 @@ setupenvironment() { fi msgninfo "Preparing environment for ${0##*/} in ${TMPWORKINGDIRECTORY}…" + # Setup coreutils on BSD systems + mkdir "${TMPWORKINGDIRECTORY}/bin" + for prefix in gnu g; do + for command in stat touch sed cp tr sha1sum sha256sum md5sum sha512sum grep date wc chmod head readlink tar expr base64; do + if command -v $prefix$command 2>/dev/null >/dev/null; then + [ -e "${TMPWORKINGDIRECTORY}/bin/$command" ] || ln -sf $(command -v $prefix$command) "${TMPWORKINGDIRECTORY}/bin/$command" + fi + done + done + export PATH="${TMPWORKINGDIRECTORY}/bin/:$PATH" + + mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded" if [ "$(id -u)" = '0' ]; then # relax permissions so that running as root with user switching works -- cgit v1.2.3