Debian Codegraph @

tests/probes/systemdunitproperty/test_probes_systemdunitproperty_offline_mode.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright 2014--2016 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # OpenScap Probes Test Suite.
7
8 set -e -o pipefail
9
10 . $builddir/tests/test_common.sh
11
12 function test_probes_systemdunitproperty_offline_modescip-shell shell shell-project 0.0.0 test_probes_systemdunitproperty_offline_mode(). {
13 local VALID=$1
14
15 probecheck "systemdunitproperty" || return 255
16 pidofscip-shell system . . pidof. systemd > /dev/nullscip-shell filesystem . . `/dev/null`. || return 255
17
18 local ret_val=0;
19 local DF="${srcdir}/test_probes_systemdunitproperty_offline_mode.xml"
20 local RF="results.xml"
21 local stderr=$(mktempscip-shell system . . mktemp. $1.err.XXXXXX)
22 echoscip-shell system . . echo. "stderr file: $stderr"
23
24 [scip-shell system . . `[`. -f $RF ] && rmscip-shell system . . rm. -f $RF
25
26 tmpdir=$(mktempscip-shell system . . mktemp. -t -d "test_offline_mode_systemdunitproperty.XXXXXX")
27
28 if [[ "${VALID}" == "true" ]]; then
29 lnscip-shell system . . ln. -s /runscip-shell filesystem . . `/run`. $tmpdir
30 fi
31
32 set_chroot_offline_test_mode "$tmpdir"
33
34 $OSCAP oval eval --results $RF $DF 2>$stderr
35
36 unset_chroot_offline_test_mode
37
38 [scip-shell system . . `[`. -f $RF ]
39
40 result="$RF"
41
42 if [[ "${VALID}" == "true" ]]; then
43 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:1"]`.'
44 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:2"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:2"]`.'
45 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:3"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:3"]`.'
46 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:4"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:4"]`.'
47 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:5"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:0:tst:5"]`.'
48 assert_exists 1 '/oval_results/results/system/tests/test[@result="false"][@test_id="oval:0:tst:6"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="false"][@test_id="oval:0:tst:6"]`.'
49 assert_exists 1 '/oval_results/results/system/tests/test[@result="false"][@test_id="oval:0:tst:7"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="false"][@test_id="oval:0:tst:7"]`.'
50 verify_results "def" $DF $RF 7
51 verify_results "tst" $DF $RF 7
52 else
53 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:1"]`.'
54 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:2"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:2"]`.'
55 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:3"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:3"]`.'
56 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:4"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:4"]`.'
57 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:5"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:5"]`.'
58 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:6"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:6"]`.'
59 assert_exists 1 '/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:7"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="unknown"][@test_id="oval:0:tst:7"]`.'
60 fi
61
62 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!"
63 rmscip-shell system . . rm. $stderr
64
65 rmscip-shell system . . rm. $RF
66 rmscip-shell system . . rm. -rf ${tmpdir}
67
68 return $ret_val
69 }
70
71 test_run "Probe systemdunitproperty offline functionality" test_probes_systemdunitproperty_offline_mode "true"
72 test_run "Probe systemdunitproperty offline functionality (invalid prefix)" test_probes_systemdunitproperty_offline_mode "false"