]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Factor out setup of fake CTDB_BASE
authorMartin Schwenke <martin@meltin.net>
Wed, 7 Feb 2018 02:56:34 +0000 (13:56 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:25 +0000 (07:08 +0100)
Several test suites need the CTDB_BASE directory to contain a subset
of the regular contents of that subdirectory.  In some cases there are
symbolic links in the test directory (or a subdirectory) and these
symbolic links need to be fixed at installation time.

Instead, add new function setup_ctdb_base() to set CTDB_BASE, create
the directory and populate it as specified.  This relies on
script_install_paths.sh so it can copy the specified targets.  It also
copies any files from the test directory's etc-ctdb/ subdirectory.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/scripts/common.sh

index 099eee11d9c48e1fd520e2e1aebb3642ba113694..b37b8a1a5b1de06c3384c6fc298a5decf4f4ecf7 100644 (file)
@@ -48,6 +48,8 @@ if [ -d "$_test_bin_dir" ] ; then
        PATH="${_test_bin_dir}:$PATH"
 fi
 
+. "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
+
 # Wait until either timeout expires or command succeeds.  The command
 # will be tried once per second, unless timeout has format T/I, where
 # I is the recheck interval.
@@ -91,3 +93,36 @@ wait_until ()
 
     return 1
 }
+
+# setup_ctdb_base <parent> <subdir> [item-to-copy]...
+setup_ctdb_base ()
+{
+       [ $# -ge 2 ] || die "usage: setup_ctdb_base <parent> <subdir> [item]..."
+       # If empty arguments are passed then we attempt to remove /
+       # (i.e. the root directory) below
+       [ -n "$1" -a -n "$2" ] || \
+               die "usage: setup_ctdb_base <parent> <subdir> [item]..."
+
+       _parent="$1"
+       _subdir="$2"
+
+       # Other arguments are files/directories to copy
+       shift 2
+
+       export CTDB_BASE="${_parent}/${_subdir}"
+       if [ -d "$CTDB_BASE" ] ; then
+               rm -r "$CTDB_BASE"
+       fi
+       mkdir -p  "$CTDB_BASE" || die "Failed to create CTDB_BASE=$CTDB_BASE"
+
+       for _i ; do
+               cp -pr "${CTDB_SCRIPTS_BASE}/${_i}" "${CTDB_BASE}/"
+       done
+
+       for _i in "${TEST_SUBDIR}/etc-ctdb/"* ; do
+               # No/empty etc-ctdb directory
+               [ -e "$_i" ] || break
+
+               cp -pr "$_i" "${CTDB_BASE}/"
+       done
+}