source: trunk/test/testrun_2a.sh@ 26

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

More tests; fix for update+schedule issue.

File size: 7.2 KB
Line 
1#! /bin/sh
2
3LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
4RCFILE="$PW_DIR/testrc_2"; export RCFILE
5
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
7
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
9
10do_test_1_a () {
11
12 [ -z "$verbose" ] || {
13 echo;
14 echo "${S}Start Server${E}: ./yule -l info -p none &";
15 echo;
16 }
17 rm -f test_log_valgrind
18
19 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
20 PROC_Y=$!
21 sleep 5
22
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
29 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
30 if test x$? = x0; then
31 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";
32 else
33 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";
34 kill $PROC_Y
35 return 1
36 fi
37
38 kill $PROC_Y
39 sleep 5
40
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
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 }
75
76 return 0
77}
78
79testrun2a_internal ()
80{
81 [ -z "$verbose" ] || {
82 echo;
83 echo Working directory: $PW_DIR; echo MAKE is $MAKE;
84 echo;
85 }
86 #
87 #
88 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; }
89 #
90 if test -r "Makefile"; then
91 $MAKE distclean
92 fi
93 #
94 ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS}
95 #
96 if test x$? = x0; then
97 [ -z "$verbose" ] || log_msg_ok "configure...";
98 $MAKE > /dev/null 2>>test_log
99 if test x$? = x0; then
100 [ -z "$verbose" ] || log_msg_ok "make...";
101 else
102 [ -z "$quiet" ] && log_msg_fail "make...";
103 return 1
104 fi
105
106 else
107 [ -z "$quiet" ] && log_msg_fail "configure...";
108 return 1
109 fi
110
111 # save binary and build server
112 #
113 cp samhain samhain.build || return 1
114 make clean >/dev/null || return 1
115
116 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
117 #
118 if test x$? = x0; then
119 [ -z "$verbose" ] || log_msg_ok "configure...";
120 $MAKE > /dev/null 2>>test_log
121 if test x$? = x0; then
122 [ -z "$verbose" ] || log_msg_ok "make...";
123 else
124 [ -z "$quiet" ] && log_msg_fail "make...";
125 return 1
126 fi
127
128 else
129 [ -z "$quiet" ] && log_msg_fail "configure...";
130 return 1
131 fi
132
133
134 #####################################################################
135 #
136 #
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}
142 rm -f "./rc.${ALTHOST}"
143 rm -f "./file.${ALTHOST}"
144
145 cp ${SCRIPTDIR}/testrc_2.in testrc_2
146
147 ./samhain.build -t init -p none
148
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
155
156 # Create a password
157
158 SHPW=`./yule -G`
159 if test x"$SHPW" = x; then
160 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
161 return 1
162 fi
163
164 # Set in client
165
166 ./samhain_setpwd samhain.build new $SHPW >/dev/null
167
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
174
175 mv samhain.build.new samhain.new || return 1
176
177 rm -f ./.samhain_log*
178 rm -f ./.samhain_lock
179
180 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
181
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
189 echo $SHCLT >> testrc_2
190
191 cp ./testrc_2 ./rc.${SH_LOCALHOST}
192 mv ./.samhain_file ./file.${SH_LOCALHOST}
193
194 ALTHOST=`find_hostname`
195 cp ./testrc_2 "./rc.${ALTHOST}"
196 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
197
198}
199
200MAXTEST=5; export MAXTEST
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"
208 fi
209 #
210 SH_LOCALHOST=$1; export SH_LOCALHOST
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 #
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 #
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}
277
Note: See TracBrowser for help on using the repository browser.