| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # OpenScap Probes Test Suite. |
| 7 | # |
| 8 | # Created on: Nov 30, 2009 |
| 9 | # |
| 10 | # Authors: |
| 11 | # Peter Vrabec, <[email protected]> |
| 12 | # David Niemoller |
| 13 | # Ondrej Moris, <[email protected]> |
| 14 | # Petr Lautrbach <[email protected]> |
| 15 | |
| 16 | . $builddir/tests/test_common.sh |
| 17 | |
| 18 | # Test Cases. |
| 19 | |
| 20 | function test_probes_environmentvariable58 { |
| 21 | |
| 22 | probecheck "environmentvariable58" || return 255 |
| 23 | |
| 24 | local ret_val=0; |
| 25 | local DF="$1.xml" |
| 26 | local RF="$1.results.xml" |
| 27 | echo "result file: $RF" |
| 28 | local stderr=$(mktemp $1.err.XXXXXX) |
| 29 | echo "stderr file: $stderr" |
| 30 | |
| 31 | [ -f $RF ] && rm -f $RF |
| 32 | |
| 33 | bash ${srcdir}/$1.xml.sh > $DF |
| 34 | LINES=$? |
| 35 | |
| 36 | $OSCAP oval eval --results $RF $DF 2> $stderr |
| 37 | |
| 38 | if [ -f $RF ]; then |
| 39 | verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF $LINES |
| 40 | ret_val=$? |
| 41 | else |
| 42 | ret_val=1 |
| 43 | fi |
| 44 | |
| 45 | # Test fails if there are any warnings or "Entity has no value" on stderr. |
| 46 | echo "Verify that there are no warnings on stderr" |
| 47 | grep -Ei "(W:|Entity has no value)" $stderr && ret_val=1 |
| 48 | |
| 49 | rm $stderr |
| 50 | return $ret_val |
| 51 | } |
| 52 | |
| 53 | # Testing. |
| 54 | |
| 55 | test_init |
| 56 | |
| 57 | test_run "test_probes_environmentvariable58" test_probes_environmentvariable58 \ |
| 58 | test_probes_environmentvariable58 |
| 59 | test_run "test_probes_environmentvariable58-fail" \ |
| 60 | test_probes_environmentvariable58 test_probes_environmentvariable58-fail |
| 61 | |
| 62 | test_exit |