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 CONFIGURATION
19 NET
="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
22 if test "x${RPC}" = "xrpc" ; then
23 NETREG
="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry"
25 NETREG
="${NET} registry"
28 test x
"$TEST_FUNCTIONS_SH" != x
"INCLUDED" && {
29 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 local 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
$NET conf drop
78 test "x$?" = "x0" ||
{
82 test -z "$($NET conf list)" 2>>$LOG
83 if [ "$?" = "1" ]; then
84 echo "ERROR: conf drop failed" |
tee -a $LOG
88 conf_roundtrip_step
$NET conf import
$DIR/conf_in
89 test "x$?" = "x0" ||
{
93 conf_roundtrip_step
$NET 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
$NET -d10 registry
export $REGPATH $DIR/conf_exp.reg
105 test "x$?" = "x0" ||
{
109 conf_roundtrip_step
$NET conf drop
110 test "x$?" = "x0" ||
{
114 test -z "$($NET conf list)" 2>>$LOG
115 if [ "$?" = "1" ]; then
116 echo "ERROR: conf drop failed" |
tee -a $LOG
120 conf_roundtrip_step
$NET registry import
$DIR/conf_exp.reg
121 test "x$?" = "x0" ||
{
125 conf_roundtrip_step
$NET 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
$NET 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
=${CONF_FILES:-$(find $SRCDIR/ -name '*.conf' | grep -v examples/logon | xargs grep -l "\[global\]")}
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`