Changeset 19 for trunk/test/testrun_2a.sh
- Timestamp:
- Feb 12, 2006, 10:49:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testrun_2a.sh
r1 r19 1 1 #! /bin/sh 2 2 3 4 # The following two are the ANSI sequences for start and end embolden 5 case $TERM in 6 vt*|ansi*|con*|xterm*|linux*|screen*) 7 S=[1m 8 E=[m 9 ;; 10 *) 11 S= 12 E= 13 ;; 14 esac 15 16 PW_DIR=`pwd` 17 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 23 24 echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER __${E}"; echo; 25 echo Working directory: $PW_DIR 26 27 MAKE=`which gmake` 28 if test "x$?" = x1 ; then 29 MAKE="make -s" 30 else 31 MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"` 32 if test "x$MAKE" = x; then 33 MAKE="make -s" 34 elif test "x$MAKE" = xno; then 35 MAKE="make -s" 36 else 37 if test "x$MAKE" = "xwhich:"; then 38 MAKE="make -s" 39 else 40 MAKE="gmake -s" 41 gmake -v >/dev/null 2>&1 || MAKE="make -s" 42 fi 43 fi 44 fi 45 46 echo MAKE is $MAKE 47 echo 48 49 50 51 testrun2a () 3 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 4 RCFILE="$PW_DIR/testrc_2"; export RCFILE 5 6 SERVER_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 8 CLIENT_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 10 do_test_1_a () { 11 12 [ -z "$verbose" ] || { 13 echo; 14 echo "${S}Start Server${E}: ./yule -l info -p none &"; 15 echo; 16 } 17 ./yule -l info -p none >/dev/null 2>&1 & 18 PROC_Y=$! 19 sleep 5 20 21 [ -z "$verbose" ] || { 22 echo; 23 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 24 echo; 25 } 26 27 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1 28 if test x$? = x0; then 29 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; 30 else 31 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 32 kill $PROC_Y 33 return 1 34 fi 35 36 kill $PROC_Y 37 sleep 5 38 39 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 40 if [ $? -ne 0 ]; then 41 [ -z "$verbose" ] || log_msg_fail "Server start"; 42 return 1 43 fi 44 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1 45 if [ $? -ne 0 ]; then 46 [ -z "$verbose" ] || log_msg_fail "Client connect"; 47 return 1 48 fi 49 egrep "Checking.*/etc" $LOGFILE >/dev/null 2>&1 50 if [ $? -ne 0 ]; then 51 [ -z "$verbose" ] || log_msg_fail "Client file check"; 52 return 1 53 fi 54 egrep "EXIT.*Samhain" $LOGFILE >/dev/null 2>&1 55 if [ $? -ne 0 ]; then 56 [ -z "$verbose" ] || log_msg_fail "Client exit"; 57 return 1 58 fi 59 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1 60 if [ $? -ne 0 ]; then 61 [ -z "$verbose" ] || log_msg_fail "Server exit"; 62 return 1 63 fi 64 65 66 return 0 67 } 68 69 testrun2a_internal () 52 70 { 53 # 54 # test standalone compilation 55 # 56 echo "${S}Building client and server${E}"; echo; 71 [ -z "$verbose" ] || { 72 echo; 73 echo Working directory: $PW_DIR; echo MAKE is $MAKE; 74 echo; 75 } 76 # 77 # 78 [ -z "$verbose" ] || { echo; echo "${S}Building client and server${E}"; echo; } 57 79 # 58 80 if test -r "Makefile"; then … … 60 82 fi 61 83 # 62 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=client --enable-srp --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=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 63 # 64 # --disable-encrypt 65 # 66 if test x$? = x0; then 67 echo "configure completed, exit status 0"; echo; 68 $MAKE > /dev/null 84 ${TOP_SRCDIR}/configure ${CLIENT_BUILDOPTS} 85 # 86 if test x$? = x0; then 87 [ -z "$verbose" ] || log_msg_ok "configure..."; 88 $MAKE > /dev/null 2>>test_log 69 89 if test x$? = x0; then 70 echo "$MAKE completed, exit status $?"; echo;90 [ -z "$verbose" ] || log_msg_ok "make..."; 71 91 else 72 echo "${S}ERROR:${E} make failed, exit status $?"; echo;73 exit92 [ -z "$quiet" ] && log_msg_fail "make..."; 93 return 1 74 94 fi 75 95 76 96 else 77 echo "${S}ERROR:${E} configure failed, exit status $?"; echo;78 exit97 [ -z "$quiet" ] && log_msg_fail "configure..."; 98 return 1 79 99 fi 80 100 81 101 # save binary and build server 82 102 # 83 cp samhain samhain.build 84 make clean 85 86 # 87 ${TOP_SRCDIR}/configure --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 88 # --enable-identity=rainer 89 # --with-libwrap 90 # 91 if test x$? = x0; then 92 echo "configure completed, exit status 0"; echo; 93 $MAKE > /dev/null 103 cp samhain samhain.build || return 1 104 make clean >/dev/null || return 1 105 106 ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS} 107 # 108 if test x$? = x0; then 109 [ -z "$verbose" ] || log_msg_ok "configure..."; 110 $MAKE > /dev/null 2>>test_log 94 111 if test x$? = x0; then 95 echo "$MAKE completed, exit status $?"; echo;112 [ -z "$verbose" ] || log_msg_ok "make..."; 96 113 else 97 echo "${S}ERROR:${E} make failed, exit status $?"; echo;98 exit114 [ -z "$quiet" ] && log_msg_fail "make..."; 115 return 1 99 116 fi 100 117 101 118 else 102 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 103 exit 104 fi 105 106 echo "${S}Initialize database${E}"; echo; 107 119 [ -z "$quiet" ] && log_msg_fail "configure..."; 120 return 1 121 fi 122 123 124 ##################################################################### 125 # 126 # 108 127 rm -f ./.samhain_file 109 128 rm -f ./.samhain_log … … 114 133 cp ${SCRIPTDIR}/testrc_2.in testrc_2 115 134 116 echo "./samhain.build -t init" 117 ./samhain.build -t init 118 119 SHINI=$? 135 ./samhain.build -t init -p none 136 137 if test x$? = x0; then 138 [ -z "$verbose" ] || log_msg_ok "init..."; 139 else 140 [ -z "$quiet" ] && log_msg_fail "init..."; 141 return 1 142 fi 120 143 121 144 # Create a password … … 123 146 SHPW=`./yule -G` 124 147 if test x"$SHPW" = x; then 125 echo"password not generated -- aborting"126 exit1148 [ -z "$quiet" ] && log_msg_fail "password not generated -- aborting" 149 return 1 127 150 fi 128 151 129 152 # Set in client 130 153 131 echo "./samhain_setpwd samhain.build new $SHPW" 132 ./samhain_setpwd samhain.build new $SHPW 133 134 mv samhain.build.new samhain.new 135 136 rm -f ./.samhain_log 154 ./samhain_setpwd samhain.build new $SHPW >/dev/null 155 156 if test x$? = x0; then 157 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd samhain.build new $SHPW"; 158 else 159 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd samhain.build new $SHPW"; 160 return 1 161 fi 162 163 mv samhain.build.new samhain.new || return 1 164 165 rm -f ./.samhain_log* 137 166 rm -f ./.samhain_lock 167 168 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 169 170 if test x$? = x0; then 171 [ -z "$verbose" ] || log_msg_ok "yule -P $SHPW"; 172 else 173 [ -z "$quiet" ] && log_msg_fail "yule -P $SHPW"; 174 return 1 175 fi 176 177 echo $SHCLT >> testrc_2 138 178 139 179 cp ./testrc_2 ./rc.${SH_LOCALHOST} 140 180 mv ./.samhain_file ./file.${SH_LOCALHOST} 141 181 142 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 143 144 echo $SHCLT >> testrc_2 145 146 if test x$SHINI = x0; then 147 echo; echo "${S}Start Server${E}: ./yule &"; echo; 148 ./yule -q & 149 PROC_Y=$! 150 sleep 5 151 152 echo; echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 153 154 ./samhain.new -t check -p none -l none -e info 155 if test x$? = x0; then 156 echo "${S}check completed${E}" 157 else 158 echo "${S}ERROR:${E} -- check -- failed, exit status $?" 159 echo 160 kill $PROC_Y 161 exit 162 fi 163 164 kill $PROC_Y 165 sleep 5 166 else 167 echo "${S}ERROR:${E} -- init -- failed, exit status $SHINI"; 168 echo; 169 exit 170 fi 171 182 ALTHOST=`find_hostname` 183 cp ./testrc_2 "./rc.${ALTHOST}" 184 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null 185 172 186 } 173 187 174 if test x$1 = x; then 175 echo 176 echo "Please provide the local hostname as argument." 177 echo 178 exit 8 188 MAXTEST=1; export MAXTEST 189 190 testrun2a () 191 { 192 log_start "RUN FULL CLIENT/SERVER"; 193 # 194 if [ x"$1" = x ]; then 195 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 179 196 fi 180 197 # 181 198 SH_LOCALHOST=$1; export SH_LOCALHOST 182 183 testrun2a 184 185 186 echo; echo "${S}__ END TEST RUN CLIENT/SERVER __${E}"; echo; 187 188 exit 189 199 # 200 testrun2a_internal 201 # 202 do_test_1_a 203 if [ $? -eq 0 ]; then 204 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client download+logging"; 205 else 206 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging"; 207 fi 208 # 209 if [ -n "$cleanup" ]; then 210 rm -f ./rc.${SH_LOCALHOST} 211 rm -f ./file.${SH_LOCALHOST} 212 ALTHOST=`find_hostname` 213 rm -f "./file.${ALTHOST}" 214 rm -f "./rc.${ALTHOST}" 215 fi 216 # 217 log_end "RUN FULL CLIENT/SERVER" 218 } 219
Note:
See TracChangeset
for help on using the changeset viewer.