| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basename $0 .sh) |
| 8 | result=$(make_temp_file /tmp ${name}.out) |
| 9 | stderr=$(make_temp_file /tmp ${name}.out) |
| 10 | |
| 11 | cp $srcdir/${name}.xccdf.xml $result |
| 12 | |
| 13 | echo "Stderr file = $stderr" |
| 14 | echo "Result and input file = $result" |
| 15 | tmpdir=$(dirname $result) |
| 16 | |
| 17 | for i in {1..5}; do |
| 18 | $OSCAP xccdf eval --results $result $result 2> $stderr |
| 19 | [ -f $stderr ] |
| 20 | grep "Skipping $tmpdir/non_existent\.oval\.xml file which is referenced from XCCDF content" $stderr |
| 21 | :> $stderr |
| 22 | |
| 23 | $OSCAP xccdf validate --skip-schematron $result |
| 24 | assert_exists $i '//TestResult' |
| 25 | assert_exists $i '//TestResult/rule-result/result[text()="notchecked"]' |
| 26 | assert_exists $i '//TestResult/score' |
| 27 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile"]' |
| 28 | assert_exists $i '//TestResult[contains(@id, "xccdf_org.open-scap_testresult_default-profile")]' |
| 29 | let n=i-1 || true |
| 30 | assert_exists $n '//TestResult[contains(@id, "xccdf_org.open-scap_testresult_default-profile00")]' |
| 31 | for j in `seq 1 $n`; do |
| 32 | # Compatibility for FreeBSD's seq |
| 33 | if [ "$j" -gt "$n" ]; then |
| 34 | break; |
| 35 | fi |
| 36 | assert_exists 1 '//TestResult[contains(@id, "xccdf_org.open-scap_testresult_default-profile00'$j'")]' |
| 37 | done |
| 38 | done |
| 39 | |
| 40 | rm $result |