1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
3 # Common variables and functions for all CTDB tests.
5 # This expands the most probable problem cases like "." and "..".
6 TEST_SUBDIR
=$
(dirname "$0")
7 if [ $
(dirname "$TEST_SUBDIR") = "." ] ; then
8 TEST_SUBDIR
=$
(cd "$TEST_SUBDIR" ; pwd)
11 _test_dir
=$
(dirname "$TEST_SUBDIR")
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).
23 if [ -f "${_test_dir}/run_tests.sh" ] ; then
24 ctdb_dir
=$
(dirname "$_test_dir")
26 _tools_dir
="${ctdb_dir}/tools"
27 if [ -d "$_tools_dir" ] ; then
28 PATH
="${_tools_dir}:$PATH"
32 _test_bin_dir
="${TEST_BIN_DIR:-${_test_dir}/bin}"
33 if [ -d "$_test_bin_dir" ] ; then
34 PATH
="${_test_bin_dir}:$PATH"
37 # Print a message and exit.
40 echo "$1" >&2 ; exit ${2:-1}