Debian Codegraph @

tests/probes/partition/test_probes_partition_offline_mode.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . $builddir/tests/test_common.sh
4
5 set -e -o pipefail
6
7 function test_probes_partition {
8 local VALID=$1
9
10 probecheck "partition" || return 255
11
12 local ret_val=0;
13 local DF="${srcdir}/test_probes_partition.xml"
14 local RF="test_probes_partition_offline_mode.results.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
21 tmpdir=$(mktemp -t -d "test_offline_mode_partition.XXXXXX")
22
23 if [[ "${VALID}" == "true" ]]; then
24 ln -s /proc $tmpdir
25 fi
26
27 set_chroot_offline_test_mode "$tmpdir"
28
29 $OSCAP oval eval --results $RF $DF 2>$stderr
30
31 unset_chroot_offline_test_mode
32
33 [ -f $RF ]
34
35 result="$RF"
36
37 if [[ "${VALID}" == "true" ]]; then
38 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:1:tst:1"]'
39 verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF 1
40 else
41 assert_exists 1 '/oval_results/results/system/tests/test[@result="false"][@test_id="oval:1:tst:1"]'
42 fi
43
44 grep -Ei "(W: |E: )" $stderr && ret_val=1 && echo "There is an error and/or a warning in the output!"
45 rm $stderr
46
47 rm -rf ${tmpdir}
48
49 return $ret_val
50 }
51
52 test_run "Probe partition simple offline test (/proc mount point)" test_probes_partition "true"
53 test_run "Probe partition simple offline test (/proc mount point) (invalid prefix)" test_probes_partition "false"