test_probes_rpminfo.sh   test_probes_rpminfo.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_rpminfo { function test_probes_rpminfo {
if [ ! -x ${OVAL_PROBE_DIR}/probe_rpminfo ]; then probecheck "rpminfo" || return 255
echo -e "Probe rpminfo does not exist!\n" require "rpm" || return 255
return 255; # Test is not applicable.
fi
local ret_val=0; local ret_val=0;
local DEFFILE="test_probes_rpminfo.xml" local DF="test_probes_rpminfo.xml"
local RESFILE="results.xml" local RF="results.xml"
[ -f $RESFILE ] && rm -f $RESFILE
eval "which rpm > /dev/null 2>&1" [ -f $RF ] && rm -f $RF
if [ ! $? -eq 0 ]; then
echo -e "No rpm found in $PATH!\n"
return 255; # Test is not applicable.
fi
local RPM_A_NAME=`rpm --qf "%{NAME}\n" -qa | sort -u | sed -n '1p'` local RPM_A_NAME=`rpm --qf "%{NAME}\n" -qa | sort -u | sed -n '1p'`
local RPM_B_NAME=`rpm --qf "%{NAME}\n" -qa | sort -u | sed -n '2p'` local RPM_B_NAME=`rpm --qf "%{NAME}\n" -qa | sort -u | sed -n '2p'`
bash ${srcdir}/test_probes_rpminfo.xml.sh $RPM_A_NAME $RPM_B_NAME > $DE bash ${srcdir}/test_probes_rpminfo.xml.sh $RPM_A_NAME $RPM_B_NAME > $DF
FFILE ../../../utils/.libs/oscap oval eval --results $RF $DF
../../../utils/.libs/oscap oval eval --results $RESFILE $DEFFILE
if [ -f $RESFILE ]; then
COUNT=13; ID=1
while [ $ID -le $COUNT ]; do
DEF_DEF=`cat "$DEFFILE" | grep "id=\"oval:1:def:${ID}\""`
DEF_RES=`cat "$RESFILE" | grep "definition_id=\"oval:1:def:${ID}
\""`
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=200; 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 200
ret_val=$?
else else
ret_val=1 ret_val=1
fi fi
return $ret_val return $ret_val
} }
# Testing. # Testing.
test_init "test_probes_rpminfo.log" test_init "test_probes_rpminfo.log"
 End of changes. 5 change blocks. 
78 lines changed or deleted 10 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/