Fix: filesystem report
[gnucomo.git] / test / filesystem_report
diff --git a/test/filesystem_report b/test/filesystem_report
new file mode 100755 (executable)
index 0000000..44f7f1b
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+#  Create an object 'test.gnucomo.org' in the database and
+#  and read several filesystems report created by df.
+
+rm -f gcm_input.log
+
+createdb gnucomo_test
+result=1
+
+if psql gnucomo_test -q <../src/database/create.sql >/dev/null
+then
+   psql gnucomo_test -q -c "insert into object (objectname) values ('test.gnucomo.org')"
+
+   # read the output from 'df -k'
+   echo "Read output from 'df -k'"
+   ../src/gcm_input/gcm_input -v -c gnucomo_test -h test.gnucomo.org -d 'sep 7 2007 13:20:45' <df-k.out
+   result=$?
+   if [[ $result -eq 0 ]]
+   then
+      NR_PARS=`psql gnucomo_test -q -t -c "select count(*) from parameter"`
+      echo $NR_PARS parameters in the datebase
+      NR_PROP=`psql gnucomo_test -q -t -c "select count(*) from property"`
+      echo $NR_PROP parameter properties in the datebase
+      if [[ $NR_PARS -ne 7 ]]
+      then
+         result=2
+      fi
+      if [[ $NR_PROP -ne 28 ]]
+      then
+         result=3
+      fi
+   fi
+
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+else
+   echo Can not create test database
+   result=1
+fi
+
+dropdb gnucomo_test
+exit $result