diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2020-12-02 13:49:03 -0500 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2020-12-11 11:09:06 -0500 |
commit | bc237190e7a7ce4d47d6b1f4a75b2d96b34a19f8 (patch) | |
tree | ec03902cc0594b552febdd316786e737b1fe5555 /tests/simple.sh | |
parent | b548ac15c56b6c9efe82743a6c51333e1d56a58d (diff) | |
download | sos-bc237190e7a7ce4d47d6b1f4a75b2d96b34a19f8.tar.gz |
[tests] Add test for newly loaded kernel modules
Adds a test to `simple.sh` to check if we loaded any new kernel modules
during a normal exeuction. This test will be somewhat limited in the
fact that this currently only tests the plugins that are loaded by
default on each tested distribution.
Also included is a minor typo fix for reporting where IP addresses were
not obfuscated, if any. This typo did not affect the actual test
however.
Resolves: #2326
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/simple.sh')
-rwxr-xr-x | tests/simple.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/simple.sh b/tests/simple.sh index 73436014..f1d530dc 100755 --- a/tests/simple.sh +++ b/tests/simple.sh @@ -1,3 +1,4 @@ +#!/bin/bash # This file is part of the sos project: https://github.com/sosreport/sos # # This copyrighted material is made available to anyone wishing to use, @@ -5,7 +6,6 @@ # version 2 of the GNU General Public License. # # See the LICENSE file in the source distribution for further information. -#/bin/bash # A quick port of the travis tests to bash, requires root # TODO # * look into using a framework.. @@ -101,6 +101,8 @@ add_failure () { # Test a no frills run with verbosity and make sure the expected items exist test_normal_report () { cmd="-vvv" + # get a list of initial kmods loaded + kmods=( $(lsmod | cut -f1 -d ' ' | sort) ) run_expecting_success "$cmd" extract if [ $? -eq 0 ]; then if [ ! -f /var/tmp/sosreport_test/sos_reports/sos.html ]; then @@ -115,6 +117,12 @@ test_normal_report () { if [ ! "$(grep "DEBUG" /var/tmp/sosreport_test/sos_logs/sos.log)" ]; then add_failure "did not find debug logging when using -vvv" fi + # new list, see if we added any + new_kmods=( $(lsmod | cut -f1 -d ' ' | sort) ) + if [ "$(printf '%s\n' "${kmods[@]}" "${new_kmods[@]}" | sort | uniq -u)" ]; then + add_failure "new kernel modules loaded during execution" + echo "$(printf '%s\n' "${kmods[@]}" "${new_kmods[@]}" | sort | uniq -u)" + fi update_failures update_summary "$cmd" fi @@ -163,7 +171,7 @@ test_mask () { ip_addr=$(ip route show default | awk '/default/ {print $3}') if [ "$(grep -rI $ip_addr /var/tmp/sosreport_test/*)" ]; then add_failure "IP address not obfuscated in all places" - echo "$grep -rI $ip_addr /var/tmp/sosreport/_test/*)" + echo "$(grep -rI $ip_addr /var/tmp/sosreport/_test/*)" fi update_failures fi |