Fix PR10: Gcm_input may loose its input message
[gnucomo.git] / test / notification_sendmail
1 #!/bin/bash
2
3 #
4 #  Test the log processing of gcm_daemon
5 #  Create a database with one object and read a piece of sendmail log
6 #
7 #  This tests problem report nrs. 14 through 17
8
9
10 rm -f gcm_input.log
11 createdb gnucomo_test
12
13 result=0
14
15 if psql gnucomo_test -q <../src/database/create.sql >/dev/null
16 then
17    #  Prepare the database
18
19    psql gnucomo_test -q -c "insert into object (objectname) values ('schiza.andromeda.nl')"
20
21    #  read logs for both objects
22
23    ../src/gcm_input/gcm_input -c gnucomo_test -h schiza.andromeda.nl -d 'oct 26 2003 20:30:45' <log0010
24
25    # Test gcm_daemon
26    cd ../src/gcm_daemon; ./gcm_daemon.php -c gnucomo_test; cd ../../test
27
28    # Check the notifications.
29
30    NR_NOTIF1=`psql gnucomo_test -q -t -c "select count(*) from notification"`
31    if [[ $NR_NOTIF1 -ne 4 ]]
32    then
33       echo "$NR_NOTIF1 notifications for object 1 (4 expected)."
34       result=2
35    fi
36
37    #  Clean up.
38
39    psql gnucomo_test -f ../src/database/destroy.sql -q
40
41    dropdb gnucomo_test
42    exit $result
43 else
44    echo Can not create test database
45    dropdb gnucomo_test
46    exit 1
47 fi