From: Michael Jeanson Date: Tue, 23 Jul 2019 15:43:13 +0000 (-0400) Subject: tests: readlink 'canonicalize' is GNU specific X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=9c5dd55ab776adbdfe69dcad62765c937e0a52e7 tests: readlink 'canonicalize' is GNU specific 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 Change-Id: I798e6320dda78c5d9b33a2568b663c57d35d42b3 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1749 Reviewed-by: Philippe Proulx --- diff --git a/tests/cli/auto-source-discovery/test_auto_source_discovery b/tests/cli/auto-source-discovery/test_auto_source_discovery index 208928dc..07b0475e 100755 --- a/tests/cli/auto-source-discovery/test_auto_source_discovery +++ b/tests/cli/auto-source-discovery/test_auto_source_discovery @@ -30,7 +30,7 @@ NUM_TESTS=2 plan_tests $NUM_TESTS -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" diff --git a/tests/cli/test_convert_args b/tests/cli/test_convert_args index 6deecf7f..ed217e7f 100755 --- a/tests/cli/test_convert_args +++ b/tests/cli/test_convert_args @@ -81,8 +81,8 @@ if [ "$BT_OS_TYPE" = "mingw" ]; then 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 diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index d6fcf303..896f2a0f 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -22,7 +22,14 @@ # 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]}")" +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. @@ -52,12 +59,12 @@ export BT_OS_TYPE # 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 - BT_TESTS_BUILDDIR="$scriptdir/.." + BT_TESTS_BUILDDIR="$testsdir" fi export BT_TESTS_BUILDDIR