| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e -o pipefail |
| 5 | |
| 6 | name=$(basename $0 .sh) |
| 7 | tmpdir=$(make_temp_dir /tmp ${name}) |
| 8 | tpl=${srcdir}/${name}.xml.tpl |
| 9 | input=${tmpdir}/${name}.xml |
| 10 | result=${tmpdir}/${name}.results.xml |
| 11 | echo "Temp dir: $tmpdir" |
| 12 | |
| 13 | # prepare the environment |
| 14 | sed "s@%PATH%@${tmpdir}@" $tpl > $input |
| 15 | echo "line1" > "${tmpdir}/textfile" |
| 16 | echo "line2" >> "${tmpdir}/textfile" |
| 17 | echo "line3" >> "${tmpdir}/textfile" |
| 18 | |
| 19 | echo "Evaluating content." |
| 20 | $OSCAP oval eval --results $result $input || [ $? == 2 ] |
| 21 | echo "Validating results." |
| 22 | $OSCAP oval validate --results $result |
| 23 | echo "Testing syschar values." |
| 24 | # filename |
| 25 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filename:tst:1"]/@result)')" == "true" ] |
| 26 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filename:tst:2"]/@result)')" == "true" ] |
| 27 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filename:tst:3"]/@result)')" == "true" ] |
| 28 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filename:tst:4"]/@result)')" == "false" ] |
| 29 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filename:tst:5"]/@result)')" == "true" ] |
| 30 | # filepath |
| 31 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filepath:tst:1"]/@result)')" == "true" ] |
| 32 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filepath:tst:2"]/@result)')" == "true" ] |
| 33 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filepath:tst:3"]/@result)')" == "true" ] |
| 34 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filepath:tst:4"]/@result)')" == "false" ] |
| 35 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:filepath:tst:5"]/@result)')" == "true" ] |
| 36 | echo "Testing syschar values." |
| 37 | # filename |
| 38 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filename:obj:1"]/@flag)')" == "complete" ] |
| 39 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filename:obj:2"]/@flag)')" == "complete" ] |
| 40 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filename:obj:3"]/@flag)')" == "complete" ] |
| 41 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filename:obj:4"]/@flag)')" == "does not exist" ] |
| 42 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filename:obj:5"]/@flag)')" == "complete" ] |
| 43 | #filepath |
| 44 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filepath:obj:1"]/@flag)')" == "complete" ] |
| 45 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filepath:obj:2"]/@flag)')" == "complete" ] |
| 46 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filepath:obj:3"]/@flag)')" == "complete" ] |
| 47 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filepath:obj:4"]/@flag)')" == "does not exist" ] |
| 48 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:filepath:obj:5"]/@flag)')" == "complete" ] |
| 49 | |
| 50 | rm -rf $tmpdir |