Changeset 19 for trunk/test/testrun_2c.sh
- Timestamp:
- Feb 12, 2006, 10:49:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testrun_2c.sh
r1 r19 1 1 #! /bin/sh 2 2 3 SERVER_BUILDOPTS="--quiet $TRUST --enable-xml-log --enable-debug --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 --with-database=mysql"; export SERVER_BUILDOPTS 3 4 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 5 CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS 15 6 16 PW_DIR=`pwd` 7 check_mysql_log () { 8 DATE="$1" 17 9 18 if test x$UID != x; then 19 TRUST="--with-trusted=0,2,$UID" 20 else 21 TRUST="--with-trusted=0,2" 22 fi 10 rm -f test_log_db 11 echo "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '"${DATE}"';" | mysql --password=samhain -u samhain samhain >test_log_db 12 # 13 egrep "START.*Yule" test_log_db >/dev/null 2>&1 14 if [ $? -ne 0 ]; then 15 [ -z "$verbose" ] || log_msg_fail "Server start"; 16 return 1 17 fi 18 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1 19 if [ $? -ne 0 ]; then 20 [ -z "$verbose" ] || log_msg_fail "Client connect"; 21 return 1 22 fi 23 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1 24 if [ $? -ne 0 ]; then 25 [ -z "$verbose" ] || log_msg_fail "Client file check"; 26 return 1 27 fi 28 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1 29 if [ $? -ne 0 ]; then 30 [ -z "$verbose" ] || log_msg_fail "Client exit"; 31 return 1 32 fi 33 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1 34 if [ $? -ne 0 ]; then 35 [ -z "$verbose" ] || log_msg_fail "Server exit"; 36 return 1 37 fi 38 return 0 39 } 23 40 24 echo; echo "${S}__ STARTING TEST RUN CLIENT/SERVER W/MYSQL __${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 41 MAXTEST=1; export MAXTEST 49 42 50 43 testrun2c () 51 44 { 52 # 53 # test standalone compilation 54 # 55 echo "${S}Building client and server${E}"; echo; 56 # 57 if test -r "Makefile"; then 58 $MAKE distclean 45 log_start "RUN FULL CLIENT/SERVER W/MYSQL" 46 # 47 if [ -z "$doall" ]; then 48 log_skip 1 $MAXTEST 'Client/server w/mysql (or use --really-all)' 49 return 0 50 fi 51 if [ x"$1" = x ]; then 52 [ -z "$quiet" ] && log_msg_fail "Missing hostname" 53 fi 54 MYSQL=`find_path mysql` 55 if [ -z "$MYSQL" ]; then 56 log_skip 1 $MAXTEST "mysql not found"; 57 return 1 58 else 59 TEST=`echo "DESCRIBE log;" | mysql --password=samhain -u samhain samhain 2>/dev/null` 60 if [ $? -ne 0 -o -z "$TEST" ]; then 61 log_skip 1 $MAXTEST "mysql not default setup" 62 return 1 59 63 fi 60 # 61 # 62 # ${TOP_SRCDIR}/configure --quiet $TRUST --enable-login-watch --enable-xml-log --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 ${TOP_SRCDIR}/configure --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-timeserver=localhost --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock 65 # 66 # 67 if test x$? = x0; then 68 echo "configure completed, exit status 0"; echo; 69 $MAKE > /dev/null 70 if test x$? = x0; then 71 echo "$MAKE completed, exit status $?"; echo; 72 else 73 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 74 exit 75 fi 76 64 fi 65 # 66 SH_LOCALHOST=$1; export SH_LOCALHOST 67 # 68 DATE=`date '+%Y-%m-%d %T'` 69 # 70 testrun2a_internal 71 # 72 ORIGINAL="DatabaseSeverity=none" 73 REPLACEMENT="DatabaseSeverity=info" 74 ex $RCFILE <<EOF 75 :%s/$ORIGINAL/$REPLACEMENT/g 76 :wq 77 EOF 78 # 79 do_test_1_a 80 if [ $? -ne 0 ]; then 81 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql"; 82 else 83 # 84 check_mysql_log "${DATE}" 85 if [ $? -ne 0 ]; then 86 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/mysql"; 77 87 else 78 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 79 exit 88 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/mysql"; 80 89 fi 81 82 # save binary and build server 83 # 84 cp samhain samhain.build 85 make clean 86 87 # 88 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-xml-log --enable-debug --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 --with-database=mysql 89 90 # --enable-login-watch --enable-mounts-check --enable-userfiles --enable-identity=yule --enable-suidcheck --with-gpg=/usr/local/bin/gpg --with-fp="EF6C EF54 701A 0AFD B86A F4C3 1AAD 26C8 0F57 1F6C" 91 92 # 93 # --with-database=mysql --with-libs=-L/usr/local/mysql/lib 94 # --with-database=postgresql 95 # 96 if test x$? = x0; then 97 echo "configure completed, exit status 0"; echo; 98 $MAKE > /dev/null 99 if test x$? = x0; then 100 echo "$MAKE completed, exit status $?"; echo; 101 else 102 echo "${S}ERROR:${E} make failed, exit status $?"; echo; 103 exit 104 fi 105 106 else 107 echo "${S}ERROR:${E} configure failed, exit status $?"; echo; 108 exit 109 fi 110 echo "${S}Initialize database${E}"; echo; 111 112 rm -f ./.samhain_file 113 rm -f ./.samhain_log 114 rm -f ./.samhain_lock 90 fi 91 # 92 if [ -n "$cleanup" ]; then 115 93 rm -f ./rc.${SH_LOCALHOST} 116 94 rm -f ./file.${SH_LOCALHOST} 117 118 cp ${SCRIPTDIR}/testrc_2.in testrc_2 119 120 # Create a password 121 SHPW=`./yule -G` 122 if test x"$SHPW" = x; then 123 echo "password not generated -- aborting" 124 exit 1 125 fi 126 127 # Set in client 128 echo "./samhain_setpwd samhain.build new $SHPW" 129 ./samhain_setpwd samhain.build new $SHPW 130 mv samhain.build.new samhain.new 131 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 132 echo $SHCLT >> testrc_2 133 134 echo "./samhain.new -t init" 135 ./samhain.new -t init 136 137 SHINI=$? 138 139 rm -f ./.samhain_log 140 rm -f ./.samhain_lock 141 142 cp ./testrc_2 ./rc.${SH_LOCALHOST} 143 mv ./.samhain_file ./file.${SH_LOCALHOST} 144 145 if test x$SHINI = x0; then 146 147 echo; echo "${S}Start Server${E}: ./yule &"; echo; 148 ./yule & 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 95 ALTHOST=`find_hostname` 96 rm -f "./file.${ALTHOST}" 97 rm -f "./rc.${ALTHOST}" 98 fi 99 # 100 log_end "RUN FULL CLIENT/SERVER W/MYSQL" 172 101 } 173 102 174 if test x$1 = x; then175 echo176 echo "Please provide the local hostname as argument."177 echo178 exit 8179 fi180 181 SH_LOCALHOST=$1; export SH_LOCALHOST182 183 testrun2c184 185 186 echo; echo "${S}__ END TEST RUN CLIENT/SERVER W/MYSQL __${E}"; echo;187 188 exit189
Note:
See TracChangeset
for help on using the changeset viewer.