| 1 | #!/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_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 | [ -f "/etc/os-release" ] || return 255 |
| 24 | |
| 25 | local ret_val=0; |
| 26 | local LOGFILE="test_probes_system_info.log" |
| 27 | |
| 28 | bash $builddir/run ./test_probes_system_info > "$LOGFILE" |
| 29 | |
| 30 | . /etc/os-release |
| 31 | |
| 32 | if [ $? -eq 0 ] && [ -f $RF ]; then |
| 33 | OS_NAME="$NAME" |
| 34 | if ! grep "os_name: $OS_NAME" "$LOGFILE" > /dev/null; then |
| 35 | echo "os_name should be `uname -s`" |
| 36 | ret_val=$[$ret_val + 1] |
| 37 | fi |
| 38 | |
| 39 | OS_VERSION="$VERSION" |
| 40 | if ! grep "os_version: ${OS_VERSION}" "$LOGFILE" > /dev/null; then |
| 41 | echo "os_version should be ${OS_VERSION}" |
| 42 | ret_val=$[$ret_val + 1] |
| 43 | fi |
| 44 | |
| 45 | OS_ARCHITECTURE="`uname -m`" |
| 46 | if ! grep "os_architecture: ${OS_ARCHITECTURE}" "$LOGFILE" > /dev/null; then |
| 47 | echo "os_architecture should be ${OS_ARCHITECTURE}" |
| 48 | ret_val=$[$ret_val + 1] |
| 49 | fi |
| 50 | |
| 51 | PRIMARY_HOST_NAME="`uname -n`" |
| 52 | if ! grep "primary_host_name: ${PRIMARY_HOST_NAME}" "$LOGFILE" > /dev/null; then |
| 53 | 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 [ ! $ret_val -eq 0 ]; then |
| 60 | echo "---------------------------------------" |
| 61 | cat "$LOGFILE" |
| 62 | echo "---------------------------------------" |
| 63 | ret_val=2 |
| 64 | fi |
| 65 | else |
| 66 | echo "Unable to probe system characteristics!" |
| 67 | echo "" |
| 68 | ret_val=1 |
| 69 | fi |
| 70 | |
| 71 | return $ret_val |
| 72 | } |
| 73 | |
| 74 | # Testing. |
| 75 | |
| 76 | test_init |
| 77 | |
| 78 | if [ -z ${CUSTOM_OSCAP+x} ] ; then |
| 79 | test_run "test_probes_system_info" test_probes_system_info |
| 80 | fi |
| 81 | |
| 82 | test_exit |