Changeset 22 for trunk/test/testrun_2.sh
- Timestamp:
- Feb 23, 2006, 12:03:58 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testrun_2.sh
r19 r22 3 3 LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE 4 4 RCFILE="$PW_DIR/testrc_2"; export RCFILE 5 HTML="$PW_DIR/yule.html"; export HTML 5 6 6 7 … … 12 13 echo; 13 14 } 14 ./yule -l info -p none >/dev/null 2>&1 & 15 16 rm -f test_log_valgrind 17 18 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind & 15 19 PROC_Y=$! 16 20 sleep 5 … … 22 26 } 23 27 24 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&128 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind 25 29 if test x$? = x0; then 26 30 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; … … 59 63 return 1 60 64 fi 61 65 66 [ -z "$VALGRIND" ] || { 67 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 68 if [ $tmp -ne 0 ]; then 69 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 70 cat test_log_valgrind 71 return 1; 72 fi; 73 } 62 74 63 75 return 0 … … 81 93 82 94 rm -f $LOGFILE 83 84 ./yule -l info -p none >/dev/null 2>&1 & 95 rm -f test_log_valgrind 96 97 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind & 85 98 PROC_Y=$! 86 99 sleep 5 … … 92 105 } 93 106 94 ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1107 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind 95 108 if test x$? = x0; then 96 109 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; … … 112 125 CLIENTLOG="${LOGFILE}.${remhost}" 113 126 else 114 CLIENTLOG=`ls -1 ${LOGFILE}.* | tail -n 1`127 CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1` 115 128 fi 116 129 … … 140 153 return 1 141 154 fi 155 156 [ -z "$VALGRIND" ] || { 157 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 158 if [ $tmp -ne 0 ]; then 159 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 160 cat test_log_valgrind 161 return 1; 162 fi; 163 } 142 164 143 165 rm -f ${LOGFILE}.${remhost} … … 171 193 172 194 rm -f $LOGFILE 173 174 ./yule -p none >/dev/null 2>&1 & 195 rm -f test_log_valgrind 196 197 ${VALGRIND} ./yule -p none >/dev/null 2>>test_log_valgrind & 175 198 PROC_Y=$! 176 199 sleep 5 … … 182 205 } 183 206 184 ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>&1&207 ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind & 185 208 if test x$? = x0; then 186 209 PROC_S=$! … … 231 254 return 1 232 255 fi 256 257 [ -z "$VALGRIND" ] || { 258 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 259 if [ $tmp -ne 0 ]; then 260 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 261 cat test_log_valgrind 262 return 1; 263 fi; 264 } 233 265 234 rm -f ${LOGFILE} .${remhost}266 rm -f ${LOGFILE} 235 267 return 0 236 268 } 269 270 do_test_4 () { 271 272 # don't know what is supported on the test platform, so 273 # prepare for both (password and socket credential) 274 275 # 'id -u' is posix 276 me=`id -u` 277 278 ORIGINAL_1="SetSocketAllowUid=0" 279 REPLACEMENT_1="SetSocketAllowUid=$me" 280 ex $RCFILE <<EOF 281 :%s/${ORIGINAL_1}/${REPLACEMENT_1}/g 282 :wq 283 EOF 284 285 [ -z "$verbose" ] || { 286 echo; 287 echo "${S}Start Server${E}: ./yule -l info -p none &"; 288 echo; 289 } 290 291 rm -f $LOGFILE 292 rm -f test_log_valgrind 293 294 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind & 295 PROC_Y=$! 296 sleep 5 297 298 [ -z "$verbose" ] || { 299 echo; 300 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 301 echo; 302 } 303 304 $MAKE yulectl >/dev/null 305 if [ $? -ne 0 ]; then 306 [ -z "$verbose" ] || log_msg_fail "make yulectl"; 307 kill $PROC_Y 308 return 1 309 fi 310 311 312 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null 313 314 if [ $? -ne 0 ]; then 315 YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD 316 ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 317 if [ $? -ne 0 ]; then 318 kill ${PROC_Y} 319 [ -z "$verbose" ] || log_msg_fail "yulectl"; 320 return 1 321 fi 322 fi 323 324 ./yulectl -v -c RELOAD foobar2 >test_yulectl_log 325 326 if [ $? -ne 0 ]; then 327 kill ${PROC_Y} 328 [ -z "$verbose" ] || log_msg_fail "yulectl"; 329 return 1 330 fi 331 332 ./yulectl -v -c RELOAD foobar3 >test_log_yulectl 333 334 if [ $? -ne 0 ]; then 335 kill ${PROC_Y} 336 [ -z "$verbose" ] || log_msg_fail "yulectl"; 337 return 1 338 fi 339 340 ./yulectl -v -c LISTALL dummy >test_log_yulectl 341 342 if [ $? -ne 0 ]; then 343 kill ${PROC_Y} 344 [ -z "$verbose" ] || log_msg_fail "yulectl"; 345 return 1 346 fi 347 348 tmp=`cat test_log_yulectl | grep RELOAD | wc -l` 349 if [ $tmp -ne 3 ]; then 350 kill ${PROC_Y} 351 [ -z "$verbose" ] || log_msg_fail "command confirmation"; 352 return 1 353 fi 354 355 ./yulectl -v -c CANCEL foobar3 >test_log_yulectl 356 357 if [ $? -ne 0 ]; then 358 kill ${PROC_Y} 359 [ -z "$verbose" ] || log_msg_fail "yulectl"; 360 return 1 361 fi 362 363 ./yulectl -v -c LISTALL dummy >test_log_yulectl 364 365 if [ $? -ne 0 ]; then 366 kill ${PROC_Y} 367 [ -z "$verbose" ] || log_msg_fail "yulectl"; 368 return 1 369 fi 370 371 tmp=`cat test_log_yulectl | grep RELOAD | wc -l` 372 if [ $tmp -ne 2 ]; then 373 kill ${PROC_Y} 374 [ -z "$verbose" ] || log_msg_fail "command confirmation"; 375 return 1 376 fi 377 378 kill ${PROC_Y} 379 380 [ -z "$VALGRIND" ] || { 381 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 382 if [ $tmp -ne 0 ]; then 383 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 384 cat test_log_valgrind 385 return 1; 386 fi; 387 } 388 389 return 0 390 } 391 392 do_test_5 () { 393 394 [ -z "$verbose" ] || { 395 echo; 396 echo "${S}Start Server${E}: ./yule -l info -p none &"; 397 echo; 398 } 399 400 ( cat <<EOF 401 <!-- head --> 402 <html><head><title>test</title></head> 403 <body> 404 Current time: %T <br> 405 <table> 406 <!-- ehead --> 407 EOF 408 ) >head.html 409 410 ( cat <<EOF 411 <!-- foot --> 412 </table> 413 </body> 414 <!-- efoot --> 415 EOF 416 ) >foot.html 417 418 ( cat <<EOF 419 <!-- entry --> 420 <tr> 421 <td>%H</td> 422 <td>%S</td> 423 <td>%T</td> 424 </tr> 425 <!-- eentry --> 426 EOF 427 ) >entry.html 428 429 ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind & 430 PROC_Y=$! 431 sleep 5 432 433 egrep '<!-- head -->' $HTML >/dev/null 2>&1 434 if [ $? -ne 0 ]; then 435 rm -f head.html; rm -f foot.html; rm -f entry.html; 436 kill $PROC_Y 437 [ -z "$verbose" ] || log_msg_fail "head.html"; 438 return 1 439 fi 440 441 egrep '<!-- foot -->' $HTML >/dev/null 2>&1 442 if [ $? -ne 0 ]; then 443 rm -f head.html; rm -f foot.html; rm -f entry.html; 444 kill $PROC_Y 445 [ -z "$verbose" ] || log_msg_fail "foot.html"; 446 return 1 447 fi 448 449 [ -z "$verbose" ] || { 450 echo; 451 echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check"; 452 echo; 453 } 454 455 ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind 456 if test x$? = x0; then 457 [ -z "$verbose" ] || log_msg_ok "samhain.new -t check"; 458 else 459 kill $PROC_Y 460 [ -z "$quiet" ] && log_msg_fail "samhain.new -t check"; 461 return 1 462 fi 463 464 kill $PROC_Y 465 sleep 5 466 467 # rm -f head.html; rm -f foot.html; rm -f entry.html; 468 469 egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1 470 if [ $? -ne 0 ]; then 471 [ -z "$verbose" ] || log_msg_fail "Server start"; 472 return 1 473 fi 474 egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1 475 if [ $? -ne 0 ]; then 476 [ -z "$verbose" ] || log_msg_fail "Client connect"; 477 return 1 478 fi 479 egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1 480 if [ $? -ne 0 ]; then 481 [ -z "$verbose" ] || log_msg_fail "Client file check"; 482 return 1 483 fi 484 egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1 485 if [ $? -ne 0 ]; then 486 [ -z "$verbose" ] || log_msg_fail "Client exit"; 487 return 1 488 fi 489 egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1 490 if [ $? -ne 0 ]; then 491 [ -z "$verbose" ] || log_msg_fail "Server exit"; 492 return 1 493 fi 494 495 egrep '<!-- head -->' $HTML >/dev/null 2>&1 496 if [ $? -ne 0 ]; then 497 [ -z "$verbose" ] || log_msg_fail "head.html"; 498 return 1 499 fi 500 egrep '<!-- ehead -->' $HTML >/dev/null 2>&1 501 if [ $? -ne 0 ]; then 502 [ -z "$verbose" ] || log_msg_fail "head.html"; 503 return 1 504 fi 505 506 egrep '<!-- entry -->' $HTML >/dev/null 2>&1 507 if [ $? -ne 0 ]; then 508 [ -z "$verbose" ] || log_msg_fail "entry.html"; 509 return 1 510 fi 511 egrep '<!-- eentry -->' $HTML >/dev/null 2>&1 512 if [ $? -ne 0 ]; then 513 [ -z "$verbose" ] || log_msg_fail "entry.html"; 514 return 1 515 fi 516 517 egrep '<!-- foot -->' $HTML >/dev/null 2>&1 518 if [ $? -ne 0 ]; then 519 [ -z "$verbose" ] || log_msg_fail "foot.html"; 520 return 1 521 fi 522 egrep '<!-- efoot -->' $HTML >/dev/null 2>&1 523 if [ $? -ne 0 ]; then 524 [ -z "$verbose" ] || log_msg_fail "foot.html"; 525 return 1 526 fi 527 528 [ -z "$VALGRIND" ] || { 529 tmp=`cat test_log_valgrind 2>/dev/null | wc -l`; 530 if [ $tmp -ne 0 ]; then 531 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors"; 532 cat test_log_valgrind 533 return 1; 534 fi; 535 } 536 537 return 0 538 } 539 237 540 238 541 testrun2_internal () … … 273 576 make clean >/dev/null || return 1 274 577 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=2578 ${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 --with-html-file=$HTML --enable-encrypt=2 276 579 # 277 580 if test x$? = x0; then … … 353 656 do_test_2 354 657 if [ $? -eq 0 ]; then 355 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, sep erate logfiles";356 else 357 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, sep erate logfiles";658 [ -z "$quiet" ] && log_ok 2 ${MAXTEST} "Client logging, separate logfiles"; 659 else 660 [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles"; 358 661 fi 359 662 … … 365 668 fi 366 669 670 do_test_4 671 if [ $? -eq 0 ]; then 672 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "Server command socket"; 673 else 674 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket"; 675 fi 676 677 do_test_5 678 if [ $? -eq 0 ]; then 679 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Server status file"; 680 else 681 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file"; 682 fi 683 367 684 return $? 368 685 } 369 686 370 MAXTEST= 3; export MAXTEST687 MAXTEST=5; export MAXTEST 371 688 372 689 testrun2 ()
Note:
See TracChangeset
for help on using the changeset viewer.