-# Allow overriding the source and build directories
-if [ -z "${BT_TESTS_SRCDIR:-}" ]; then
- BT_TESTS_SRCDIR="$testsdir"
-fi
-export BT_TESTS_SRCDIR
+# Sets and exports, if not set:
+#
+# • `BT_TESTS_SRCDIR` to the base source directory of tests.
+# • `BT_TESTS_BUILDDIR` to the base build directory of tests.
+_set_vars_srcdir_builddir() {
+ # If `readlink -f` is available, then get a resolved absolute path
+ # to the tests source directory. Otherwise, make do with a relative
+ # path.
+ local -r scriptdir="$(dirname "${BASH_SOURCE[0]}")"
+ local testsdir
+
+ if readlink -f "." >/dev/null 2>&1; then
+ testsdir=$(readlink -f "$scriptdir/..")
+ else
+ testsdir="$scriptdir/.."
+ fi