7f0d1148 |
#!/bin/sh |
2a75d710 |
die() { |
7f0d1148 |
test -f /tmp/clamd-test.pid && kill `cat /tmp/clamd-test.pid` |
dfc0c031 |
rm -rf test-db test-clamd-viraction.conf test-clamd.log test-clamd-heur-pred.conf clamd-test.socket |
232c4b70 |
exit $1
} |
7f0d1148 |
run_clamd_test() {
conf_file=$1
shift
rm -f clamdscan.log
../clamd/clamd -c $conf_file || { echo "Failed to start clamd!" >&2; die 1;}
../clamdscan/clamdscan --version --config-file $conf_file 2>&1|grep "^ClamAV" >/dev/null || { echo "clamdscan can't get version of clamd!" >&2; die 2;}
../clamdscan/clamdscan --quiet --config-file $conf_file $* --log=clamdscan.log
if test $? = 2; then
echo "Failed to run clamdscan!" >&2;
die 3;
fi
test /tmp/clamd-test.pid && kill `cat /tmp/clamd-test.pid`
} |
232c4b70 |
mkdir -p test-db
cat <<EOF >test-db/test.hdb
aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
EOF |
7f0d1148 |
cp $srcdir/input/daily.ftm test-db/
cp $srcdir/input/daily.pdb test-db/ |
232c4b70 |
|
7f0d1148 |
# Test that all testfiles are detected |
232c4b70 |
FILES=../test/clam* |
7f0d1148 |
run_clamd_test $srcdir/test-clamd.conf $FILES |
232c4b70 |
NFILES=`ls -1 $FILES | wc -l`
NINFECTED=`grep "Infected files" clamdscan.log | cut -f2 -d:` |
53ffc6c7 |
if test "$NFILES" -ne "$NINFECTED"; then |
232c4b70 |
echo "clamd did not detect all testfiles correctly!" >&2;
grep OK clamdscan.log >&2;
die 4;
fi |
7f0d1148 |
# Test VirusEvent feature |
b6927a7c |
cat <$srcdir/test-clamd.conf >test-clamd-viraction.conf |
751f8470 |
echo "VirusEvent `pwd`/$srcdir/virusaction-test.sh `pwd` \"Virus found: %v\"" >>test-clamd-viraction.conf
rm -f test-clamd.log |
7f0d1148 |
run_clamd_test test-clamd-viraction.conf ../test/clam.exe |
dfc0c031 |
grep "Virus found: ClamAV-Test-File.UNOFFICIAL" test-clamd.log >/dev/null 2>/dev/null;
if test ! $? ; then
echo "Virusaction test failed!" |
751f8470 |
cat test-clamd.log |
7f0d1148 |
die 5;
fi
# Test HeuristicScanPrecedence feature |
b6927a7c |
cat <$srcdir/test-clamd.conf >test-clamd-heur-pred.conf |
7f0d1148 |
run_clamd_test test-clamd-heur-pred.conf clam-phish-exe |
dfc0c031 |
grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null;
if test ! $?; then |
7f0d1148 |
echo "HeuristicScanPrecedence off test failed!" >&2;
cat clamdscan.log;
die 6;
fi
echo "HeuristicScanPrecedence yes" >>test-clamd-heur-pred.conf
run_clamd_test test-clamd-heur-pred.conf clam-phish-exe |
dfc0c031 |
grep "Phishing.Heuristics.Email.SpoofedDomain" clamdscan.log >/dev/null 2>/dev/null;
if test ! $?; then |
7f0d1148 |
echo "HeuristicScanPrecedence on test failed!" >&2;
cat clamdscan.log;
die 6; |
751f8470 |
fi |
232c4b70 |
die 0; |