Fix: filesystem report
[gnucomo.git] / test / filesystem_report
1 #!/bin/bash
2
3 #
4 #  Create an object 'test.gnucomo.org' in the database and
5 #  and read several filesystems report created by df.
6
7 rm -f gcm_input.log
8
9 createdb gnucomo_test
10 result=1
11
12 if psql gnucomo_test -q <../src/database/create.sql >/dev/null
13 then
14    psql gnucomo_test -q -c "insert into object (objectname) values ('test.gnucomo.org')"
15
16    # read the output from 'df -k'
17    echo "Read output from 'df -k'"
18    ../src/gcm_input/gcm_input -v -c gnucomo_test -h test.gnucomo.org -d 'sep 7 2007 13:20:45' <df-k.out
19    result=$?
20    if [[ $result -eq 0 ]]
21    then
22       NR_PARS=`psql gnucomo_test -q -t -c "select count(*) from parameter"`
23       echo $NR_PARS parameters in the datebase
24       NR_PROP=`psql gnucomo_test -q -t -c "select count(*) from property"`
25       echo $NR_PROP parameter properties in the datebase
26       if [[ $NR_PARS -ne 7 ]]
27       then
28          result=2
29       fi
30       if [[ $NR_PROP -ne 28 ]]
31       then
32          result=3
33       fi
34    fi
35
36    psql gnucomo_test -f ../src/database/destroy.sql -q
37 else
38    echo Can not create test database
39    result=1
40 fi
41
42 dropdb gnucomo_test
43 exit $result