Debian Codegraph @

tests/probes/system_info/test_probes_system_info.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright 2009 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # OpenScap Probes Test Suite.
7 #
8 # Created on: Nov 30, 2009
9 #
10 # Authors:
11 # Peter Vrabec, <[email protected]>
12 # David Niemoller
13 # Ondrej Moris, <[email protected]>
14
15 . $builddir/tests/test_common.sh
16
17 # Test Cases.
18
19 function test_probes_system_infoscip-shell shell shell-project 0.0.0 test_probes_system_info(). {
20 probecheck "system_info" || return 255
21
22 # This test is dependent on /etc/os-release being present, so skip this test if it doesn't exist.
23 [scip-shell system . . `[`. -f "/etc/os-releasescip-shell filesystem . . `/etc/os-release`." ] || return 255
24
25 local ret_val=0;
26 local LOGFILE="test_probes_system_info.log"
27
28 bashscip-shell system . . bash. $builddir/run ./test_probes_system_info > "$LOGFILE"
29
30 . /etc/os-releasescip-shell source . . `/etc/os-release`.
31
32 if [scip-shell system . . `[`. $? -eq 0 ] && [scip-shell system . . `[`. -f $RF ]; then
33 OS_NAME="$NAME"
34 if ! grepscip-shell system . . grep. "os_name: $OS_NAME" "$LOGFILE" > /dev/nullscip-shell filesystem . . `/dev/null`.; then
35 echoscip-shell system . . echo. "os_name should be `unamescip-shell system . . uname. -s`"
36 ret_val=$[$ret_val + 1]
37 fi
38
39 OS_VERSION="$VERSION"
40 if ! grepscip-shell system . . grep. "os_version: ${OS_VERSION}" "$LOGFILE" > /dev/nullscip-shell filesystem . . `/dev/null`.; then
41 echoscip-shell system . . echo. "os_version should be ${OS_VERSION}"
42 ret_val=$[$ret_val + 1]
43 fi
44
45 OS_ARCHITECTURE="`unamescip-shell system . . uname. -m`"
46 if ! grepscip-shell system . . grep. "os_architecture: ${OS_ARCHITECTURE}" "$LOGFILE" > /dev/nullscip-shell filesystem . . `/dev/null`.; then
47 echoscip-shell system . . echo. "os_architecture should be ${OS_ARCHITECTURE}"
48 ret_val=$[$ret_val + 1]
49 fi
50
51 PRIMARY_HOST_NAME="`unamescip-shell system . . uname. -n`"
52 if ! grepscip-shell system . . grep. "primary_host_name: ${PRIMARY_HOST_NAME}" "$LOGFILE" > /dev/nullscip-shell filesystem . . `/dev/null`.; then
53 echoscip-shell system . . echo. "primary_host_name should be ${PRIMARY_HOST_NAME}"
54 ret_val=$[$ret_val + 1]
55 fi
56
57 # TODO: network interfaces check
58
59 if [scip-shell system . . `[`. ! $ret_val -eq 0 ]; then
60 echoscip-shell system . . echo. "---------------------------------------"
61 catscip-shell system . . cat. "$LOGFILE"
62 echoscip-shell system . . echo. "---------------------------------------"
63 ret_val=2
64 fi
65 else
66 echoscip-shell system . . echo. "Unable to probe system characteristics!"
67 echoscip-shell system . . echo. ""
68 ret_val=1
69 fi
70
71 return $ret_val
72 }
73
74 # Testing.
75
76 test_init
77
78 if [scip-shell system . . `[`. -z ${CUSTOM_OSCAP+x} ] ; then
79 test_run "test_probes_system_info" test_probes_system_info
80 fi
81
82 test_exit