tests: When running local tests with run_tests.sh, use fixed TEST_VAR_DIR
[vlendec/samba-autobuild/.git] / ctdb / tests / run_tests.sh
1 #!/bin/sh
2
3 test_dir=$(dirname "$0")
4
5 case $(basename "$0") in
6     *run_cluster_tests*)
7         # Running on a cluster:
8         # * print summary, run any integration tests against cluster
9         # * default to running: all integration tests, no unit tests
10         opts="-s"
11         tests="simple complex"
12         ;;
13     *)
14         # Running on local machine:
15         # * print summary, run any integration tests against local daemons
16         # * default to running: all unit tests, simple integration tests
17         opts="-s -l"
18         tests="onnode takeover tool eventscripts simple"
19         # If running in the source tree then use a fixed TEST_VAR_DIR.
20         # If this script is installed using the INSTALL script then
21         # TEST_BIN_DIR will be set, so use this as the test.
22         if [ -z "$TEST_BIN_DIR" ] ; then
23             opts="${opts} -V ${test_dir}/var"
24         fi
25 esac
26
27 # Allow options to be passed to this script.  However, if any options
28 # are passed there must be a "--" between the options and the tests.
29 # This makes it easy to handle options that take arguments.
30 case "$1" in
31     -*)
32         while [ -n "$1" ] ; do
33             case "$1" in
34                 --) shift ; break ;;
35                 *) opts="$opts $1" ; shift ;;
36             esac
37         done
38 esac
39
40 # If no tests are specified, then run the defaults.
41 [ -n "$1" ] || set -- $tests
42
43 "${test_dir}/scripts/run_tests" $opts "$@" || exit 1
44
45 echo "All OK"
46 exit 0