11 trap "cleanup" INT TERM EXIT
14 if diff --help 2>&1 | grep -q -- --color; then
15 diff_cmd='diff --color'
20 echo "Starting log unit tests (must be run as root and on a system with OSSEC installed)."
21 echo "(it will make sure the current rules are working as they should)."
26 rm -f ./tmpres || exit "Unable to remove tmpres.";
27 cat $i | /var/ossec/bin/ossec-logtest 2>&1|grep -av ossec-testrule |grep -aA 500 "Phase 1:" > ./tmpres
29 if [ ! -f $idir/res ]; then
30 echo "** Creating entry for $i - Not set yet."
31 cat ./tmpres > $idir/res
35 MD1=`md5sum ./tmpres | cut -d " " -f 1`
36 MD2=`md5sum $idir/res | cut -d " " -f 1`
38 if [ ! $MD1 = $MD2 ]; then
43 echo "**ERROR: Unit testing failed. Output for the test $i failed."
44 echo "== DIFF OUTPUT: =="
45 $diff_cmd -Na -U `wc -l $idir/res` tmpres
52 if [ $exitcode -eq 0 ]; then
53 echo "Log unit tests completed. Everything seems ok (nothing changed since last test regarding the outputs)."
55 echo "Log unit tests completed. Some tests failed."