Debian Codegraph @

tests/probes/systemdunitdependency/test_probes_systemdunitdependency_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_systemdunitdependency_offline_modescip-shell shell shell-project 0.0.0 test_probes_systemdunitdependency_offline_mode(). {
13 local VALID=$1
14
15 probecheck "systemdunitdependency" || 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="test_probes_systemdunitdependency_offline_mode.xml"
20 local RF="test_probes_systemdunitdependency_offline_mode.results.${VALID}.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 ${srcdir}/test_probes_systemdunitdependency_offline_mode.xml.sh $VALID > $DF
26
27 tmpdir=$(mktempscip-shell system . . mktemp. -t -d "test_offline_mode_systemdunitdependency.XXXXXX")
28
29 if [[ "${VALID}" == "true" ]]; then
30 lnscip-shell system . . ln. -s /runscip-shell filesystem . . `/run`. $tmpdir
31 fi
32
33 set_chroot_offline_test_mode "$tmpdir"
34
35 $OSCAP oval eval --results $RF $DF 2>$stderr
36
37 unset_chroot_offline_test_mode
38
39 [scip-shell system . . `[`. -f $RF ]
40
41 result="$RF"
42
43 if [[ "${VALID}" == "true" ]]; then
44 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"]`.'
45 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"]`.'
46 else
47 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"]`.'
48 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"]`.'
49 fi
50
51 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!"
52 rmscip-shell system . . rm. $stderr
53
54 rmscip-shell system . . rm. $RF
55 rmscip-shell system . . rm. -rf ${tmpdir}
56
57 return $ret_val
58 }
59
60 test_run "Probe systemdunitdependency offline functionality" test_probes_systemdunitdependency_offline_mode "true"
61 test_run "Probe systemdunitdependency offline functionality (invalid prefix)" test_probes_systemdunitdependency_offline_mode "false"