1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

tdb: Add test for tdbdump command

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Christof Schmitt 2024-04-12 15:44:38 -07:00
parent 3d290e3152
commit f6a47de2db
3 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,12 @@
{
key(11) = "nbt_server\00"
data(35) = "972.2147483648/1085706313786795392\00"
}
{
key(15) = "winbind_server\00"
data(25) = "977/12826542715097898407\00"
}
{
key(14) = "notify-daemon\00"
data(24) = "992/6389638235474936598\00"
}

53
lib/tdb/test/test_tdbdump.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/sh
# Test dumping of tdb database
# Copyright (C) 2024 Christof Schmitt <cs@samba.org>
if [ $# -lt 3 ]; then
echo "Usage: $0 TDB_FILE EXPECTED_DUMP EXPECTED_DUMP_X"
exit 1
fi
TDB_FILE=$1
EXPECTED_DUMP=$2
TEMP_DUMP=tempdump.txt
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 $TDB_FILE > $TEMP_DUMP
testit "Verifying tdbdump" cmp $TEMP_DUMP $EXPECTED_DUMP \
|| failed=$(expr $failed + 1)
rm $TEMP_DUMP
exit $failed

View File

@ -216,7 +216,8 @@ def testonly(ctx):
if not os.path.exists(link):
os.symlink(ctx.path.make_node('test').abspath(), link)
sh_tests = ["test/test_tdbbackup.sh test/jenkins-be-hash.tdb"]
sh_tests = ["test/test_tdbbackup.sh test/jenkins-be-hash.tdb",
"test/test_tdbdump.sh test/sample_tdb.tdb test/sample_tdb.txt"]
for sh_test in sh_tests:
cmd = "BINDIR=%s %s" % (blddir, sh_test)