2018-07-31 10:07:53 +12:00
#!/bin/sh
# Blackbox test for tdbbackup of given ldb or tdb database
# Copyright (C) 2018 Andrew Bartlett <abartlet@samba.org>
if [ $# -lt 1 ] ; then
echo " Usage: $0 LDBFILE "
2022-02-21 11:17:52 +01:00
exit 1
2018-07-31 10:07:53 +12:00
fi
LDBFILE = $1
2024-04-12 15:22:06 -07:00
failed = 0
2018-07-31 10:07:53 +12:00
2022-02-21 11:17:52 +01:00
timestamp( )
{
date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/\..*NZ$/.000000Z/'
2018-07-31 10:07:53 +12:00
}
2022-02-21 11:17:52 +01:00
subunit_fail_test( )
{
timestamp
printf 'failure: %s [\n' " $1 "
cat -
echo "]"
2018-07-31 10:07:53 +12:00
}
2022-02-21 11:17:52 +01:00
testit( )
{
2018-07-31 10:07:53 +12:00
name = " $1 "
shift
cmdline = " $@ "
timestamp
printf 'test: %s\n' " $1 "
2022-02-21 11:17:52 +01:00
output = $( $cmdline 2>& 1)
2018-07-31 10:07:53 +12:00
status = $?
if [ x$status = x0 ] ; then
timestamp
printf 'success: %s\n' " $name "
else
echo " $output " | subunit_fail_test " $name "
fi
return $status
}
2022-02-21 11:17:52 +01:00
$BINDIR /tdbdump $LDBFILE | sort >orig_dump
2018-07-31 10:07:53 +12:00
2024-04-12 15:22:06 -07:00
testit "normal tdbbackup on tdb file" $BINDIR /tdbbackup $LDBFILE -s .bak \
|| failed = $(( failed + 1 ))
2022-02-21 11:17:52 +01:00
$BINDIR /tdbdump $LDBFILE .bak | sort >bak_dump
2024-04-12 15:22:06 -07:00
testit "cmp between tdbdumps of original and backup" cmp orig_dump bak_dump \
|| failed = $(( failed + 1 ))
2018-07-31 10:07:53 +12:00
rm $LDBFILE .bak
rm bak_dump
2024-04-12 15:22:06 -07:00
testit "readonly tdbbackup on tdb file" $BINDIR /tdbbackup $LDBFILE -s .bak -r \
|| failed = $(( failed + 1 ))
2022-02-21 11:17:52 +01:00
$BINDIR /tdbdump $LDBFILE .bak | sort >bak_dump
2024-04-12 15:22:06 -07:00
testit "cmp between tdbdumps of original and back dbs" cmp orig_dump bak_dump \
|| failed = $(( failed + 1 ))
2018-07-31 10:07:53 +12:00
rm $LDBFILE .bak
rm bak_dump
rm orig_dump
2024-04-12 15:22:06 -07:00
exit $failed