| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # Copyright 2012 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | |
| 6 | set -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | |
| 10 | function test_progressscip-shell shell shell-project 0.0.0 test_progress(). { |
| 11 | local PROGRESS=$1 |
| 12 | local INPUT="$srcdir/$2" |
| 13 | local EXPECTED_CONTENT="$3" |
| 14 | |
| 15 | local GENERATED_CONTENT=$($OSCAP xccdf eval $PROGRESS "$INPUT") |
| 16 | if [scip-shell system . . `[`. "$?" != "0" ]; then |
| 17 | echoscip-shell system . . echo. "Unable to generate content, oscap result: $?" |
| 18 | return 1 |
| 19 | fi |
| 20 | |
| 21 | echoscip-shell system . . echo. "$GENERATED_CONTENT" | grepscip-shell system . . grep. "$EXPECTED_CONTENT" |
| 22 | if [scip-shell system . . `[`. "$?" == "0" ]; then |
| 23 | return 0 |
| 24 | fi |
| 25 | |
| 26 | echoscip-shell system . . echo. "Generated content does not contain '$EXPECTED_CONTENT'!" |
| 27 | echoscip-shell system . . echo. "Generated content:" |
| 28 | echoscip-shell system . . echo. "$GENERATED_CONTENT" |
| 29 | |
| 30 | return 1 |
| 31 | } |
| 32 | |
| 33 | # Testing. |
| 34 | |
| 35 | test_init "test_api_xccdf_progress.log" |
| 36 | |
| 37 | test_run "test_api_xccdf_progress_xccdf11" test_progress --progress content-xccdf11.xml xccdf_moc.elpmaxe.www_rule_1:pass |
| 38 | test_run "test_api_xccdf_progress_xccdf12" test_progress --progress content-xccdf12.xml xccdf_moc.elpmaxe.www_rule_1:pass |
| 39 | |
| 40 | test_run "test_api_xccdf_progress_full_xccdf11" test_progress --progress-full content-xccdf11.xml "xccdf_moc.elpmaxe.www_rule_1\\|Rule 1\\|pass" |
| 41 | |
| 42 | test_exit |