3 # Blackbox test for net conf/registry roundtrips.
5 # Copyright (C) 2010 Gregor Beck <gbeck@sernet.de>
6 # Copyright (C) 2011 Michael Adam <obnox@samba.org>
10 Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION RPC
21 NET
="$VALGRIND ${NET} $CONFIGURATION"
23 if test "x${RPC}" = "xrpc" ; then
24 NETCMD
="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc"
30 incdir
=`dirname $0`/..
/..
/..
/testprogs
/blackbox
42 s/read prediction/;&/g
52 REGPATH
="HKLM\Software\Samba"
54 conf_roundtrip_step
() {
58 echo "RC: $RC" >> $LOG
59 test "x$RC" = "x0" ||
{
60 echo "ERROR: $@ failed (RC=$RC)" |
tee -a $LOG
66 LOGDIR_PREFIX
="conf_roundtrip"
70 DIR
=$
(mktemp
-d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX
)
73 echo conf_roundtrip
$1 > $LOG
75 sed -e "$SED_INVALID_PARAMS" $1 >$DIR/conf_in
77 conf_roundtrip_step
$NETCMD conf drop
78 test "x$?" = "x0" ||
{
82 test -z "$($NETCMD conf list)" 2>>$LOG
83 if [ "$?" = "1" ]; then
84 echo "ERROR: conf drop failed" |
tee -a $LOG
88 conf_roundtrip_step
$NETCMD conf import
$DIR/conf_in
89 test "x$?" = "x0" ||
{
93 conf_roundtrip_step
$NETCMD conf list
> $DIR/conf_exp
94 test "x$?" = "x0" ||
{
98 grep "\[global\]" $DIR/conf_exp
>/dev
/null
2>>$LOG
99 if [ "$?" = "1" ]; then
100 echo "ERROR: conf import => conf export failed" |
tee -a $LOG
104 conf_roundtrip_step
$NETCMD -d10 registry
export $REGPATH $DIR/conf_exp.reg
105 test "x$?" = "x0" ||
{
109 conf_roundtrip_step
$NETCMD conf drop
110 test "x$?" = "x0" ||
{
114 test -z "$($NETCMD conf list)" 2>>$LOG
115 if [ "$?" = "1" ]; then
116 echo "ERROR: conf drop failed" |
tee -a $LOG
120 conf_roundtrip_step
$NETCMD registry import
$DIR/conf_exp.reg
121 test "x$?" = "x0" ||
{
125 conf_roundtrip_step
$NETCMD conf list
>$DIR/conf_out
126 test "x$?" = "x0" ||
{
130 diff -q $DIR/conf_out
$DIR/conf_exp
>> $LOG
131 if [ "$?" = "1" ]; then
132 echo "ERROR: registry import => conf export failed" |
tee -a $LOG
136 conf_roundtrip_step
$NETCMD registry
export $REGPATH $DIR/conf_out.reg
137 test "x$?" = "x0" ||
{
141 diff -q $DIR/conf_out.reg
$DIR/conf_exp.reg
>>$LOG
142 if [ "$?" = "1" ]; then
143 echo "Error: registry import => registry export failed" |
tee -a $LOG
149 CONF_FILES
=$SERVERCONFFILE
152 for OLDDIR
in $
(find ${PREFIX} -type d
-name "${LOGDIR_PREFIX}_*") ; do
153 echo "removing old directory ${OLDDIR}"
157 for conf_file
in $CONF_FILES
159 testit
"conf_roundtrip $conf_file" \
160 conf_roundtrip
$conf_file \
161 || failed
=`expr $failed + 1`