source: trunk/test/testrun_2a.sh@ 25

Last change on this file since 25 was 25, checked in by rainer, 19 years ago

More tests; fix for update+schedule issue.

File size: 7.2 KB
RevLine 
[1]1#! /bin/sh
2
[19]3LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
4RCFILE="$PW_DIR/testrc_2"; export RCFILE
[1]5
[19]6SERVER_BUILDOPTS="--quiet $TRUST --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export SERVER_BUILDOPTS
[1]7
[19]8CLIENT_BUILDOPTS="--quiet $TRUST --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
[1]9
[19]10do_test_1_a () {
[1]11
[19]12 [ -z "$verbose" ] || {
13 echo;
14 echo "${S}Start Server${E}: ./yule -l info -p none &";
15 echo;
16 }
[22]17 rm -f test_log_valgrind
18
19 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
[19]20 PROC_Y=$!
21 sleep 5
[1]22
[19]23 [ -z "$verbose" ] || {
24 echo;
25 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
26 echo;
27 }
28
[22]29 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
[19]30 if test x$? = x0; then
31 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
[1]32 else
[19]33 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
34 kill $PROC_Y
35 return 1
[1]36 fi
37
[19]38 kill $PROC_Y
39 sleep 5
[1]40
[19]41 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
42 if [ $? -ne 0 ]; then
43 [ -z "$verbose" ] || log_msg_fail "Server start";
44 return 1
45 fi
46 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
47 if [ $? -ne 0 ]; then
48 [ -z "$verbose" ] || log_msg_fail "Client connect";
49 return 1
50 fi
51 egrep "Checking.*/etc" $LOGFILE >/dev/null 2>&1
52 if [ $? -ne 0 ]; then
53 [ -z "$verbose" ] || log_msg_fail "Client file check";
54 return 1
55 fi
56 egrep "EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
57 if [ $? -ne 0 ]; then
58 [ -z "$verbose" ] || log_msg_fail "Client exit";
59 return 1
60 fi
61 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
62 if [ $? -ne 0 ]; then
63 [ -z "$verbose" ] || log_msg_fail "Server exit";
64 return 1
65 fi
66
[22]67 [ -z "$VALGRIND" ] || {
68 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
69 if [ $tmp -ne 0 ]; then
70 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
71 cat test_log_valgrind
72 return 1;
73 fi;
74 }
[1]75
[19]76 return 0
77}
[1]78
[19]79testrun2a_internal ()
[1]80{
[19]81 [ -z "$verbose" ] || {
82 echo;
83 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
84 echo;
85 }
[1]86 #
87 #
[19]88 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
[1]89 #
90 if test -r "Makefile"; then
91 $MAKE distclean
92 fi
93 #
[19]94 ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
[1]95 #
96 if test x$? = x0; then
[19]97 [ -z "$verbose" ] || log_msg_ok "configure...";
98 $MAKE > /dev/null 2>>test_log
[1]99 if test x$? = x0; then
[19]100 [ -z "$verbose" ] || log_msg_ok "make...";
[1]101 else
[19]102 [ -z "$quiet" ] && log_msg_fail "make...";
103 return 1
[1]104 fi
105
106 else
[19]107 [ -z "$quiet" ] && log_msg_fail "configure...";
108 return 1
[1]109 fi
110
111 # save binary and build server
112 #
[19]113 cp samhain samhain.build || return 1
114 make clean >/dev/null || return 1
[1]115
[19]116 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
[1]117 #
118 if test x$? = x0; then
[19]119 [ -z "$verbose" ] || log_msg_ok "configure...";
120 $MAKE > /dev/null 2>>test_log
[1]121 if test x$? = x0; then
[19]122 [ -z "$verbose" ] || log_msg_ok "make...";
[1]123 else
[19]124 [ -z "$quiet" ] && log_msg_fail "make...";
125 return 1
[1]126 fi
127
128 else
[19]129 [ -z "$quiet" ] && log_msg_fail "configure...";
130 return 1
[1]131 fi
132
133
[19]134 #####################################################################
135 #
136 #
[1]137 rm -f ./.samhain_file
138 rm -f ./.samhain_log
139 rm -f ./.samhain_lock
140 rm -f ./rc.${SH_LOCALHOST}
141 rm -f ./file.${SH_LOCALHOST}
[25]142 rm -f "./rc.${ALTHOST}"
143 rm -f "./file.${ALTHOST}"
[1]144
145 cp ${SCRIPTDIR}/testrc_2.in testrc_2
146
[19]147 ./samhain.build -t init -p none
[1]148
[19]149 if test x$? = x0; then
150 [ -z "$verbose" ] || log_msg_ok "init...";
151 else
152 [ -z "$quiet" ] && log_msg_fail "init...";
153 return 1
154 fi
[1]155
156 # Create a password
157
158 SHPW=`./yule -G`
159 if test x"$SHPW" = x; then
[19]160 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
161 return 1
[1]162 fi
163
164 # Set in client
165
[19]166 ./samhain_setpwd samhain.build new $SHPW >/dev/null
[1]167
[19]168 if test x$? = x0; then
169 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
170 else
171 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
172 return 1
173 fi
[1]174
[19]175 mv samhain.build.new samhain.new || return 1
176
177 rm -f ./.samhain_log*
[1]178 rm -f ./.samhain_lock
179
180 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
181
[19]182 if test x$? = x0; then
183 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
184 else
185 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
186 return 1
187 fi
188
[1]189 echo $SHCLT >> testrc_2
190
[19]191 cp ./testrc_2 ./rc.${SH_LOCALHOST}
192 mv ./.samhain_file ./file.${SH_LOCALHOST}
[1]193
[19]194 ALTHOST=`find_hostname`
195 cp ./testrc_2 "./rc.${ALTHOST}"
196 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
[1]197
198}
199
[25]200MAXTEST=5; export MAXTEST
[19]201
202testrun2a ()
203{
204 log_start "RUN FULL CLIENT/SERVER";
205 #
206 if [ x"$1" = x ]; then
207 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
[1]208 fi
[19]209 #
[1]210 SH_LOCALHOST=$1; export SH_LOCALHOST
[19]211 #
212 testrun2a_internal
213 do_test_1_a
214 if [ $? -eq 0 ]; then
215 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
216 else
217 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
218 fi
219 #
[25]220 SERVER_BUILDOPTS_ORIG="${SERVER_BUILDOPTS}"
221 CLIENT_BUILDOPTS_ORIG="${CLIENT_BUILDOPTS}"
222 #
223 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-srp"
224 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-srp"
225 #
226 testrun2a_internal
227 do_test_1_a
228 if [ $? -eq 0 ]; then
229 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "SRP disabled";
230 else
231 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "SRP disabled";
232 fi
233 #
234 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-encrypt"
235 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-encrypt"
236 #
237 testrun2a_internal
238 do_test_1_a
239 if [ $? -eq 0 ]; then
240 [ -z "$quiet" ] && log_ok 3 ${MAXTEST} "Encryption disabled";
241 else
242 [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Encryption disabled";
243 fi
244 #
245 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --enable-encrypt=1"
246 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
247 #
248 testrun2a_internal
249 do_test_1_a
250 if [ $? -eq 0 ]; then
251 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Encryption (v1)";
252 else
253 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)";
254 fi
255 #
256 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"
257 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
258 #
259 testrun2a_internal
260 do_test_1_a
261 if [ $? -eq 0 ]; then
262 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Encryption backward compat";
263 else
264 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat";
265 fi
266 #
[19]267 if [ -n "$cleanup" ]; then
268 rm -f ./rc.${SH_LOCALHOST}
269 rm -f ./file.${SH_LOCALHOST}
270 ALTHOST=`find_hostname`
271 rm -f "./file.${ALTHOST}"
272 rm -f "./rc.${ALTHOST}"
273 fi
274 #
275 log_end "RUN FULL CLIENT/SERVER"
276}
[1]277
Note: See TracBrowser for help on using the repository browser.