summaryrefslogtreecommitdiffstats
path: root/tests/check_klog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_klog.sh')
-rwxr-xr-xtests/check_klog.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/check_klog.sh b/tests/check_klog.sh
new file mode 100755
index 0000000..489fa71
--- /dev/null
+++ b/tests/check_klog.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# set -x
+set -e
+
+# arguments: ipaddr proto port setname ...
+
+expand_ipv6() {
+ # incomplete, but for our addresses it's OK
+ addr=
+ n=0
+ while read a; do
+ n=$((n+1))
+ if [ -z "$a" ]; then
+ addr="$addr::"
+ else
+ case `echo $a | wc -c` in
+ 4) a="0$a";;
+ 3) a="00$a";;
+ 2) a="000$a";;
+ esac
+ addr="$addr$a:"
+ fi
+ done < <(echo $1 | tr : '\n')
+ addr=`echo $addr | sed -e 's/:$//'`
+ null=
+ while [ $n -le 8 ]; do
+ null="$null:0000"
+ n=$((n+1))
+ done
+ addr=`echo $addr | sed -e "s/::/$null/"`
+ echo $addr
+}
+
+ipaddr=`expand_ipv6 $1`; shift
+proto=`echo $1 | tr a-z A-Z`; shift
+port=$1; shift
+
+for setname in $@; do
+ match=`grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*" /var/log/kern.log`
+ if [ -z "$match" ]; then
+ echo "no match!"
+ exit 1
+ fi
+done
+exit 0