tests/check_klog.sh: Try dmesg too, don't let shell terminate script
authorStefano Brivio <sbrivio@redhat.com>
Tue, 8 May 2018 15:43:30 +0000 (17:43 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 30 May 2018 08:13:32 +0000 (10:13 +0200)
Some hosts might not use /var/log/kern.log for kernel messages,
so if we can't find a match there, try dmesg next.

If no matches are found, don't let the shell terminate the
script, so that we have a chance to try dmesg and actually echo
"no match!" if no matches are found: set +e before the setname
loop.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
tests/check_klog.sh

index 146e492b27706417b858a7fff711ffbfb69d2a19..9af5f66f28eb2e0b1bd54a183d746ff717d959ae 100755 (executable)
@@ -42,8 +42,12 @@ ipaddr=`expand_ipv6 $1`; shift
 proto=`echo $1 | tr a-z A-Z`; shift
 port=$1; shift
 
+set +e
 for setname in $@; do
        match=`tail -n +$loglines /var/log/kern.log | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"`
+       if [ -z "$match" ]; then
+               match=`dmesg | tail -n +$loglines | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"`
+       fi
        if [ -z "$match" ]; then
                echo "no match!"
                exit 1