From: Martin Schwenke Date: Wed, 7 Feb 2018 02:56:34 +0000 (+1100) Subject: ctdb-tests: Factor out setup of fake CTDB_BASE X-Git-Tag: talloc-2.1.12~213 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1c87b26090fd357da1f0bce3ede025d03ffb96a;p=thirdparty%2Fsamba.git ctdb-tests: Factor out setup of fake CTDB_BASE 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh index 099eee11d9c..b37b8a1a5b1 100644 --- a/ctdb/tests/scripts/common.sh +++ b/ctdb/tests/scripts/common.sh @@ -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 [item-to-copy]... +setup_ctdb_base () +{ + [ $# -ge 2 ] || die "usage: setup_ctdb_base [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 [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 +}