summaryrefslogtreecommitdiff
path: root/testprogs
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-10-20 20:47:43 +0200
committerKarolin Seeger <kseeger@samba.org>2020-10-27 08:22:02 +0000
commit33b116da10aa8a79a45f32480277cbc2072242b3 (patch)
tree594123c136109b256df912e6c33250a78d453928 /testprogs
parentdaeada8e48ea426288eb55187e3ff200bb81f145 (diff)
downloadsamba-33b116da10aa8a79a45f32480277cbc2072242b3.tar.gz
testprogs: Fix and improve demote-saveddb test
This fixes running `make test` in a release tarball! BUG: https://bugzilla.samba.org/show_bug.cgi?id=14542 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> (cherry picked from commit e58ccdaa1a1e5943aa02ecba88d1de0323777041)
Diffstat (limited to 'testprogs')
-rwxr-xr-xtestprogs/blackbox/demote-saveddb.sh75
1 files changed, 43 insertions, 32 deletions
diff --git a/testprogs/blackbox/demote-saveddb.sh b/testprogs/blackbox/demote-saveddb.sh
index 3d5fabd72e3..d8fccf32011 100755
--- a/testprogs/blackbox/demote-saveddb.sh
+++ b/testprogs/blackbox/demote-saveddb.sh
@@ -10,58 +10,69 @@ fi
PREFIX_ABS="$1"
shift 1
-. `dirname $0`/subunit.sh
+failed=0
-tree_dir=`dirname $0`/../../source4/selftest/provisions/multi-dc-samba-master-c596ac6
+. `dirname $0`/subunit.sh
+. `dirname $0`/common_test_fns.inc
-undump() {
- if test -x $BINDIR/tdbrestore;
- then
- `dirname $0`/../../source4/selftest/provisions/undump.sh $tree_dir $PREFIX_ABS $BINDIR/tdbrestore
- else
- `dirname $0`/../../source4/selftest/provisions/undump.sh $tree_dir $PREFIX_ABS
- fi
-}
+samba_tree_dir="$SRCDIR_ABS/source4/selftest/provisions/multi-dc-samba-master-c596ac6"
-demote() {
- $PYTHON $BINDIR/samba-tool domain demote -H tdb://$PREFIX_ABS/private/sam.ldb --remove-other-dead-server=$1
-}
+samba_tdbrestore="tdbrestore"
+if [ -x $BINDIR/tdbrestore ]; then
+ samba_tdbrestore="$BINDIR/tdbrestore"
+fi
+# The undump script and the provision data is not part of release tarballs,
+# skip the tests in this case!
+samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
+if [ ! -x $samba_undump ] || [ ! -d $samba_tree_dir ]; then
+ subunit_start_test "undump"
+ subunit_skip_test "undump" <<EOF
+EOF
-if [ -d $tree_dir ]; then
- testit "undump" undump
- testit "demote-q-0-0" demote "q-0-0"
- # The database was copied of q-0-1 so this will fail
- # as we can't remove our own name
- testit_expect_failure "demote-q-0-1" demote "q-0-1"
- testit "demote-q-1-0" demote "q-1-0"
- testit "demote-q-1-1" demote "q-1-1"
-else
subunit_start_test "undump"
subunit_skip_test "undump" <<EOF
-no test provision
+Skipping tests - no provision!
EOF
subunit_start_test "demote-q-0-0"
subunit_skip_test "demote-q-0-0" <<EOF
-no test provision
+Skipping tests - no provision!
EOF
subunit_start_test "demote-q-0-1"
subunit_skip_test "demote-q-0-1" <<EOF
-no test provision
+Skipping tests - no provision!
EOF
- subunit_start_test "demote-q-1-1"
- subunit_skip_test "demote-q-0-1" <<EOF
-no test provision
+ subunit_start_test "demote-q-1-0"
+ subunit_skip_test "demote-q-1-0" <<EOF
+Skipping tests - no provision!
EOF
subunit_start_test "demote-q-1-1"
subunit_skip_test "demote-q-1-1" <<EOF
-no test provision
+Skipping tests - no provision!
EOF
-fi
-if [ -d $PREFIX_ABS ]; then
- rm -fr $PREFIX_ABS
+ exit 0
fi
+undump() {
+ $SRCDIR_ABS/source4/selftest/provisions/undump.sh $samba_tree_dir $PREFIX_ABS $samba_tdbrestore
+}
+
+demote() {
+ $PYTHON $BINDIR/samba-tool domain demote -H tdb://$PREFIX_ABS/private/sam.ldb --remove-other-dead-server=$1
+}
+
+remove_directory $PREFIX_ABS
+
+testit "undump" undump || failed=`expr $failed + 1`
+testit "demote-q-0-0" demote "q-0-0" || failed=`expr $failed + 1`
+# The database was copied of q-0-1 so this will fail
+# as we can't remove our own name
+testit_expect_failure "demote-q-0-1" demote "q-0-1" || failed=`expr $failed + 1`
+testit "demote-q-1-0" demote "q-1-0" || failed=`expr $failed + 1`
+testit "demote-q-1-1" demote "q-1-1" || failed=`expr $failed + 1`
+
+remove_directory $PREFIX_ABS
+
exit $failed