s3: Remove a call to procid_self()
[Samba/gebeck_regimport.git] / source3 / script / tests / test_net_registry_roundtrip.sh
blobf2158879e36583aab177dd22a4681ebca5ac46ba
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 if [ $# -lt 3 ]; then
9 cat <<EOF
10 Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION RPC
11 EOF
12 exit 1;
15 SCRIPTDIR="$1"
16 SERVERCONFFILE="$2"
17 NET="$3"
18 CONFIGURATION="$4"
19 RPC="$5"
21 NET="$VALGRIND ${NET} $CONFIGURATION"
23 if test "x${RPC}" = "xrpc" ; then
24 NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc"
25 else
26 NETCMD="${NET}"
30 incdir=`dirname $0`/../../../testprogs/blackbox
31 . $incdir/subunit.sh
33 failed=0
35 SED_INVALID_PARAMS="{
36 s/lock directory/;&/g
37 s/lock dir/;&/g
38 s/modules dir/;&/g
39 s/logging/;&/g
40 s/status/;&/g
41 s/logdir/;&/g
42 s/read prediction/;&/g
43 s/mkprofile/;&/g
44 s/valid chars/;&/g
45 s/timesync/;&/g
46 s/sambaconf/;&/g
47 s/logtype/;&/g
48 s/servername/;&/g
49 s/postscript/;&/g
52 REGPATH="HKLM\Software\Samba"
54 conf_roundtrip_step() {
55 echo "CMD: $*" >>$LOG
56 $@ 2>>$LOG
57 RC=$?
58 echo "RC: $RC" >> $LOG
59 test "x$RC" = "x0" || {
60 echo "ERROR: $@ failed (RC=$RC)" | tee -a $LOG
62 return $RC
63 # echo -n .
66 LOGDIR_PREFIX="conf_roundtrip"
68 conf_roundtrip()
70 DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
71 LOG=$DIR/log
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" || {
79 return 1
82 test -z "$($NETCMD conf list)" 2>>$LOG
83 if [ "$?" = "1" ]; then
84 echo "ERROR: conf drop failed" | tee -a $LOG
85 return 1
88 conf_roundtrip_step $NETCMD conf import $DIR/conf_in
89 test "x$?" = "x0" || {
90 return 1
93 conf_roundtrip_step $NETCMD conf list > $DIR/conf_exp
94 test "x$?" = "x0" || {
95 return 1
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
101 return 1
104 conf_roundtrip_step $NETCMD -d10 registry export $REGPATH $DIR/conf_exp.reg
105 test "x$?" = "x0" || {
106 return 1
109 conf_roundtrip_step $NETCMD conf drop
110 test "x$?" = "x0" || {
111 return 1
114 test -z "$($NETCMD conf list)" 2>>$LOG
115 if [ "$?" = "1" ]; then
116 echo "ERROR: conf drop failed" | tee -a $LOG
117 return 1
120 conf_roundtrip_step $NETCMD registry import $DIR/conf_exp.reg
121 test "x$?" = "x0" || {
122 return 1
125 conf_roundtrip_step $NETCMD conf list >$DIR/conf_out
126 test "x$?" = "x0" || {
127 return 1
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
133 return 1
136 conf_roundtrip_step $NETCMD registry export $REGPATH $DIR/conf_out.reg
137 test "x$?" = "x0" || {
138 return 1
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
144 return 1
146 rm -r $DIR
149 CONF_FILES=$SERVERCONFFILE
151 # remove old logs:
152 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
153 echo "removing old directory ${OLDDIR}"
154 rm -rf ${OLDDIR}
155 done
157 for conf_file in $CONF_FILES
159 testit "conf_roundtrip $conf_file" \
160 conf_roundtrip $conf_file \
161 || failed=`expr $failed + 1`
162 done
164 testok $0 $failed