cefb782c1d2aef4207dcbda646d45375708dbfa1
[lttng-ust.git] / tests / utils / utils.sh
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (c) 2019 Michael Jeanson <mjeanson@efficios.com>
6 # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
7 #
8
9 # This file is meant to be sourced at the start of shell script-based tests.
10
11
12 # Error out when encountering an undefined variable
13 set -u
14
15 # If "readlink -f" is available, get a resolved absolute path to the
16 # tests source dir, otherwise make do with a relative path.
17 scriptdir="$(dirname "${BASH_SOURCE[0]}")"
18 if readlink -f "." >/dev/null 2>&1; then
19 testsdir=$(readlink -f "$scriptdir/..")
20 else
21 testsdir="$scriptdir/.."
22 fi
23
24 # Allow overriding the source and build directories
25 if [ "x${UST_TESTS_SRCDIR:-}" = "x" ]; then
26 UST_TESTS_SRCDIR="$testsdir"
27 fi
28 export UST_TESTS_SRCDIR
29
30 if [ "x${UST_TESTS_BUILDDIR:-}" = "x" ]; then
31 UST_TESTS_BUILDDIR="$testsdir"
32 fi
33 export UST_TESTS_BUILDDIR
This page took 0.029152 seconds and 3 git commands to generate.