source: vendor/current/ctdb/tests/scripts/common.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.4 KB
Line 
1# Hey Emacs, this is a -*- shell-script -*- !!! :-)
2
3# Common variables and functions for all CTDB tests.
4
5# This expands the most probable problem cases like "." and "..".
6TEST_SUBDIR=$(dirname "$0")
7if [ $(dirname "$TEST_SUBDIR") = "." ] ; then
8 TEST_SUBDIR=$(cd "$TEST_SUBDIR" ; pwd)
9fi
10
11_test_dir=$(dirname "$TEST_SUBDIR")
12
13# If we are running from within the source tree then, depending on the
14# tests that we're running, we may need to add the top level bin/ and
15# tools/ subdirectories to $PATH. This means we need a way of
16# determining if we're running from within the source tree. There is
17# no use looking outside the tests/ subdirectory because anything
18# above that level may be meaningless and outside our control.
19# Therefore, we'll use existence of $_test_dir/run_tests.sh to
20# indicate that we're running in-tree - on a system where the tests
21# have been installed, this file will be absent (renamed and placed in
22# some bin/ directory).
23if [ -f "${_test_dir}/run_tests.sh" ] ; then
24 ctdb_dir=$(dirname "$_test_dir")
25
26 _tools_dir="${ctdb_dir}/tools"
27 if [ -d "$_tools_dir" ] ; then
28 PATH="${_tools_dir}:$PATH"
29 fi
30fi
31
32_test_bin_dir="${TEST_BIN_DIR:-${ctdb_dir}/bin}"
33case "$_test_bin_dir" in
34 /*) : ;;
35 *) _test_bin_dir="${PWD}/${_test_bin_dir}" ;;
36esac
37if [ -d "$_test_bin_dir" ] ; then
38 PATH="${_test_bin_dir}:$PATH"
39fi
40
41# Print a message and exit.
42die ()
43{
44 echo "$1" >&2 ; exit ${2:-1}
45}
Note: See TracBrowser for help on using the repository browser.