6032bbc985e48320638aab4111ba6fa46bca08b7
[obnox/samba/samba-obnox.git] / testprogs / blackbox / dbcheck-oldrelease.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: dbcheck.sh PREFIX RELEASE
6 EOF
7 exit 1;
8 fi
9
10 PREFIX_ABS="$1"
11 RELEASE="$2"
12 shift 2
13
14 . `dirname $0`/subunit.sh
15
16 release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
17
18 undump() {
19        if test -x $BINDIR/tdbrestore;
20        then
21         `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
22        else
23         `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
24        fi
25 }
26
27 reindex() {
28        $BINDIR/samba-tool dbcheck --reindex -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
29 }
30
31 # This should 'fail', because it returns the number of modified records
32 dbcheck() {
33        $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
34 }
35 # But having fixed it all up, this should pass
36 dbcheck_clean() {
37        $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
38 }
39
40 if [ -d $release_dir ]; then
41     testit $RELEASE undump
42     testit "reindex" reindex
43     testit_expect_failure "dbcheck" dbcheck
44     testit "dbcheck_clean" dbcheck_clean
45 else
46     subunit_start_test $RELEASE
47     subunit_skip_test $RELEASE <<EOF
48 no test provision
49 EOF
50
51     subunit_start_test "reindex"
52     subunit_skip_test "reindex" <<EOF
53 no test provision
54 EOF
55     subunit_start_test "dbcheck"
56     subunit_skip_test "dbcheck" <<EOF
57 no test provision
58 EOF
59     subunit_start_test "dbcheck_clean"
60     subunit_skip_test "dbcheck_clean" <<EOF
61 no test provision
62 EOF
63 fi
64
65 exit $failed