ctdb-tests: nfs_iterate_test() marks RPC service down
[samba4-gss.git] / lib / tdb / test / test_tdbbackup.sh
blob7bc025ca42b0ada35d62069aa42712226d03e290
1 #!/bin/sh
2 # Blackbox test for tdbbackup of given ldb or tdb database
3 # Copyright (C) 2018 Andrew Bartlett <abartlet@samba.org>
5 if [ $# -lt 1 ]; then
6 echo "Usage: $0 LDBFILE"
7 exit 1
8 fi
10 LDBFILE=$1
11 failed=0
13 timestamp()
15 date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/\..*NZ$/.000000Z/'
18 subunit_fail_test()
20 timestamp
21 printf 'failure: %s [\n' "$1"
22 cat -
23 echo "]"
26 testit()
28 name="$1"
29 shift
30 cmdline="$@"
31 timestamp
32 printf 'test: %s\n' "$1"
33 output=$($cmdline 2>&1)
34 status=$?
35 if [ x$status = x0 ]; then
36 timestamp
37 printf 'success: %s\n' "$name"
38 else
39 echo "$output" | subunit_fail_test "$name"
41 return $status
44 $BINDIR/tdbdump $LDBFILE | sort >orig_dump
46 testit "normal tdbbackup on tdb file" $BINDIR/tdbbackup $LDBFILE -s .bak \
47 || failed=$((failed + 1))
48 $BINDIR/tdbdump $LDBFILE.bak | sort >bak_dump
49 testit "cmp between tdbdumps of original and backup" cmp orig_dump bak_dump \
50 || failed=$((failed + 1))
51 rm $LDBFILE.bak
52 rm bak_dump
54 testit "readonly tdbbackup on tdb file" $BINDIR/tdbbackup $LDBFILE -s .bak -r \
55 || failed=$((failed + 1))
56 $BINDIR/tdbdump $LDBFILE.bak | sort >bak_dump
57 testit "cmp between tdbdumps of original and back dbs" cmp orig_dump bak_dump \
58 || failed=$((failed + 1))
59 rm $LDBFILE.bak
60 rm bak_dump
62 rm orig_dump
64 exit $failed