From dc2dfbdb93eadd4e3112af9cdd33b43042f7ec20 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 24 Apr 2012 16:28:15 +1000 Subject: tests: Add installation script for tests This could all be done in Makefile.in, but that would be very complex. Signed-off-by: Martin Schwenke (This used to be ctdb commit 12c9986059cacda819e669fa77d613b408c62599) --- ctdb/Makefile.in | 4 +++ ctdb/tests/INSTALL | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100755 ctdb/tests/INSTALL diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in index 7b7f356331..843a948d66 100755 --- a/ctdb/Makefile.in +++ b/ctdb/Makefile.in @@ -364,6 +364,10 @@ install_pmda: $(INSTALLCMD) -m 644 pmda/pmns pmda/domain.h pmda/help pmda/README $(PMDA_DEST_DIR) $(INSTALLCMD) -m 755 bin/pmdactdb $(PMDA_DEST_DIR) +# Should use $(datarootdir) but older autoconfs don't do this. :-( +install_tests: all + tests/INSTALL --destdir=$(DESTDIR) --datarootdir=$(prefix)/share --libdir=$(libdir) --bindir=$(bindir) --etcdir=$(etcdir) + test: all tests/run_tests.sh diff --git a/ctdb/tests/INSTALL b/ctdb/tests/INSTALL new file mode 100755 index 0000000000..6f43650cce --- /dev/null +++ b/ctdb/tests/INSTALL @@ -0,0 +1,91 @@ +#!/bin/sh + +# Script to install the CTDB testsuite on a machine. + +usage () +{ + if [ -n "$1" ] ; then + echo "$1" + echo + fi + + cat < \\ + --datarootdir= \\ + --libdir= \\ + --bindir= \\ + --etcdir= +EOF + exit 1 +} + +parse_options () +{ + temp=$(getopt -n "$prog" -o "h" -l help,destdir:,datarootdir:,libdir:,bindir:,etcdir: -- "$@") + + [ $? != 0 ] && usage + + eval set -- "$temp" + + destdir="" + datarootdir="" + libdir="" + bindir="" + etcdir="" + + while true ; do + case "$1" in + --destdir) destdir="$2" ; shift 2 ;; + --datarootdir) datarootdir="$2" ; shift 2 ;; + --libdir) libdir="$2" ; shift 2 ;; + --bindir) bindir="$2" ; shift 2 ;; + --etcdir) etcdir="$2" ; shift 2 ;; + --) shift ; break ;; + -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable. + esac + done + + [ $# -gt 0 ] && usage + + [ -n "$destdir" ] || usage "No option --destdir specified" + [ -n "$datarootdir" ] || usage "No option --datarootdir specified" + [ -n "$libdir" ] || usage "No option --libdir specified" + [ -n "$bindir" ] || usage "No option --bindir specified" + [ -n "$etcdir" ] || usage "No option --etcdir specified" +} + +parse_options "$@" + +# Make things neater! +if [ "$destdir" = "/" ] ; then + destdir="" +fi + +data_subdirs="complex events.d eventscripts onnode scripts simple takeover tool" + +ctdb_datadir="${destdir}${datarootdir}/ctdb-tests" +echo "Installing test data files into ${ctdb_datadir}..." +for d in $data_subdirs ; do + mkdir -p "${ctdb_datadir}/${d}" + cp -pr "tests/${d}" "${ctdb_datadir}" +done +# Some of the unit tests have relative symlinks back to in-tree bits +# and pieces. These links will be broken! +for i in "events.d" "functions" ; do + ln -sf "${etcdir}/ctdb/${i}" "${ctdb_datadir}/eventscripts/etc-ctdb/${i}" +done + +ctdb_libdir="${destdir}${libdir}/ctdb-tests" +mkdir -p "${destdir}${libdir}" +echo "Installing test binary files into ${ctdb_libdir}..." +cp -pr "tests/bin/" "${ctdb_libdir}" + +ctdb_bindir="${destdir}${bindir}" +echo "Installing wrapper scripts into ${ctdb_bindir}..." +mkdir -p "${ctdb_bindir}" +for i in tests/run_tests.sh tests/run_cluster_tests.sh ; do + b=$(basename "$i" ".sh") + out="${ctdb_bindir}/ctdb_${b}" + sed -e "s@^test_dir=.*@test_dir=${datarootdir}/ctdb-tests\nexport TEST_BIN_DIR=\"${libdir}/ctdb-tests\"@" "$i" >"${out}" + chmod 755 "$out" +done -- cgit