| 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_cpe2_eval { |
| 11 | local INPUT=$srcdir/$1 |
| 12 | local CPE_DICT=$srcdir/$2 |
| 13 | local EXPECTED_NA=$3 |
| 14 | |
| 15 | result=$(make_temp_file /tmp tmp) |
| 16 | $OSCAP xccdf eval --cpe $CPE_DICT --results $result $INPUT |
| 17 | if [ "$?" != "0" ]; then |
| 18 | return 1 |
| 19 | fi |
| 20 | |
| 21 | assert_exists $EXPECTED_NA '//result[text()="notapplicable"]' |
| 22 | rm -f $result |
| 23 | } |
| 24 | |
| 25 | # Testing. |
| 26 | |
| 27 | test_init "test_api_xccdf_applicability.log" |
| 28 | |
| 29 | test_run "test_api_xccdf_applicability_cpe2_applicable_rule" test_api_xccdf_cpe2_eval cpe2-applicable-rule-xccdf.xml cpe2-dict.xml 0 |
| 30 | |
| 31 | test_exit |