| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | set -e -o pipefail |
| 4 | |
| 5 | . $builddir/tests/test_common.sh |
| 6 | |
| 7 | function test_probes_selinuxboolean_offline_modescip-shell shell shell-project 0.0.0 test_probes_selinuxboolean_offline_mode(). { |
| 8 | local VALID=$1 |
| 9 | |
| 10 | # if the user doesn't have SELinux enabled we will skip the test |
| 11 | selinuxenabled || return 255 |
| 12 | |
| 13 | probecheck "selinuxboolean" || return 255 |
| 14 | |
| 15 | local ret_val=0; |
| 16 | local DF="${srcdir}/test_probes_selinuxboolean_offline_mode.xml" |
| 17 | local RF="test_probes_selinuxboolean_offline_mode.results.xml" |
| 18 | local stderr=$(mktempscip-shell system . . mktemp. $1.err.XXXXXX) |
| 19 | echoscip-shell system . . echo. "stderr file: $stderr" |
| 20 | |
| 21 | [scip-shell system . . `[`. -f $RF ] && rmscip-shell system . . rm. -f $RF |
| 22 | |
| 23 | tmpdir=$(mktempscip-shell system . . mktemp. -t -d "test_offline_mode_selinuxboolean.XXXXXX") |
| 24 | |
| 25 | if [[ "${VALID}" == "true" ]]; then |
| 26 | lnscip-shell system . . ln. -s /sysscip-shell filesystem . . `/sys`. $tmpdir |
| 27 | fi |
| 28 | |
| 29 | set_chroot_offline_test_mode "$tmpdir" |
| 30 | |
| 31 | $OSCAP oval eval --results $RF $DF 2>$stderr |
| 32 | |
| 33 | unset_chroot_offline_test_mode |
| 34 | |
| 35 | [scip-shell system . . `[`. -f $RF ] |
| 36 | |
| 37 | result="$RF" |
| 38 | |
| 39 | if [[ "${VALID}" == "true" ]]; then |
| 40 | assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:1:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:1:tst:1"]`.' |
| 41 | verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF 1 |
| 42 | else |
| 43 | assert_exists 1 '/oval_results/results/system/tests/test[@result="false"][@test_id="oval:1:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="false"][@test_id="oval:1:tst:1"]`.' |
| 44 | fi |
| 45 | |
| 46 | grepscip-shell system . . grep. -Ei "(W: |E: )" $stderr && ret_val=1 && echoscip-shell system . . echo. "There is an error and/or a warning in the output!" |
| 47 | rmscip-shell system . . rm. $stderr |
| 48 | |
| 49 | rmscip-shell system . . rm. -rf ${tmpdir} |
| 50 | |
| 51 | return $ret_val |
| 52 | } |
| 53 | |
| 54 | test_run "Basic selinuxboolean probe test for offline mode" test_probes_selinuxboolean_offline_mode "true" |
| 55 | test_run "Basic selinuxboolean probe test for offline mode (invalid prefix)" test_probes_selinuxboolean_offline_mode "false" |