| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basename $0 .sh) |
| 8 | name="${name%_stigw}" |
| 9 | result="$(mktemp -t ${name}.out.XXXXXX)" |
| 10 | stderr=$(mktemp -t ${name}.out.XXXXXX) |
| 11 | ret=0 |
| 12 | echo "Stderr file = $stderr" |
| 13 | 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 | [ $ret == 2 ] |
| 24 | [ -f $stderr ]; [ ! -s $stderr ]; :> $stderr |
| 25 | [ -s "$result" ] |
| 26 | |
| 27 | "$PREFERRED_PYTHON" "$srcdir/stig-viewer-equivalence.py" "$result" "$srcdir/correct_stigw_result.xml" 2> "$stderr" |
| 28 | rm "$result" |