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
41 s/read prediction/;&/g
50 REGPATH
="HKLM\Software\Samba"
52 conf_roundtrip_step
() {
56 echo "RC: $RC" >> $LOG
57 test "x$RC" = "x0" ||
{
58 echo "ERROR: $@ failed (RC=$RC)" |
tee -a $LOG
64 LOGDIR_PREFIX
="conf_roundtrip"
68 local DIR
=$
(mktemp
-d ${PREFIX}/${LOGDIR_PREFIX}_XXXX
)
71 echo conf_roundtrip
$1 > $LOG
73 sed -e "$SED_INVALID_PARAMS" $1 >$DIR/conf_in
75 conf_roundtrip_step
$NET conf drop
76 test "x$?" = "x0" ||
{
80 test -z "$($NET conf list)" 2>>$LOG
81 if [ "$?" = "1" ]; then
82 echo "ERROR: conf drop failed" |
tee -a $LOG
86 conf_roundtrip_step
$NET conf import
$DIR/conf_in
87 test "x$?" = "x0" ||
{
91 conf_roundtrip_step
$NET conf list
> $DIR/conf_exp
92 test "x$?" = "x0" ||
{
96 grep "\[global\]" $DIR/conf_exp
>/dev
/null
2>>$LOG
97 if [ "$?" = "1" ]; then
98 echo "ERROR: conf import => conf export failed" |
tee -a $LOG
102 conf_roundtrip_step
$NET -d10 registry
export $REGPATH $DIR/conf_exp.reg
103 test "x$?" = "x0" ||
{
107 conf_roundtrip_step
$NET conf drop
108 test "x$?" = "x0" ||
{
112 test -z "$($NET conf list)" 2>>$LOG
113 if [ "$?" = "1" ]; then
114 echo "ERROR: conf drop failed" |
tee -a $LOG
118 conf_roundtrip_step
$NET registry import
$DIR/conf_exp.reg
119 test "x$?" = "x0" ||
{
123 conf_roundtrip_step
$NET conf list
>$DIR/conf_out
124 test "x$?" = "x0" ||
{
128 diff -q $DIR/conf_out
$DIR/conf_exp
>> $LOG
129 if [ "$?" = "1" ]; then
130 echo "ERROR: registry import => conf export failed" |
tee -a $LOG
134 conf_roundtrip_step
$NET registry
export $REGPATH $DIR/conf_out.reg
135 test "x$?" = "x0" ||
{
139 diff -q $DIR/conf_out.reg
$DIR/conf_exp.reg
>>$LOG
140 if [ "$?" = "1" ]; then
141 echo "Error: registry import => registry export failed" |
tee -a $LOG
147 CONF_FILES
=${CONF_FILES:-$(find $SRCDIR/ -name '*.conf' | grep -v examples/logon | xargs grep -l "\[global\]")}
150 for OLDDIR
in $
(find ${PREFIX} -type d
-name "${LOGDIR_PREFIX}_*") ; do
151 echo "removing old directory ${OLDDIR}"
155 for conf_file
in $CONF_FILES
157 testit
"conf_roundtrip $conf_file" \
158 conf_roundtrip
$conf_file \
159 || failed
=`expr $failed + 1`