source: trunk/test/testrun_2a.sh@ 22

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

Minor code revisions.

File size: 5.7 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
143 cp ${SCRIPTDIR}/testrc_2.in testrc_2
144
145 ./samhain.build -t init -p none
146
147 if test x$? = x0; then
148 [ -z "$verbose" ] || log_msg_ok "init...";
149 else
150 [ -z "$quiet" ] && log_msg_fail "init...";
151 return 1
152 fi
153
154 # Create a password
155
156 SHPW=`./yule -G`
157 if test x"$SHPW" = x; then
158 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
159 return 1
160 fi
161
162 # Set in client
163
164 ./samhain_setpwd samhain.build new $SHPW >/dev/null
165
166 if test x$? = x0; then
167 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW";
168 else
169 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW";
170 return 1
171 fi
172
173 mv samhain.build.new samhain.new || return 1
174
175 rm -f ./.samhain_log*
176 rm -f ./.samhain_lock
177
178 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
179
180 if test x$? = x0; then
181 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW";
182 else
183 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW";
184 return 1
185 fi
186
187 echo $SHCLT >> testrc_2
188
189 cp ./testrc_2 ./rc.${SH_LOCALHOST}
190 mv ./.samhain_file ./file.${SH_LOCALHOST}
191
192 ALTHOST=`find_hostname`
193 cp ./testrc_2 "./rc.${ALTHOST}"
194 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
195
196}
197
198MAXTEST=1; export MAXTEST
199
200testrun2a ()
201{
202 log_start "RUN FULL CLIENT/SERVER";
203 #
204 if [ x"$1" = x ]; then
205 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
206 fi
207 #
208 SH_LOCALHOST=$1; export SH_LOCALHOST
209 #
210 testrun2a_internal
211 #
212 do_test_1_a
213 if [ $? -eq 0 ]; then
214 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging";
215 else
216 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
217 fi
218 #
219 if [ -n "$cleanup" ]; then
220 rm -f ./rc.${SH_LOCALHOST}
221 rm -f ./file.${SH_LOCALHOST}
222 ALTHOST=`find_hostname`
223 rm -f "./file.${ALTHOST}"
224 rm -f "./rc.${ALTHOST}"
225 fi
226 #
227 log_end "RUN FULL CLIENT/SERVER"
228}
229
Note: See TracBrowser for help on using the repository browser.