| 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 -e -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | |
| 10 | |
| 11 | function test_generate_guide_benchmarkscip-shell shell shell-project 0.0.0 test_generate_guide_benchmark(). { |
| 12 | local INPUT=$srcdir/$1 |
| 13 | local BENCHMARK=$2 |
| 14 | local EXPECTED_CONTENT=$3 |
| 15 | |
| 16 | local GENERATED_CONTENT=$($OSCAP xccdf generate guide --benchmark-id $BENCHMARK "$INPUT") |
| 17 | if [scip-shell system . . `[`. "$?" != "0" ]; then |
| 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_guide_benchmark.log" |
| 36 | |
| 37 | test_run "test_api_xccdf_guide_benchmark_id1" test_generate_guide_benchmark benchmark_id_test-ds.xml xccdf_org.ssgproject.content_benchmark_1 Benchmark1 |
| 38 | test_run "test_api_xccdf_guide_benchmark_id2" test_generate_guide_benchmark benchmark_id_test-ds.xml xccdf_org.ssgproject.content_benchmark_2 Benchmark2 |
| 39 | |
| 40 | test_exit |