| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2012 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | |
| 6 | set -e -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | |
| 10 | function test_api_xccdf_embedded_cpe_eval { |
| 11 | local INPUT=$srcdir/$1 |
| 12 | local EXPECTED_NA=$2 |
| 13 | |
| 14 | result=$(make_temp_file /tmp tmp) |
| 15 | $OSCAP xccdf eval --results $result $INPUT |
| 16 | if [ "$?" != "0" ]; then |
| 17 | return 1 |
| 18 | fi |
| 19 | |
| 20 | assert_exists $EXPECTED_NA '//result[text()="notapplicable"]' |
| 21 | rm -f $result |
| 22 | } |
| 23 | # Testing. |
| 24 | |
| 25 | test_init "test_api_xccdf_applicability.log" |
| 26 | |
| 27 | test_run "test_api_xccdf_applicability_cpe_applicable_embedded_rule" test_api_xccdf_embedded_cpe_eval applicable-rule-embedded-xccdf.xml 0 |
| 28 | test_run "test_api_xccdf_applicability_cpe2_applicable_embedded_rule" test_api_xccdf_embedded_cpe_eval cpe2-applicable-rule-embedded-xccdf.xml 0 |
| 29 | test_run "test_api_xccdf_applicability_cpe2_negated_applicable_embedded_rule" test_api_xccdf_embedded_cpe_eval cpe2-negated-applicable-rule-embedded-xccdf.xml 1 |
| 30 | test_run "test_api_xccdf_applicability_cpe2_and_embedded_rule" test_api_xccdf_embedded_cpe_eval cpe2-and-rule-embedded-xccdf.xml 2 |
| 31 | test_run "test_api_xccdf_applicability_cpe2_or_embedded_rule" test_api_xccdf_embedded_cpe_eval cpe2-or-rule-embedded-xccdf.xml 0 |
| 32 | |
| 33 | test_exit |