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 "..".
|
---|
6 | TEST_SUBDIR=$(dirname "$0")
|
---|
7 | if [ $(dirname "$TEST_SUBDIR") = "." ] ; then
|
---|
8 | TEST_SUBDIR=$(cd "$TEST_SUBDIR" ; pwd)
|
---|
9 | fi
|
---|
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).
|
---|
23 | if [ -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
|
---|
30 | fi
|
---|
31 |
|
---|
32 | _test_bin_dir="${TEST_BIN_DIR:-${ctdb_dir}/bin}"
|
---|
33 | case "$_test_bin_dir" in
|
---|
34 | /*) : ;;
|
---|
35 | *) _test_bin_dir="${PWD}/${_test_bin_dir}" ;;
|
---|
36 | esac
|
---|
37 | if [ -d "$_test_bin_dir" ] ; then
|
---|
38 | PATH="${_test_bin_dir}:$PATH"
|
---|
39 | fi
|
---|
40 |
|
---|
41 | # Print a message and exit.
|
---|
42 | die ()
|
---|
43 | {
|
---|
44 | echo "$1" >&2 ; exit ${2:-1}
|
---|
45 | }
|
---|