test_probes_filehash.sh | test_probes_filehash.sh | |||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
# Peter Vrabec, <pvrabec@redhat.com> | # Peter Vrabec, <pvrabec@redhat.com> | |||
# David Niemoller | # David Niemoller | |||
# Ondrej Moris, <omoris@redhat.com> | # Ondrej Moris, <omoris@redhat.com> | |||
. ${srcdir}/../../test_common.sh | . ${srcdir}/../../test_common.sh | |||
# Test Cases. | # Test Cases. | |||
function test_probes_filehash { | function test_probes_filehash { | |||
if [ ! -x ${OVAL_PROBE_DIR}/probe_filehash ]; then | probecheck "filehash" || return 255 | |||
echo -e "Probe filehash does not exist!\n" | require "sha1sum" || return 255 | |||
return 255; # Test is not applicable. | require "md5sum" || return 255 | |||
fi | ||||
local ret_val=0; | local ret_val=0; | |||
local DEFFILE="test_probes_filehash.xml" | local DF="test_probes_filehash.xml" | |||
local RESFILE="results.xml" | local RF="results.xml" | |||
[ -f $RESFILE ] && rm -f $RESFILE | ||||
eval "which md5sum > /dev/null 2>&1" | ||||
if [ ! $? -eq 0 ]; then | ||||
echo -e "No md5sum found in $PATH!\n" | ||||
return 255; # Test is not applicable. | ||||
fi | ||||
eval "which sha1sum > /dev/null 2>&1" | ||||
if [ ! $? -eq 0 ]; then | ||||
echo -e "No sha1sum found in $PATH!\n" | ||||
return 255; # Test is not applicable. | ||||
fi | ||||
bash ${srcdir}/test_probes_filehash.xml.sh > $DEFFILE | ||||
../../../utils/.libs/oscap oval eval --results $RESFILE $DEFFILE | ||||
if [ -f $RESFILE ]; then | ||||
COUNT=13; ID=1 | [ -f $RF ] && rm -f $RF | |||
while [ $ID -le $COUNT ]; do | ||||
DEF_DEF=`cat "$DEFFILE" | grep "id=\"oval:1:def:${ID}\""` | bash ${srcdir}/test_probes_filehash.xml.sh > $DF | |||
DEF_RES=`cat "$RESFILE" | grep "definition_id=\"oval:1:def:${ID} | ../../../utils/.libs/oscap oval eval --results $RF $DF | |||
\""` | ||||
if (echo $DEF_RES | grep -q "result=\"true\""); then | ||||
RES="TRUE" | ||||
elif (echo $DEF_RES | grep -q "result=\"false\""); then | ||||
RES="FALSE" | ||||
else | ||||
RES="ERROR" | ||||
fi | ||||
if (echo $DEF_DEF | grep -q "comment=\"true\""); then | ||||
CMT="TRUE" | ||||
elif (echo $DEF_DEF | grep -q "comment=\"false\""); then | ||||
CMT="FALSE" | ||||
else | ||||
CMT="ERROR" | ||||
fi | ||||
if [ ! $RES = $CMT ]; then | ||||
echo "Result of oval:1:def:${ID} should be ${CMT}!" | ||||
ret_val=$[$ret_val + 1] | ||||
fi | ||||
ID=$[$ID+1] | ||||
done | ||||
COUNT=120; ID=1 | ||||
while [ $ID -le $COUNT ]; do | ||||
TEST_DEF=`cat "$DEFFILE" | grep "id=\"oval:1:tst:${ID}\""` | ||||
TEST_RES=`cat "$RESFILE" | grep "test_id=\"oval:1:tst:${ID}\""` | ||||
if (echo $TEST_RES | grep -q "result=\"true\""); then | ||||
RES="TRUE" | ||||
elif (echo $TEST_RES | grep -q "result=\"false\""); then | ||||
RES="FALSE" | ||||
else | ||||
RES="ERROR" | ||||
fi | ||||
if (echo $TEST_DEF | grep -q "comment=\"true\""); then | ||||
CMT="TRUE" | ||||
elif (echo $TEST_DEF | grep -q "comment=\"false\""); then | ||||
CMT="FALSE" | ||||
else | ||||
CMT="ERROR" | ||||
fi | ||||
if [ ! $RES = $CMT ]; then | ||||
echo "Result of oval:1:tst:${ID} should be ${CMT}!" | ||||
ret_val=$[$ret_val + 1] | ||||
fi | ||||
ID=$[$ID+1] | if [ -f $RF ]; then | |||
done | verify_results "def" $DF $RF 13 && verify_results "tst" $DF $RF 120 | |||
ret_val=$? | ||||
else | else | |||
ret_val=1 | ret_val=1 | |||
fi | fi | |||
return $ret_val | return $ret_val | |||
} | } | |||
# Testing. | # Testing. | |||
test_init "test_probes_filehash.log" | test_init "test_probes_filehash.log" | |||
End of changes. 5 change blocks. | ||||
83 lines changed or deleted | 11 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |