3 # Blackbox tests for the "net registry check" command.
5 # Copyright (C) 2011 Björn Baumbach <bb@sernet.de>
8 echo "Usage: test_net_registry.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION DBWRAP_TOOL"
16 DBWRAP_TOOL
="$5 --persistent"
18 NET
="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
20 NETREG
="${NET} registry"
21 REGORIG
="$(grep 'state directory = ' $SERVERCONFFILE | sed 's/[^=]*=//')/registry.tdb"
24 incdir
=`dirname $0`/..
/..
/..
/testprogs
/blackbox
29 # run registry check and filter allowed errors
32 ALLOWEDERR
="Check database:|INFO: version ="
33 ERRSTR
=$
(${NETREG} check
$REG $@
2>&1 |
egrep -v "$ALLOWEDERR")
36 # try to repair registry
42 # check if $ERRSTR contains expected error
47 ERRCNT
=$
(echo "$ERRSTR" |
grep "$EXPERR" |
wc -l)
58 test "$?" -eq "$ERRCNT" ||
{
59 echo "Expected $EXPERRCNT of error $EXPERR. Received $ERRCNT"
65 test "x$ERRSTR" = "x" ||
{
66 echo "Error: Can't repair database"
77 test "x$ERRSTR" = "x" ||
{
91 $DBWRAP_TOOL $REG store
'HKLM/SOFTWARE' hex
'02000000534F4654574152450053595354454D00'
93 regchecknrepair
"Duplicate subkeylist" 1
99 $DBWRAP_TOOL $REG store
'HKLM/SOFTWARE' hex
'02000000534F4654574152450053595354454D00'
101 regchecknrepair
"Unnormal key:" 1
107 $DBWRAP_TOOL $REG store
'HKLM\Software' hex
'02000000534F4654574152450053595354454D00'
109 regchecknrepair
"Unnormal key:" 1
112 test_strangeletters
()
115 $DBWRAP_TOOL $REG store
'HKLM\SOFTWARE' hex
'02000000534F4654574FABFABFABFAB354454D00'
117 regchecknrepair
"Conversion error: Incomplete multibyte sequence" 1
122 failed
=`expr $failed + 1`
124 testit
"damages_registry" \
126 failed
=`expr $failed + 1`
130 failed
=`expr $failed + 1`
134 failed
=`expr $failed + 1`
138 failed
=`expr $failed + 1`
140 #Can't repair this atm
141 #testit "strangeletters" \
142 # test_strangeletters || \
143 # failed=`expr $failed + 1`