Changeset 19 for trunk/test/testext.sh
- Timestamp:
- Feb 12, 2006, 10:49:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/testext.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 EXTERNAL PROGRAM __${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 COMP=`which gcc` 47 if test "x$?" = x1 ; then 48 COMP="cc" 49 else 50 COMP=`which gcc | sed -e "s%\([a-z:]\) .*%\1%g"` 51 if test "x$COMP" = x; then 52 COMP="cc" 53 elif test "x$COMP" = xno; then 54 COMP="cc" 55 else 56 if test "x$COMP" = "xwhich:"; then 57 COMP="cc" 58 else 59 COMP="gcc" 60 gcc -v >/dev/null 2>&1 || COMP="gcc" 61 fi 62 fi 63 fi 64 echo MAKE is $MAKE 65 echo COMP is $COMP 66 echo 67 3 MAXTEST=1; export MAXTEST 68 4 69 5 testext0 () 70 6 { 7 COMP=`which gcc` 8 if test "x$?" = x1 ; then 9 COMP="cc" 10 else 11 COMP=`which gcc | sed -e "s%\([a-z:]\) .*%\1%g"` 12 if test "x$COMP" = x; then 13 COMP="cc" 14 elif test "x$COMP" = xno; then 15 COMP="cc" 16 else 17 if test "x$COMP" = "xwhich:"; then 18 COMP="cc" 19 else 20 COMP="gcc" 21 gcc -v >/dev/null 2>&1 || COMP="gcc" 22 fi 23 fi 24 fi 25 log_start "EXTERNAL PROGRAM" 26 [ -z "$verbose" ] || echo MAKE is $MAKE 27 [ -z "$verbose" ] || { echo COMP is $COMP; echo; } 71 28 # 72 29 # standalone compilation 73 30 # 74 echo "${S}Building standalone agent${E}"; echo;31 [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; } 75 32 # 76 33 if test -r "Makefile"; then 77 ${MAKE} distclean34 ${MAKE} distclean >/dev/null 78 35 fi 79 36 # 80 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_1ext --with-log-file=$ PW_DIR/.samhain_log--with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file37 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/testrc_1ext --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file 81 38 # 82 39 if test x$? = x0; then 83 echo "configure completed, exit status 0"; echo; 84 ${MAKE} > /dev/null 85 echo "${MAKE} completed, exit status $?"; echo; 40 [ -z "$verbose" ] || log_msg_ok "configure..."; 41 $MAKE > /dev/null 42 if test x$? = x0; then 43 [ -z "$verbose" ] || log_msg_ok "make..."; 44 else 45 [ -z "$quiet" ] && log_msg_fail "make..."; 46 return 1 47 fi 48 86 49 else 87 echo "ERROR: configure failed"; echo; 50 [ -z "$quiet" ] && log_msg_fail "configure..."; 51 return 1 88 52 fi 89 53 # 90 54 # prepare the program 91 55 # 92 56 cat test/test_ext.c.in | sed -e "s%MYPWDIR%$PW_DIR/test_ext.res%g" > test_ext.c 93 57 94 58 ${COMP} -o test_ext test_ext.c 95 59 if test "x$?" != x0; then 96 echo "FAIL:${COMP} -o test_ext test_ext.c"97 exit160 log_msg_fail "${COMP} -o test_ext test_ext.c" 61 return 1 98 62 fi 99 chmod +rx $PW_DIR/test_ext 100 63 chmod +rx test_ext 64 if test "x$?" != x0; then 65 log_msg_fail "chmod +rx test_ext" 66 return 1 67 fi 68 101 69 # compute checksum and fix config file 102 70 # … … 107 75 echo "SetChecksum=$CHKSUM" >> testrc_1ext 108 76 echo "SetFilterOr=ALERT" >> testrc_1ext 109 77 110 78 rm -f $PW_DIR/test_ext.res 111 79 rm -f $PW_DIR/pdbg.child 112 80 rm -f $PW_DIR/pdbg.main 113 ./samhain 114 81 ./samhain -p none 82 115 83 # The shell is too fast ... 116 sleep 1 117 echo; 118 echo "${S}Logged by external C program test_ext (filtered: ALERT only):${E}"; 119 echo; 120 cat $PW_DIR/test_ext.res 121 echo; 84 sleep 1 85 [ -z "$verbose" ] || { 86 echo; 87 echo "${S}Logged by external C program test_ext (filtered: ALERT only):${E}"; 88 echo; 89 cat $PW_DIR/test_ext.res 90 echo 91 } 92 93 tmp=`cat $PW_DIR/test_ext.res | wc -l` 94 if [ $tmp -eq 4 ]; then 95 tmp=`egrep 'RECV: \[EOF\]' $PW_DIR/test_ext.res | wc -l` 96 if [ $tmp -eq 2 ]; then 97 tmp=`egrep 'RECV: ALERT' $PW_DIR/test_ext.res | wc -l` 98 if [ $tmp -eq 2 ]; then 99 log_ok 1 ${MAXTEST}; 100 else 101 log_fail 1 ${MAXTEST}; 102 fi 103 else 104 log_fail 1 ${MAXTEST}; 105 fi 106 else 107 log_fail 1 ${MAXTEST}; 108 fi 122 109 123 110 rm -f $PW_DIR/.samhain_file 124 rm -f $ PW_DIR/.samhain_log111 rm -f $LOGFILE 125 112 rm -f $PW_DIR/.samhain_lock 126 113 114 log_end "EXTERNAL PROGRAM" 127 115 } 128 116 129 130 131 testext0132 133 134 echo; echo "${S}__ END TEST EXTERNAL PROGRAM __${E}"; echo;135 136 exit137
Note:
See TracChangeset
for help on using the changeset viewer.