Debian Codegraph @

tests/probes/system_info/test_probes_system_info_offline_mode.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright 2018 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # OpenSCAP Test Suite
7 #
8 # Authors:
9 # Jan Černý <[email protected]>
10
11 . $builddir/tests/test_common.sh
12
13 set -e -o pipefail
14
15 function test_offline_mode_system_info_offlinescip-shell shell shell-project 0.0.0 test_offline_mode_system_info_offline(). {
16 # This test is dependent on /etc/os-release being present, so skip this test if it doesn't exist.
17 [scip-shell system . . `[`. -f "/etc/os-releasescip-shell filesystem . . `/etc/os-release`." ] || return 255
18
19 temp_dir="$(mktempscip-shell system . . mktemp. -d)"
20
21 lnscip-shell system . . ln. -s /etcscip-shell filesystem . . `/etc`. $temp_dir
22
23 result="$(mktempscip-shell system . . mktemp.)"
24
25 set_chroot_offline_test_mode "$temp_dir"
26
27 $OSCAP oval eval --results $result $srcdir/test_probes_system_info.oval.xml
28
29 unset_chroot_offline_test_mode
30
31 [scip-shell system . . `[`. -s "$result" ]
32
33 . /etc/os-releasescip-shell source . . `/etc/os-release`.
34
35 case $(unamescip-shell system . . uname.) in
36 FreeBSD)
37 HOSTNAME=`grepscip-shell system . . grep. hostname= /etc/rc.confscip-shell filesystem . . `/etc/rc.conf`. | cutscip-shell system . . cut. -d '"' -f 2`
38 ;;
39 *)
40 HOSTNAME=`catscip-shell system . . cat. /etc/hostnamescip-shell filesystem . . `/etc/hostname`.`
41 ;;
42 esac
43
44 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_infoscip-shell filesystem . . `/oval_results/results/system/oval_system_characteristics/system_info`.'
45 assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/os_name[text()=\"${NAME}\"]"
46 assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/os_version[text()=\"${VERSION}\"]"
47 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_info/architecture[text()="Unknown"]scip-shell filesystem . . `/oval_results/results/system/oval_system_characteristics/system_info/architecture[text()="Unknown"]`.'
48 assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_info/primary_host_name[text()=\"${HOSTNAME}\"]"
49
50 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_info/interfacesscip-shell filesystem . . `/oval_results/results/system/oval_system_characteristics/system_info/interfaces`.'
51 # Getting network interfaces information from the guest is not implemented,
52 # check if there are no interfaces from the host
53 assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_info/interfaces/interfacescip-shell filesystem . . `/oval_results/results/system/oval_system_characteristics/system_info/interfaces/interface`.'
54
55 rmscip-shell system . . rm. -rf "$temp_dir"
56 rmscip-shell system . . rm. -f "$result"
57 }
58
59 test_run "test_offline_mode_system_info_offline" test_offline_mode_system_info_offline