tests: readlink 'canonicalize' is GNU specific
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 23 Jul 2019 15:43:13 +0000 (11:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 23 Jul 2019 19:34:16 +0000 (15:34 -0400)
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>
tests/cli/auto-source-discovery/test_auto_source_discovery
tests/cli/test_convert_args
tests/utils/utils.sh

index 208928dc5f5166cd2b924efae3fd122f4a37139e..07b0475e95f5488628799dfba2523322be6896b8 100755 (executable)
@@ -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"
 
index 6deecf7f079777ff757de5cc0af2099f96f9ac30..ed217e7f9789e2a9bc8e4a2cca4d6cb7a5135081 100755 (executable)
@@ -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
 
index d6fcf303452b30648f8235e6cbfa052f73696713..896f2a0f29d4aeea42b42b4419520115321b262f 100644 (file)
 # 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
 
This page took 0.025977 seconds and 4 git commands to generate.