gcm_daemon: Use lock file to prevent parallel execution
[gnucomo.git] / test / read_bad_messages
1 #!/bin/sh
2
3 #
4 #  Create an object 'example1.gnucomo.test' in the database and
5 #  parse a piece of a syslog file with bad, short and empty lines.
6 #  There should be warnings printed on the log
7
8 rm -f gcm_input.log
9
10 createdb gnucomo_test
11
12 result=0
13
14 if psql gnucomo_test -q <../src/database/create.sql >/dev/null
15 then
16    psql gnucomo_test -q -c "insert into object (objectname) values ('example1.gnucomo.test')"
17    ../src/gcm_input/gcm_input -c gnucomo_test -h example1.gnucomo.test -d 'Jun 9 2002 20:30:45' <messages.bad
18    psql gnucomo_test -q -t -c "select * from log" -o log.tbl
19    result=2
20    if grep "WARNING: Not a valid line: nearly empty line" gcm_input.log && grep "Can not insert log element" gcm_input.log
21    then
22       result=0
23    fi
24    result=$?
25    psql gnucomo_test -f ../src/database/destroy.sql -q
26 else
27    echo Can not create test database
28    result=1
29 fi
30 dropdb gnucomo_test
31 exit $result