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
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}
142
143 cp ${SCRIPTDIR}/testrc_2.in testrc_2
144
[19]145 ./samhain.build -t init -p none
[1]146
[19]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
[1]153
154 # Create a password
155
156 SHPW=`./yule -G`
157 if test x"$SHPW" = x; then
[19]158 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting"
159 return 1
[1]160 fi
161
162 # Set in client
163
[19]164 ./samhain_setpwd samhain.build new $SHPW >/dev/null
[1]165
[19]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
[1]172
[19]173 mv samhain.build.new samhain.new || return 1
174
175 rm -f ./.samhain_log*
[1]176 rm -f ./.samhain_lock
177
178 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
179
[19]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
[1]187 echo $SHCLT >> testrc_2
188
[19]189 cp ./testrc_2 ./rc.${SH_LOCALHOST}
190 mv ./.samhain_file ./file.${SH_LOCALHOST}
[1]191
[19]192 ALTHOST=`find_hostname`
193 cp ./testrc_2 "./rc.${ALTHOST}"
194 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
[1]195
196}
197
[19]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"
[1]206 fi
[19]207 #
[1]208 SH_LOCALHOST=$1; export SH_LOCALHOST
[19]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}
[1]229
Note: See TracBrowser for help on using the repository browser.