[PATCH ipset 4/7] tests: check_klog.sh: unclutter stderr
Florian Westphal <[email protected]>
| Newsgroups | gmane.comp.security.firewalls.netfilter.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- tests/check_klog.sh | 7 ++++++- tests/sendip.sh | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/check_klog.sh b/tests/check_klog.sh index 8ecad3eb987e..bc602be839aa 100755 --- a/tests/check_klog.sh +++ b/tests/check_klog.sh @@ -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 diff --git a/tests/sendip.sh b/tests/sendip.sh index f80b24ab49b8..d1f8ebe4d75b 100755 --- a/tests/sendip.sh +++ b/tests/sendip.sh @@ -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 "$@" - -- 2.54.0