source: trunk/test/testext.sh@ 9

Last change on this file since 9 was 1, checked in by katerina, 19 years ago

Initial import

File size: 2.7 KB
Line 
1#! /bin/sh
2
3
4# The following two are the ANSI sequences for start and end embolden
5case $TERM in
6vt*|ansi*|con*|xterm*|linux*|screen*)
7 S=[1m
8 E=[m
9 ;;
10*)
11 S=
12 E=
13 ;;
14esac
15
16PW_DIR=`pwd`
17
18if test x$UID != x; then
19 TRUST="--with-trusted=0,2,$UID"
20else
21 TRUST="--with-trusted=0,2"
22fi
23
24echo; echo "${S}__ STARTING TEST EXTERNAL PROGRAM __${E}"; echo;
25echo Working directory: $PW_DIR
26
27MAKE=`which gmake`
28if test "x$?" = x1 ; then
29 MAKE="make -s"
30else
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
44fi
45
46COMP=`which gcc`
47if test "x$?" = x1 ; then
48 COMP="cc"
49else
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
63fi
64echo MAKE is $MAKE
65echo COMP is $COMP
66echo
67
68
69testext0 ()
70{
71 #
72 # standalone compilation
73 #
74 echo "${S}Building standalone agent${E}"; echo;
75 #
76 if test -r "Makefile"; then
77 ${MAKE} distclean
78 fi
79 #
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_file
81 #
82 if test x$? = x0; then
83 echo "configure completed, exit status 0"; echo;
84 ${MAKE} > /dev/null
85 echo "${MAKE} completed, exit status $?"; echo;
86 else
87 echo "ERROR: configure failed"; echo;
88 fi
89
90 # prepare the program
91 #
92 cat test/test_ext.c.in | sed -e "s%MYPWDIR%$PW_DIR/test_ext.res%g" > test_ext.c
93
94 ${COMP} -o test_ext test_ext.c
95 if test "x$?" != x0; then
96 echo "FAIL: ${COMP} -o test_ext test_ext.c"
97 exit 1
98 fi
99 chmod +rx $PW_DIR/test_ext
100
101 # compute checksum and fix config file
102 #
103 cp test/testrc_1ext.in testrc_1ext
104 CHKSUM=`./samhain -H $PW_DIR/test_ext | awk '{ print $2$3$4$5$6$7}'`
105 echo "OpenCommand=$PW_DIR/test_ext" >> testrc_1ext
106 echo "SetType=log" >> testrc_1ext
107 echo "SetChecksum=$CHKSUM" >> testrc_1ext
108 echo "SetFilterOr=ALERT" >> testrc_1ext
109
110 rm -f $PW_DIR/test_ext.res
111 rm -f $PW_DIR/pdbg.child
112 rm -f $PW_DIR/pdbg.main
113 ./samhain
114
115 # 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;
122
123 rm -f $PW_DIR/.samhain_file
124 rm -f $PW_DIR/.samhain_log
125 rm -f $PW_DIR/.samhain_lock
126
127}
128
129
130
131 testext0
132
133
134echo; echo "${S}__ END TEST EXTERNAL PROGRAM __${E}"; echo;
135
136exit
137
Note: See TracBrowser for help on using the repository browser.