X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=contrib%2Flogtesting%2Fdotests.sh;fp=contrib%2Flogtesting%2Fdotests.sh;h=e0c65a9717caf00680cee8cf319f9c6d315e35a7;hp=0000000000000000000000000000000000000000;hb=ff0e686ac67bbd82b60c277eb324910dbc60f65f;hpb=33a81e69474ae91ecec4e991debe59e26bb330fd diff --git a/contrib/logtesting/dotests.sh b/contrib/logtesting/dotests.sh new file mode 100755 index 0000000..e0c65a9 --- /dev/null +++ b/contrib/logtesting/dotests.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +echo "Starting log unit tests (must be run as root and on a system with OSSEC installed)." +echo "(it will make sure the current rules aree working as they should)." +rm -f ./tmpres +for i in ./*/log; do + idir=`dirname $i` + + rm -f ./tmpres || exit "Unable to remove tmpres."; + cat $i | /var/ossec/bin/ossec-logtest 2>&1|grep -v ossec-testrule |grep -A 500 "Phase 1:" > ./tmpres + + if [ ! -f $idir/res ]; then + echo "** Creating entry for $i - Not set yet." + cat ./tmpres > $idir/res + rm -f tmpres + continue; + fi + MD1=`md5sum ./tmpres | cut -d " " -f 1` + MD2=`md5sum $idir/res | cut -d " " -f 1` + + if [ ! $MD1 = $MD2 ]; then + echo "**ERROR: Unit testing failed. Output for the test $i failed." + echo "== OLD OUTPUT: ==" + cat $idir/res + echo "== NEW OUTPUT: ==" + cat tmpres + echo "** ERROR: Exiting." + rm -f tmpres + exit 0; + fi + +done + +echo "" +echo "Log unit tests completed. Everything seems ok (nothing changed since last test regarding the outputs)."