Changes in trunk/test/testrun_2.sh [30:19]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testrun_2.sh
r30 r19 1 1 #! /bin/sh 2 3 #4 # Copyright Rainer Wichmann (2006)5 #6 # License Information:7 # This program is free software; you can redistribute it and/or modify8 # it under the terms of the GNU General Public License as published by9 # the Free Software Foundation; either version 2 of the License, or10 # (at your option) any later version.11 #12 # This program is distributed in the hope that it will be useful,13 # but WITHOUT ANY WARRANTY; without even the implied warranty of14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 # GNU General Public License for more details.16 #17 # You should have received a copy of the GNU General Public License18 # along with this program; if not, write to the Free Software19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.20 #21 2 22 3 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 23 4 RCFILE="$PW_DIR/testrc_2"; export RCFILE 24 HTML="$PW_DIR/yule.html"; export HTML25 5 26 6 … … 32 12 echo; 33 13 } 34 35 rm -f test_log_valgrind 36 37 ${VALGRIND} ./yule.2 -l info -p none >/dev/null 2>>test_log_valgrind & 38 PROC_Y2=$! 39 sleep 5 40 41 [ -z "$verbose" ] || { 42 echo; 43 echo "${S}Start Server #2${E}: ./yule.2 -l info -p none &"; 44 echo; 45 } 46 47 ${VALGRIND} ./yule -l info -p none -e info --bind-address=127.0.0.1 \ 48 --server-port=49778 >/dev/null 2>>test_log_valgrind & 14 ./yule -l info -p none >/dev/null 2>&1 & 49 15 PROC_Y=$! 50 16 sleep 5 … … 56 22 } 57 23 58 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind24 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1 59 25 if test x$? = x0; then 60 26 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; … … 62 28 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 63 29 kill $PROC_Y 64 kill $PROC_Y265 30 return 1 66 31 fi 67 32 68 33 kill $PROC_Y 69 kill $PROC_Y2 70 sleep 5 71 72 # cp ${LOGFILE} triple_test 73 # cp ${LOGFILE}2 triple_test_2 74 75 egrep "START(>|\").*Yule(>|\")" ${LOGFILE}2 >/dev/null 2>&1 76 if [ $? -ne 0 ]; then 77 [ -z "$verbose" ] || log_msg_fail "Server #2 start"; 78 return 1 79 fi 80 egrep "remote_host.*Checking.*/bin" ${LOGFILE}2 >/dev/null 2>&1 81 if [ $? -ne 0 ]; then 82 [ -z "$verbose" ] || log_msg_fail "Client file check (relayed)"; 83 return 1 84 fi 85 egrep "remote_host.*EXIT.*Samhain" ${LOGFILE}2 >/dev/null 2>&1 86 if [ $? -ne 0 ]; then 87 [ -z "$verbose" ] || log_msg_fail "Client exit (relayed)"; 88 return 1 89 fi 90 egrep "EXIT.*Yule.*SIGTERM" ${LOGFILE}2 >/dev/null 2>&1 91 if [ $? -ne 0 ]; then 92 [ -z "$verbose" ] || log_msg_fail "Server #2 exit"; 93 return 1 94 fi 95 34 sleep 5 96 35 97 36 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 … … 120 59 return 1 121 60 fi 122 123 [ -z "$VALGRIND" ] || { 124 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 125 if [ $tmp -ne 0 ]; then 126 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 127 cat test_log_valgrind 128 return 1; 129 fi; 130 } 61 131 62 132 63 return 0 … … 138 69 REPLACEMENT="UseSeparateLogs=yes" 139 70 ex $RCFILE <<EOF 140 %s/$ORIGINAL/$REPLACEMENT/g141 wq71 :%s/$ORIGINAL/$REPLACEMENT/g 72 :wq 142 73 EOF 143 74 # :%s is the "ex" substitution command. … … 150 81 151 82 rm -f $LOGFILE 152 rm -f test_log_valgrind 153 154 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind & 83 84 ./yule -l info -p none >/dev/null 2>&1 & 155 85 PROC_Y=$! 156 86 sleep 5 … … 162 92 } 163 93 164 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind94 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1 165 95 if test x$? = x0; then 166 96 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; … … 182 112 CLIENTLOG="${LOGFILE}.${remhost}" 183 113 else 184 tail -n 1 ${SCRIPTDIR}/test.sh >/dev/null 2>&1 185 if [ $? -eq 0 ]; then 186 CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1` 187 else 188 CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -1` 189 fi 114 CLIENTLOG=`ls -1 ${LOGFILE}.* | tail -n 1` 190 115 fi 191 116 … … 215 140 return 1 216 141 fi 217 218 [ -z "$VALGRIND" ] || {219 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;220 if [ $tmp -ne 0 ]; then221 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";222 cat test_log_valgrind223 return 1;224 fi;225 }226 142 227 143 rm -f ${LOGFILE}.${remhost} … … 240 156 REPLACEMENT_4="SetClientTimeLimit=20" 241 157 ex $RCFILE <<EOF 242 %s/${ORIGINAL_1}/${REPLACEMENT_1}/g243 %s/${ORIGINAL_2}/${REPLACEMENT_2}/g244 %s/${ORIGINAL_3}/${REPLACEMENT_3}/g245 %s/${ORIGINAL_4}/${REPLACEMENT_4}/g246 wq158 :%s/${ORIGINAL_1}/${REPLACEMENT_1}/g 159 :%s/${ORIGINAL_2}/${REPLACEMENT_2}/g 160 :%s/${ORIGINAL_3}/${REPLACEMENT_3}/g 161 :%s/${ORIGINAL_4}/${REPLACEMENT_4}/g 162 :wq 247 163 EOF 248 164 # :%s is the "ex" substitution command. … … 255 171 256 172 rm -f $LOGFILE 257 rm -f test_log_valgrind 258 259 ${VALGRIND} ./yule -p none -e none >/dev/null 2>>test_log_valgrind & 173 174 ./yule -p none >/dev/null 2>&1 & 260 175 PROC_Y=$! 261 176 sleep 5 … … 267 182 } 268 183 269 ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind&184 ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>&1 & 270 185 if test x$? = x0; then 271 186 PROC_S=$! … … 316 231 return 1 317 232 fi 318 319 [ -z "$VALGRIND" ] || {320 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;321 if [ $tmp -ne 0 ]; then322 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";323 cat test_log_valgrind324 return 1;325 fi;326 }327 233 328 rm -f ${LOGFILE} 234 rm -f ${LOGFILE}.${remhost} 329 235 return 0 330 236 } 331 332 do_test_4 () {333 334 # don't know what is supported on the test platform, so335 # prepare for both (password and socket credential)336 337 # 'id -u' is posix338 me=`id -u`339 340 ORIGINAL_1="SetSocketAllowUid=0"341 REPLACEMENT_1="SetSocketAllowUid=$me"342 ex $RCFILE <<EOF343 %s/${ORIGINAL_1}/${REPLACEMENT_1}/g344 wq345 EOF346 347 [ -z "$verbose" ] || {348 echo;349 echo "${S}Start Server${E}: ./yule -l info -p none &";350 echo;351 }352 353 rm -f $LOGFILE354 rm -f test_log_valgrind355 356 ${VALGRIND} ./yule -l info -p none -e none \357 >/dev/null 2>>test_log_valgrind &358 PROC_Y=$!359 sleep 5360 361 [ -z "$verbose" ] || {362 echo;363 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";364 echo;365 }366 367 $MAKE yulectl >/dev/null368 if [ $? -ne 0 ]; then369 [ -z "$verbose" ] || log_msg_fail "make yulectl";370 kill $PROC_Y371 return 1372 fi373 374 375 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null376 377 if [ $? -ne 0 ]; then378 YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD379 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl380 if [ $? -ne 0 ]; then381 kill ${PROC_Y}382 [ -z "$verbose" ] || log_msg_fail "yulectl";383 return 1384 fi385 fi386 387 ./yulectl -v -c RELOAD foobar2 >test_yulectl_log388 389 if [ $? -ne 0 ]; then390 kill ${PROC_Y}391 [ -z "$verbose" ] || log_msg_fail "yulectl";392 return 1393 fi394 395 ./yulectl -v -c RELOAD foobar3 >test_log_yulectl396 397 if [ $? -ne 0 ]; then398 kill ${PROC_Y}399 [ -z "$verbose" ] || log_msg_fail "yulectl";400 return 1401 fi402 403 ./yulectl -v -c LISTALL dummy >test_log_yulectl404 405 if [ $? -ne 0 ]; then406 kill ${PROC_Y}407 [ -z "$verbose" ] || log_msg_fail "yulectl";408 return 1409 fi410 411 tmp=`cat test_log_yulectl | grep RELOAD | wc -l`412 if [ $tmp -ne 3 ]; then413 kill ${PROC_Y}414 [ -z "$verbose" ] || log_msg_fail "command confirmation";415 return 1416 fi417 418 ./yulectl -v -c CANCEL foobar3 >test_log_yulectl419 420 if [ $? -ne 0 ]; then421 kill ${PROC_Y}422 [ -z "$verbose" ] || log_msg_fail "yulectl";423 return 1424 fi425 426 ./yulectl -v -c LISTALL dummy >test_log_yulectl427 428 if [ $? -ne 0 ]; then429 kill ${PROC_Y}430 [ -z "$verbose" ] || log_msg_fail "yulectl";431 return 1432 fi433 434 tmp=`cat test_log_yulectl | grep RELOAD | wc -l`435 if [ $tmp -ne 2 ]; then436 kill ${PROC_Y}437 [ -z "$verbose" ] || log_msg_fail "command confirmation";438 return 1439 fi440 441 kill ${PROC_Y}442 sleep 2443 kill -9 ${PROC_Y} >/dev/null 2>&1444 445 [ -z "$VALGRIND" ] || {446 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;447 if [ $tmp -ne 0 ]; then448 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";449 cat test_log_valgrind450 return 1;451 fi;452 }453 454 return 0455 }456 457 do_test_5 () {458 459 [ -z "$verbose" ] || {460 echo;461 echo "${S}Start Server${E}: ./yule -l info -p none &";462 echo;463 }464 465 ( cat <<EOF466 <!-- head -->467 <html><head><title>test</title></head>468 <body>469 Current time: %T <br>470 <table>471 <!-- ehead -->472 EOF473 ) >head.html474 475 ( cat <<EOF476 <!-- foot -->477 </table>478 </body>479 <!-- efoot -->480 EOF481 ) >foot.html482 483 ( cat <<EOF484 <!-- entry -->485 <tr>486 <td>%H</td>487 <td>%S</td>488 <td>%T</td>489 </tr>490 <!-- eentry -->491 EOF492 ) >entry.html493 494 ${VALGRIND} ./yule -l info -p none -e none \495 >/dev/null 2>>test_log_valgrind &496 PROC_Y=$!497 sleep 5498 499 egrep '<!-- head -->' $HTML >/dev/null 2>&1500 if [ $? -ne 0 ]; then501 # rm -f head.html; rm -f foot.html; rm -f entry.html;502 kill $PROC_Y503 [ -z "$verbose" ] || log_msg_fail "head.html (1)";504 return 1505 fi506 507 egrep '<!-- foot -->' $HTML >/dev/null 2>&1508 if [ $? -ne 0 ]; then509 rm -f head.html; rm -f foot.html; rm -f entry.html;510 kill $PROC_Y511 [ -z "$verbose" ] || log_msg_fail "foot.html (1)";512 return 1513 fi514 515 [ -z "$verbose" ] || {516 echo;517 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";518 echo;519 }520 521 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind522 if test x$? = x0; then523 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check";524 else525 kill $PROC_Y526 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check";527 return 1528 fi529 530 kill $PROC_Y531 sleep 5532 533 # rm -f head.html; rm -f foot.html; rm -f entry.html;534 535 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1536 if [ $? -ne 0 ]; then537 [ -z "$verbose" ] || log_msg_fail "Server start";538 return 1539 fi540 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1541 if [ $? -ne 0 ]; then542 [ -z "$verbose" ] || log_msg_fail "Client connect";543 return 1544 fi545 egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1546 if [ $? -ne 0 ]; then547 [ -z "$verbose" ] || log_msg_fail "Client file check";548 return 1549 fi550 egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1551 if [ $? -ne 0 ]; then552 [ -z "$verbose" ] || log_msg_fail "Client exit";553 return 1554 fi555 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1556 if [ $? -ne 0 ]; then557 [ -z "$verbose" ] || log_msg_fail "Server exit";558 return 1559 fi560 561 egrep '<!-- head -->' $HTML >/dev/null 2>&1562 if [ $? -ne 0 ]; then563 [ -z "$verbose" ] || log_msg_fail "head.html";564 return 1565 fi566 egrep '<!-- ehead -->' $HTML >/dev/null 2>&1567 if [ $? -ne 0 ]; then568 [ -z "$verbose" ] || log_msg_fail "end head.html";569 return 1570 fi571 572 egrep '<!-- entry -->' $HTML >/dev/null 2>&1573 if [ $? -ne 0 ]; then574 [ -z "$verbose" ] || log_msg_fail "entry.html";575 return 1576 fi577 egrep '<!-- eentry -->' $HTML >/dev/null 2>&1578 if [ $? -ne 0 ]; then579 [ -z "$verbose" ] || log_msg_fail "end entry.html";580 return 1581 fi582 583 egrep '<!-- foot -->' $HTML >/dev/null 2>&1584 if [ $? -ne 0 ]; then585 [ -z "$verbose" ] || log_msg_fail "foot.html";586 return 1587 fi588 egrep '<!-- efoot -->' $HTML >/dev/null 2>&1589 if [ $? -ne 0 ]; then590 [ -z "$verbose" ] || log_msg_fail "end foot.html";591 return 1592 fi593 594 [ -z "$VALGRIND" ] || {595 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;596 if [ $tmp -ne 0 ]; then597 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";598 cat test_log_valgrind599 return 1;600 fi;601 }602 603 return 0604 }605 606 237 607 238 testrun2_internal () … … 637 268 fi 638 269 639 # save binary and build server 2270 # save binary and build server 640 271 # 641 272 cp samhain samhain.build || return 1 642 $MAKEclean >/dev/null || return 1643 644 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$ {RCFILE}2 --with-log-file=${LOGFILE}2 --with-pid-file=$PW_DIR/.samhain_lock2 --with-html-file=${HTML}2 --with-state-dir=$PW_DIR --enable-encrypt=2 --with-port=49778273 make clean >/dev/null || return 1 274 275 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-identity=rainer --enable-encrypt=2 645 276 # 646 277 if test x$? = x0; then … … 659 290 fi 660 291 661 # save binary and build server662 #663 cp yule yule.2 || return 1664 $MAKE clean >/dev/null || return 1665 666 ${TOP_SRCDIR}/configure --quiet $TRUST --enable-debug --enable-network=server --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-html-file=$HTML --with-state-dir=$PW_DIR --enable-encrypt=2667 #668 if test x$? = x0; then669 [ -z "$verbose" ] || log_msg_ok "configure...";670 $MAKE > /dev/null 2>>test_log671 if test x$? = x0; then672 [ -z "$verbose" ] || log_msg_ok "make...";673 else674 [ -z "$quiet" ] && log_msg_fail "make...";675 return 1676 fi677 678 else679 [ -z "$quiet" ] && log_msg_fail "configure...";680 return 1681 fi682 683 292 684 293 ##################################################################### … … 721 330 mv samhain.build.new samhain.new || return 1 722 331 723 # Set in server 724 725 ./samhain_setpwd yule new $SHPW >/dev/null 726 727 if test x$? = x0; then 728 [ -z "$verbose" ] || log_msg_ok "./samhain_setpwd yule new $SHPW"; 729 else 730 [ -z "$quiet" ] && log_msg_fail "./samhain_setpwd yule new $SHPW"; 731 return 1 732 fi 733 734 mv yule.new yule || return 1 735 736 # 737 738 rm -f ./.samhain_log* 739 rm -f ./.samhain_lock* 740 741 SHCLT=`./yule -P $SHPW` 332 rm -f ./.samhain_log.* 333 rm -f ./.samhain_lock 334 335 SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%` 742 336 743 337 if test x$? = x0; then … … 748 342 fi 749 343 750 SHCLT1=`echo "${SHCLT}" | sed s%HOSTNAME%${SH_LOCALHOST}%` 751 AHOST=`find_hostname` 752 SHCLT2=`echo "${SHCLT}" | sed s%HOSTNAME%${AHOST}%` 753 754 755 echo $SHCLT1 >> testrc_2 756 echo $SHCLT2 >> testrc_2 757 cp testrc_2 testrc_22 344 echo $SHCLT >> testrc_2 758 345 759 346 do_test_1 … … 766 353 do_test_2 767 354 if [ $? -eq 0 ]; then 768 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, sep arate logfiles";769 else 770 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, sep arate logfiles";355 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, seperate logfiles"; 356 else 357 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, seperate logfiles"; 771 358 fi 772 359 … … 778 365 fi 779 366 780 do_test_4781 if [ $? -eq 0 ]; then782 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket";783 else784 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";785 fi786 787 do_test_5788 if [ $? -eq 0 ]; then789 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file";790 else791 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";792 fi793 794 367 return $? 795 368 } 796 369 797 MAXTEST= 5; export MAXTEST370 MAXTEST=3; export MAXTEST 798 371 799 372 testrun2 ()
Note:
See TracChangeset
for help on using the changeset viewer.