summaryrefslogtreecommitdiffstats
path: root/tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests.sh')
-rwxr-xr-xtests.sh34
1 files changed, 21 insertions, 13 deletions
diff --git a/tests.sh b/tests.sh
index b9e21a9..4ac9763 100755
--- a/tests.sh
+++ b/tests.sh
@@ -17,7 +17,6 @@
############################################################################
set -e
-set -o physical
umask 022
export LC_ALL=C
@@ -40,6 +39,8 @@ if [ -t 1 ]; then
RST="$(printf '\033[0m')"
fi
+UNAME="$(uname)"
+
if command -v capsh &>/dev/null; then
if capsh --has-p=cap_dac_override &>/dev/null || capsh --has-p=cap_dac_read_search &>/dev/null; then
if [ -n "$BFS_TRIED_DROP" ]; then
@@ -63,7 +64,7 @@ EOF
fi
elif [ "$EUID" -eq 0 ]; then
UNLESS=
- if [ "$(uname)" = "Linux" ]; then
+ if [ "$UNAME" = "Linux" ]; then
UNLESS=" unless ${GRN}capsh${RST} is installed"
fi
@@ -107,17 +108,6 @@ Usage: ${GRN}$0${RST} [${BLU}--bfs${RST}=${MAG}path/to/bfs${RST}] [${BLU}--posix
EOF
}
-function _realpath() {
- (
- cd "${1%/*}"
- echo "$PWD/${1##*/}"
- )
-}
-
-BFS="$(_realpath ./bfs)"
-TESTS="$(_realpath ./tests)"
-UNAME="$(uname)"
-
DEFAULT=yes
POSIX=
BSD=
@@ -853,6 +843,24 @@ fi
eval enabled_tests=($(printf '%q\n' "${enabled_tests[@]}" | sort -u))
+function _realpath() {
+ (
+ set -P
+ cd "$(dirname -- "$1")"
+ echo "$PWD/$(basename -- "$1")"
+ )
+}
+
+ROOT="$(dirname -- "${BASH_SOURCE[0]}")"
+
+# Try to resolve the path to $BFS before we cd, while also supporting
+# --bfs="./bfs -S ids"
+BFS=(${BFS:-$ROOT/bfs})
+BFS[0]="$(_realpath "$(command -v "${BFS[0]}")")"
+BFS="${BFS[*]}"
+
+TESTS="$(_realpath "$ROOT/tests")"
+
# The temporary directory that will hold our test data
TMP="$(mktemp -d "${TMPDIR:-/tmp}"/bfs.XXXXXXXXXX)"
chown "$(id -u):$(id -g)" "$TMP"