mirror of
https://github.com/samba-team/samba.git
synced 2025-01-06 13:18:07 +03:00
3d290e3152
When this test is called from wscript, only the exit code is checked. Track failures and return as non-zero exit code. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
65 lines
1.3 KiB
Bash
Executable File
65 lines
1.3 KiB
Bash
Executable File
#!/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"
|
|
exit 1
|
|
fi
|
|
|
|
LDBFILE=$1
|
|
failed=0
|
|
|
|
timestamp()
|
|
{
|
|
date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/\..*NZ$/.000000Z/'
|
|
}
|
|
|
|
subunit_fail_test()
|
|
{
|
|
timestamp
|
|
printf 'failure: %s [\n' "$1"
|
|
cat -
|
|
echo "]"
|
|
}
|
|
|
|
testit()
|
|
{
|
|
name="$1"
|
|
shift
|
|
cmdline="$@"
|
|
timestamp
|
|
printf 'test: %s\n' "$1"
|
|
output=$($cmdline 2>&1)
|
|
status=$?
|
|
if [ x$status = x0 ]; then
|
|
timestamp
|
|
printf 'success: %s\n' "$name"
|
|
else
|
|
echo "$output" | subunit_fail_test "$name"
|
|
fi
|
|
return $status
|
|
}
|
|
|
|
$BINDIR/tdbdump $LDBFILE | sort >orig_dump
|
|
|
|
testit "normal tdbbackup on tdb file" $BINDIR/tdbbackup $LDBFILE -s .bak \
|
|
|| failed=$((failed + 1))
|
|
$BINDIR/tdbdump $LDBFILE.bak | sort >bak_dump
|
|
testit "cmp between tdbdumps of original and backup" cmp orig_dump bak_dump \
|
|
|| failed=$((failed + 1))
|
|
rm $LDBFILE.bak
|
|
rm bak_dump
|
|
|
|
testit "readonly tdbbackup on tdb file" $BINDIR/tdbbackup $LDBFILE -s .bak -r \
|
|
|| failed=$((failed + 1))
|
|
$BINDIR/tdbdump $LDBFILE.bak | sort >bak_dump
|
|
testit "cmp between tdbdumps of original and back dbs" cmp orig_dump bak_dump \
|
|
|| failed=$((failed + 1))
|
|
rm $LDBFILE.bak
|
|
rm bak_dump
|
|
|
|
rm orig_dump
|
|
|
|
exit $failed
|