| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e -o pipefail |
| 5 | |
| 6 | name=$(basenamescip-shell system . . basename. $0 .sh) |
| 7 | tmpdir=$(make_temp_dir /tmpscip-shell filesystem . . `/tmp`. ${name}) |
| 8 | tpl=${srcdir}/${name}.xml.tpl |
| 9 | input=${tmpdir}/${name}.xml |
| 10 | result=${tmpdir}/${name}.results.xml |
| 11 | echoscip-shell system . . echo. "Temp dir: $tmpdir" |
| 12 | |
| 13 | # prepare the environment |
| 14 | sedscip-shell system . . sed. "s@%PATH%@${tmpdir}@" $tpl > $input |
| 15 | lnscip-shell system . . ln. -s /etc/hostsscip-shell filesystem . . `/etc/hosts`. ${tmpdir}/sl1 |
| 16 | lnscip-shell system . . ln. -s /nonexistentscip-shell filesystem . . `/nonexistent`. ${tmpdir}/sl2 |
| 17 | lnscip-shell system . . ln. -s ${tmpdir} ${tmpdir}/sl3 |
| 18 | |
| 19 | echoscip-shell system . . echo. "Evaluating content." |
| 20 | $OSCAP oval eval --results $result $input || [scip-shell system . . `[`. $? == 2 ] |
| 21 | echoscip-shell system . . echo. "Validating results." |
| 22 | $OSCAP oval validate --results $result |
| 23 | echoscip-shell system . . echo. "Testing syschar values." |
| 24 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/@result)')" == "true" ] |
| 25 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/@result)')" == "false" ] |
| 26 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/@result)')" == "false" ] |
| 27 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/@result)')" == "true" ] |
| 28 | echoscip-shell system . . echo. "Testing syschar values." |
| 29 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/@flag)')" == "complete" ] |
| 30 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:2"]/@flag)')" == "does not exist" ] |
| 31 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:3"]/@flag)')" == "does not exist" ] |
| 32 | [scip-shell system . . `[`. "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:4"]/@flag)')" == "complete" ] |
| 33 | |
| 34 | rmscip-shell system . . rm. -rf $tmpdir |