| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -e -o pipefail |
| 4 | |
| 5 | . $builddir/tests/test_common.sh |
| 6 | |
| 7 | function test_probes_process58_offline_mode { |
| 8 | local VALID=$1 |
| 9 | |
| 10 | probecheck "process58" || return 255 |
| 11 | |
| 12 | local ret_val=0; |
| 13 | local DF="test_probes_process58_offline_mode.xml" |
| 14 | local RF="test_probes_process58_offline_mode.results.${VALID}.xml" |
| 15 | echo "result file: $RF" |
| 16 | local stderr=$(mktemp $1.err.XXXXXX) |
| 17 | echo "stderr file: $stderr" |
| 18 | |
| 19 | [ -f $RF ] && rm -f $RF |
| 20 | ${srcdir}/test_probes_process58_offline_mode.xml.sh $VALID > $DF |
| 21 | |
| 22 | tmpdir=$(mktemp -t -d "test_offline_mode_process58.XXXXXX") |
| 23 | |
| 24 | if [[ "${VALID}" == "true" ]]; then |
| 25 | ln -s /proc $tmpdir |
| 26 | fi |
| 27 | |
| 28 | set_chroot_offline_test_mode "$tmpdir" |
| 29 | |
| 30 | $OSCAP oval eval --results $RF $DF 2>$stderr |
| 31 | |
| 32 | unset_chroot_offline_test_mode |
| 33 | |
| 34 | if [ -f $RF ]; then |
| 35 | verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF 1 |
| 36 | ret_val=$? |
| 37 | else |
| 38 | ret_val=1 |
| 39 | fi |
| 40 | |
| 41 | grep -Ei "(W: |E: )" $stderr && ret_val=1 && echo "There is an error and/or a warning in the output!" |
| 42 | rm $stderr |
| 43 | |
| 44 | rm -rf ${tmpdir} |
| 45 | |
| 46 | return $ret_val |
| 47 | } |
| 48 | |
| 49 | test_run "Ensure that probe handles \$OSCAP_CHROOT" test_probes_process58_offline_mode "true" |
| 50 | test_run "Ensure that probe handles empty \$SCAP_CHROOT" test_probes_process58_offline_mode "false" |