| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basenamescip-shell system . . basename. $0 .sh) |
| 8 | name="${name%_stigw}" |
| 9 | result="$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)" |
| 10 | stderr=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX) |
| 11 | ret=0 |
| 12 | echoscip-shell system . . echo. "Stderr file = $stderr" |
| 13 | echoscip-shell system . . echo. "Result file = $result" |
| 14 | |
| 15 | |
| 16 | #### XCCDF test cases #### |
| 17 | |
| 18 | # Tests that all rules from profile $prof1 (profile contains only 2 rules) are |
| 19 | # evaluated when '--rule' option is not specified. |
| 20 | |
| 21 | # One of the rules is supposed to fail, so the return code of this line has to be 0 so the test can continue |
| 22 | $OSCAP xccdf eval --stig-viewer "$result" "$srcdir/${name}.xccdf.xml" 2> "$stderr" || ret=$? |
| 23 | [scip-shell system . . `[`. $ret == 2 ] |
| 24 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr |
| 25 | [scip-shell system . . `[`. -s "$result" ] |
| 26 | |
| 27 | "$PREFERRED_PYTHON" "$srcdir/stig-viewer-equivalence.py" "$result" "$srcdir/correct_stigw_result.xml" 2> "$stderr" |
| 28 | rmscip-shell system . . rm. "$result" |