source: trunk/test/testrun_2d.sh@ 565

Last change on this file since 565 was 562, checked in by katerina, 3 years ago

Fix for ticket #450 (compiler warnings) and fixes for tests.

File size: 4.6 KB
RevLine 
[1]1#! /bin/sh
2
[27]3#
4# Copyright Rainer Wichmann (2006)
5#
6# License Information:
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (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 of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21
[19]22SERVER_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=postgresql"; export SERVER_BUILDOPTS
[1]23
[30]24CLIENT_BUILDOPTS="--quiet $TRUST --prefix=$PW_DIR --with-tmp-dir=$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
[1]25
[170]26create_pgpass () {
27touch ~/.pgpass
28chmod 600 ~/.pgpass
29cat > ~/.pgpass << EOF
30localhost:*:samhain:samhain:samhain
31EOF
32}
33
[19]34check_psql_log () {
35 DATE="$1"
[1]36
[19]37 rm -f test_log_db
[170]38 # PGPASSWORD=samhain; export PGPASSWORD
39 create_pgpass
[562]40 psql -h localhost -o test_log_db -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';"
[19]41 #
42 egrep "START.*Yule" test_log_db >/dev/null 2>&1
43 if [ $? -ne 0 ]; then
[562]44 [ -z "$verbose" ] || log_msg_fail "Server start (psql) DATE ${DATE}";
[19]45 return 1
[1]46 fi
[19]47 egrep "NEW CLIENT" test_log_db >/dev/null 2>&1
48 if [ $? -ne 0 ]; then
[207]49 [ -z "$verbose" ] || log_msg_fail "Client connect (psql)";
[19]50 return 1
51 fi
52 egrep "Checking.*/bin" test_log_db >/dev/null 2>&1
53 if [ $? -ne 0 ]; then
[207]54 [ -z "$verbose" ] || log_msg_fail "Client file check (psql)";
[19]55 return 1
56 fi
57 egrep "EXIT.*Samhain" test_log_db >/dev/null 2>&1
58 if [ $? -ne 0 ]; then
[207]59 [ -z "$verbose" ] || log_msg_fail "Client exit (psql)";
[19]60 return 1
61 fi
62 egrep "EXIT.*Yule.*SIGTERM" test_log_db >/dev/null 2>&1
63 if [ $? -ne 0 ]; then
[207]64 [ -z "$verbose" ] || log_msg_fail "Server exit (psql)";
[19]65 return 1
66 fi
67 return 0
68}
[1]69
[19]70MAXTEST=1; export MAXTEST
[1]71
72testrun2d ()
73{
[19]74 log_start "RUN FULL CLIENT/SERVER W/POSTGRESQL"
75 #
76 if [ -z "$doall" ]; then
77 log_skip 1 $MAXTEST 'Client/server w/postgresql (or use --really-all)'
78 return 0
79 fi
80 if [ x"$1" = x ]; then
81 [ -z "$quiet" ] && log_msg_fail "Missing hostname"
82 fi
83 PSQL=`find_path psql`
84 if [ -z "$PSQL" ]; then
85 log_skip 1 $MAXTEST "psql not found";
86 return 1
87 else
[170]88 # PGPASSWORD="samhain"; export PGPASSWORD
89 create_pgpass
[562]90 TEST=`psql -h localhost -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null`
[19]91 if [ $? -ne 0 -o -z "$TEST" ]; then
92 log_skip 1 $MAXTEST "psql not default setup"
93 return 1
[1]94 fi
[19]95 fi
96 #
97 SH_LOCALHOST=$1; export SH_LOCALHOST
98 #
99 DATE=`date '+%Y-%m-%d %T'`
100 #
101 testrun2a_internal
102 #
[481]103 for ff in ./rc.*; do
104 ORIGINAL="SetUdpActive=no"
105 REPLACEMENT="ReportCheckflags=yes"
106 ex -s rc.morrigan.localdomain <<EOF
107%s/$ORIGINAL/$REPLACEMENT/g
108wq
109EOF
110 done
111 #
[19]112 ORIGINAL="DatabaseSeverity=none"
113 REPLACEMENT="DatabaseSeverity=info"
[51]114 ex -s $RCFILE <<EOF
[30]115%s/$ORIGINAL/$REPLACEMENT/g
116wq
[19]117EOF
118 #
[562]119 ORIGINAL="# setdbname=samhain"
120 REPLACEMENT="setdbhost=127.0.0.1"
121 ex -s $RCFILE <<EOF
122%s/$ORIGINAL/$REPLACEMENT/g
123wq
124EOF
125 #
[19]126 do_test_1_a
[22]127 #
[19]128 if [ $? -ne 0 ]; then
129 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
130 else
131 #
132 check_psql_log "${DATE}"
133 if [ $? -ne 0 ]; then
134 [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
[1]135 else
[19]136 [ -z "$quiet" ] && log_ok 1 ${MAXTEST} "Client/server w/postgresql";
[1]137 fi
[19]138 fi
139 #
140 if [ -n "$cleanup" ]; then
141 rm -f ./rc.${SH_LOCALHOST}
142 rm -f ./file.${SH_LOCALHOST}
143 ALTHOST=`find_hostname`
144 rm -f "./file.${ALTHOST}"
145 rm -f "./rc.${ALTHOST}"
146 fi
147 #
148 log_end "RUN FULL CLIENT/SERVER W/POSTGRESQL"
[1]149}
150
Note: See TracBrowser for help on using the repository browser.