| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | . $builddir/tests/test_common.sh |
| 4 | |
| 5 | set -e -o pipefail |
| 6 | |
| 7 | function perform_test { |
| 8 | probecheck "file" || return 255 |
| 9 | |
| 10 | name=$(basename $0 .sh) |
| 11 | result=$(mktemp ${name}.out.XXXXXX) |
| 12 | echo "Result file: $result" |
| 13 | |
| 14 | echo "Evaluating content." |
| 15 | $OSCAP oval eval --results $result $srcdir/${name}.xml || [ $? == 2 ] |
| 16 | |
| 17 | echo "Validating results." |
| 18 | $OSCAP oval validate --results $result |
| 19 | |
| 20 | echo "Testing results values." |
| 21 | [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/@result)')" == "true" ] |
| 22 | |
| 23 | echo "Testing syschar values." |
| 24 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/@flag)')" == "complete" ] |
| 25 | [ "$($XPATH $result 'count(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/reference)')" == "1" ] |
| 26 | |
| 27 | [ "$($XPATH $result 'boolean(/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath/@mask)')" == "0" ] |
| 28 | [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath)')" == "/etc/passwd" ] |
| 29 | |
| 30 | rm $result |
| 31 | } |
| 32 | |
| 33 | perform_test |