s3:test: in net registry roundtrip test, mark "lock dir" as invalid parameter
[Samba.git] / source3 / script / tests / test_net_registry_roundtrip.sh
blob77f3b8451c55b873d6cbe92b990b6c099af30183
1 #!/bin/sh
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>
8 NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
11 if test "x${RPC}" = "xrpc" ; then
12 NETREG="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry"
13 else
14 NETREG="${NET} registry"
17 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
18 incdir=`dirname $0`/../../../testprogs/blackbox
19 . $incdir/subunit.sh
22 failed=0
24 SED_INVALID_PARAMS="{
25 s/lock directory/;&/g
26 s/lock dir/;&/g
27 s/modules dir/;&/g
28 s/logging/;&/g
29 s/status/;&/g
30 s/logdir/;&/g
31 s/read prediction/;&/g
32 s/mkprofile/;&/g
33 s/valid chars/;&/g
34 s/timesync/;&/g
35 s/sambaconf/;&/g
36 s/logtype/;&/g
37 s/servername/;&/g
40 REGPATH="HKLM\Software\Samba"
42 conf_roundtrip_step() {
43 echo "CMD: $*" >>$LOG
44 $@ 2>>$LOG
45 RC=$?
46 echo "RC: $RC" >> $LOG
47 test "x$RC" = "x0" || {
48 echo "ERROR: $@ failed (RC=$RC)" | tee -a $LOG
50 return $RC
51 # echo -n .
54 LOGDIR_PREFIX="conf_roundtrip"
56 conf_roundtrip()
58 local DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXX)
59 local LOG=$DIR/log
61 echo conf_roundtrip $1 > $LOG
63 sed -e "$SED_INVALID_PARAMS" $1 >$DIR/conf_in
65 conf_roundtrip_step $NET conf drop
66 test "x$?" = "x0" || {
67 return 1
70 test -z "$($NET conf list)" 2>>$LOG
71 if [ "$?" = "1" ]; then
72 echo "ERROR: conf drop failed" | tee -a $LOG
73 return 1
76 conf_roundtrip_step $NET conf import $DIR/conf_in
77 test "x$?" = "x0" || {
78 return 1
81 conf_roundtrip_step $NET conf list > $DIR/conf_exp
82 test "x$?" = "x0" || {
83 return 1
86 grep "\[global\]" $DIR/conf_exp >/dev/null 2>>$LOG
87 if [ "$?" = "1" ]; then
88 echo "ERROR: conf import => conf export failed" | tee -a $LOG
89 return 1
92 conf_roundtrip_step $NET -d10 registry export $REGPATH $DIR/conf_exp.reg
93 test "x$?" = "x0" || {
94 return 1
97 conf_roundtrip_step $NET conf drop
98 test "x$?" = "x0" || {
99 return 1
102 test -z "$($NET conf list)" 2>>$LOG
103 if [ "$?" = "1" ]; then
104 echo "ERROR: conf drop failed" | tee -a $LOG
105 return 1
108 conf_roundtrip_step $NET registry import $DIR/conf_exp.reg
109 test "x$?" = "x0" || {
110 return 1
113 conf_roundtrip_step $NET conf list >$DIR/conf_out
114 test "x$?" = "x0" || {
115 return 1
118 diff -q $DIR/conf_out $DIR/conf_exp >> $LOG
119 if [ "$?" = "1" ]; then
120 echo "ERROR: registry import => conf export failed" | tee -a $LOG
121 return 1
124 conf_roundtrip_step $NET registry export $REGPATH $DIR/conf_out.reg
125 test "x$?" = "x0" || {
126 return 1
129 diff -q $DIR/conf_out.reg $DIR/conf_exp.reg >>$LOG
130 if [ "$?" = "1" ]; then
131 echo "Error: registry import => registry export failed" | tee -a $LOG
132 return 1
134 rm -r $DIR
137 CONF_FILES=${CONF_FILES:-$(find $SRCDIR/ -name '*.conf' | grep -v examples/logon | xargs grep -l "\[global\]")}
139 # remove old logs:
140 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
141 echo "removing old directory ${OLDDIR}"
142 rm -rf ${OLDDIR}
143 done
145 for conf_file in $CONF_FILES
147 testit "conf_roundtrip $conf_file" \
148 conf_roundtrip $conf_file \
149 || failed=`expr $failed + 1`
150 done
152 testok $0 $failed