gcm_daemon: Use lock file to prevent parallel execution
[gnucomo.git] / test / read_without_hostname
1 #!/bin/bash
2
3 #
4 #  Create an object 'kithira.andromeda.nl' in the database and
5 #  try to parse a piece of a syslog file without specifying the hostname.
6 #  The message should be rejected on account of an unknown host.
7
8 rm -f gcm_input.log
9
10 createdb gnucomo_test
11 result=1
12
13 if psql gnucomo_test -q <../src/database/create.sql >/dev/null
14 then
15    psql gnucomo_test -q -c "insert into object (objectname) values ('kithira.andromeda.nl')"
16    ../src/gcm_input/gcm_input -c gnucomo_test  <messages
17    NR_LOGS=`psql gnucomo_test -q -t -c "select count(*) from log"`
18    if [[ $NR_LOGS -eq 0 ]]
19    then
20       echo "No log entries in database"
21       result=0
22    fi
23    if [[ $result -eq 0 ]]
24    then
25       result=2
26       if grep "Can not determine the hostname where the message came from." gcm_input.log
27       then
28          result=0
29       fi
30    fi
31    psql gnucomo_test -f ../src/database/destroy.sql -q
32    dropdb gnucomo_test
33    exit $result
34 else
35    echo Can not create test database
36    dropdb gnucomo_test
37    exit 1
38 fi