On platforms not using the GNU coreutils, namely MacOs, readlink doesn't
have a canonicalize option.
Use it only when availabe, otherwise use the relative paths.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I798e6320dda78c5d9b33a2568b663c57d35d42b3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1749
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
-data_dir=$(readlink -f "${BT_TESTS_DATADIR}/cli/auto-source-discovery")
+data_dir="${BT_TESTS_DATADIR}/cli/auto-source-discovery"
plugin_dir="${data_dir}"
trace_dir="${data_dir}/traces"
plugin_dir="${data_dir}"
trace_dir="${data_dir}/traces"
path_to_trace="C://path/to/trace"
output_path="C://output/path"
else
path_to_trace="C://path/to/trace"
output_path="C://output/path"
else
- path_to_trace=$(readlink -f "${BT_CTF_TRACES_PATH}/succeed/succeed1")
- path_to_trace2=$(readlink -f "${BT_CTF_TRACES_PATH}/succeed/succeed2")
+ path_to_trace="${BT_CTF_TRACES_PATH}/succeed/succeed1"
+ path_to_trace2="${BT_CTF_TRACES_PATH}/succeed/succeed2"
output_path="/output/path"
fi
output_path="/output/path"
fi
# Error out when encountering an undefined variable
set -u
# Error out when encountering an undefined variable
set -u
+# If "readlink -f" is available, get a resolved absolute path to the
+# tests source dir, otherwise make do with a relative path.
scriptdir="$(dirname "${BASH_SOURCE[0]}")"
scriptdir="$(dirname "${BASH_SOURCE[0]}")"
+if readlink -f "." >/dev/null 2>&1; then
+ testsdir=$(readlink -f "$scriptdir/..")
+else
+ testsdir="$scriptdir/.."
+fi
# The OS on which we are running. See [1] for possible values of 'uname -s'.
# We do a bit of translation to ease our life down the road for comparison.
# The OS on which we are running. See [1] for possible values of 'uname -s'.
# We do a bit of translation to ease our life down the road for comparison.
# Allow overriding the source and build directories
if [ "x${BT_TESTS_SRCDIR:-}" = "x" ]; then
# Allow overriding the source and build directories
if [ "x${BT_TESTS_SRCDIR:-}" = "x" ]; then
- BT_TESTS_SRCDIR="$scriptdir/.."
+ BT_TESTS_SRCDIR="$testsdir"
fi
export BT_TESTS_SRCDIR
if [ "x${BT_TESTS_BUILDDIR:-}" = "x" ]; then
fi
export BT_TESTS_SRCDIR
if [ "x${BT_TESTS_BUILDDIR:-}" = "x" ]; then
- BT_TESTS_BUILDDIR="$scriptdir/.."
+ BT_TESTS_BUILDDIR="$testsdir"
fi
export BT_TESTS_BUILDDIR
fi
export BT_TESTS_BUILDDIR