| 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_generate_guide { |
| 11 | local INPUT=$srcdir/$1 |
| 12 | local EXPECTED_CONTENT=$2 |
| 13 | |
| 14 | local GENERATED_CONTENT=$($OSCAP xccdf generate guide "$INPUT") |
| 15 | if [ "$?" != "0" ]; then |
| 16 | return 1 |
| 17 | fi |
| 18 | |
| 19 | echo "$GENERATED_CONTENT" | grep "$EXPECTED_CONTENT" |
| 20 | if [ "$?" == "0" ]; then |
| 21 | return 0 |
| 22 | fi |
| 23 | |
| 24 | echo "Generated content does not contain '$EXPECTED_CONTENT'!" |
| 25 | echo "Generated content:" |
| 26 | echo "$GENERATED_CONTENT" |
| 27 | |
| 28 | return 1 |
| 29 | } |
| 30 | |
| 31 | |
| 32 | # Testing. |
| 33 | |
| 34 | test_init "test_api_xccdf_guide.log" |
| 35 | |
| 36 | test_run "test_api_xccdf_guide_xccdf11" test_generate_guide content-xccdf11.xml xccdf_moc.elpmaxe.www_rule_1 |
| 37 | test_run "test_api_xccdf_guide_xccdf12" test_generate_guide content-xccdf12.xml xccdf_moc.elpmaxe.www_rule_1 |
| 38 | test_run "test_api_xccdf_guide_value_default_xccdf11" test_generate_guide content-profile-xccdf11.xml off_default |
| 39 | |
| 40 | test_exit |