]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
tests: check_klog.sh: unclutter stderr
authorFlorian Westphal <fw@strlen.de>
Thu, 9 Jul 2026 20:03:55 +0000 (22:03 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 13 Jul 2026 13:23:47 +0000 (15:23 +0200)
My test vm doesn't have a kern.log file, but the existing
script will fall back to dmesg which is good enough for me.

Suppress the 'no such file' error from tail and go straight
to the dmesg fallback.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
tests/check_klog.sh
tests/sendip.sh

index 8ecad3eb987e6147662e54e78becc5203885493b..bc602be839aad1b8e1b08d8bf9f2fb7b16236b16 100755 (executable)
@@ -44,7 +44,12 @@ 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 [ -r /var/log/kern.log ]; then
+               match=`tail -n +$loglines /var/log/kern.log | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"`
+       else
+               match=""
+       fi
+
        if [ -z "$match" ]; then
                match=`dmesg | tail -n +$loglines | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"`
        fi
index f80b24ab49b86183dc2ba7118f93f5314cc29743..d1f8ebe4d75b1a9aac1703e459d2a7395775dce8 100755 (executable)
@@ -1,6 +1,5 @@
 #!/bin/bash
 
 # Save lineno for checking
-wc -l /var/log/kern.log | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines"
+wc -l /var/log/kern.log 2>/dev/null | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines"
 sendip "$@"
-