s3:test: move the registry roundtrip test to a test script of its own
[Samba.git] / source3 / script / tests / test_net_registry_roundtrip.sh
blob7f13bc2f74336a1d0bd6bafb3b8a97058fb5a16d
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/modules dir/;&/g
27 s/logging/;&/g
28 s/status/;&/g
29 s/logdir/;&/g
30 s/read prediction/;&/g
31 s/mkprofile/;&/g
32 s/valid chars/;&/g
33 s/timesync/;&/g
34 s/sambaconf/;&/g
35 s/logtype/;&/g
36 s/servername/;&/g
39 REGPATH="HKLM\Software\Samba"
41 conf_roundtrip_step() {
42 echo $* >>$LOG
43 $@ 2>>$LOG
44 # echo -n .
47 conf_roundtrip()
49 local DIR=$(mktemp -d --tmpdir=$PREFIX conf_roundtrip_XXXX)
50 local LOG=$DIR/log
52 echo conf_roundtrip $1 > $LOG
54 sed -e "$SED_INVALID_PARAMS" $1 >$DIR/conf_in
56 conf_roundtrip_step $NET conf drop
57 test -z "$($NET conf list)" 2>>$LOG
58 if [ "$?" = "1" ]; then
59 echo "ERROR: conf drop failed" | tee -a $LOG
60 return 1
63 conf_roundtrip_step $NET conf import $DIR/conf_in
64 conf_roundtrip_step $NET conf list > $DIR/conf_exp
66 grep "\[global\]" $DIR/conf_exp >/dev/null 2>>$LOG
67 if [ "$?" = "1" ]; then
68 echo "ERROR: conf import => conf export failed" | tee -a $LOG
69 return 1
72 conf_roundtrip_step $NET -d10 registry export $REGPATH $DIR/conf_exp.reg
74 conf_roundtrip_step $NET conf drop
75 test -z "$($NET conf list)" 2>>$LOG
76 if [ "$?" = "1" ]; then
77 echo "ERROR: conf drop failed" | tee -a $LOG
78 return 1
81 conf_roundtrip_step $NET registry import $DIR/conf_exp.reg
83 conf_roundtrip_step $NET conf list >$DIR/conf_out
84 diff -q $DIR/conf_out $DIR/conf_exp >> $LOG
85 if [ "$?" = "1" ]; then
86 echo "ERROR: registry import => conf export failed" | tee -a $LOG
87 return 1
90 conf_roundtrip_step $NET registry export $REGPATH $DIR/conf_out.reg
91 diff -q $DIR/conf_out.reg $DIR/conf_exp.reg >>$LOG
92 if [ "$?" = "1" ]; then
93 echo "Error: registry import => registry export failed" | tee -a $LOG
94 return 1
96 rm -r $DIR
99 CONF_FILES=${CONF_FILES:-$(find $SRCDIR/ -name '*.conf' | xargs grep -l "\[global\]")}
101 for conf_file in $CONF_FILES
103 testit "conf_roundtrip $conf_file" \
104 conf_roundtrip $conf_file \
105 || failed=`expr $failed + 1`
106 done
108 testok $0 $failed