From 277583e4f2f6d77eec1561215cc618fde6194429 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 3 Feb 2022 15:51:53 +0100 Subject: [PATCH] test: new test to verify multiple queries according to .conf Signed-off-by: Joachim Wiberg --- test/Makefile.am | 1 + test/two.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 test/two.sh diff --git a/test/Makefile.am b/test/Makefile.am index cd12f18..86389d2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -5,3 +5,4 @@ TEST_EXTENSIONS = .sh TESTS_ENVIRONMENT = unshare -mrun TESTS = basic.sh +TESTS += two.sh diff --git a/test/two.sh b/test/two.sh new file mode 100755 index 0000000..64c7927 --- /dev/null +++ b/test/two.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Verifies proper parsing of .conf file, and operation wrt two queries +# in the given time frame. TODO: check delta between queries. + +# shellcheck source=/dev/null +. "$(dirname "$0")/lib.sh" + +# Requires ethtool to disable UDP checksum offloading +print "Check deps ..." +check_dep tshark + +print "Creating world ..." +for iface in eth0 eth1 eth3 eth4; do + ip link add $iface type dummy + ip link set $iface up + ip link set $iface multicast on +done +ip addr add 192.168.0.1/24 dev eth0 +ip addr add 192.168.1.1/24 dev eth1 +ip addr add 192.168.1.2/24 dev eth1 +ip addr add 192.168.3.1/24 dev eth1 +ip addr add 192.168.2.1/24 dev eth2 + +ip -br l +ip -br a + +print "Creating config ..." +cat < "/tmp/$NM/config" +query-interval 5 +iface eth0 enable igmpv3 +iface eth1 enable igmpv3 +EOF + +print "Starting collector(s) ..." +tshark -lni eth0 -w "/tmp/$NM/eth0.pcap" 2>/dev/null & +echo $! >> "/tmp/$NM/PIDs" +tshark -lni eth1 -w "/tmp/$NM/eth1.pcap" 2>/dev/null & +echo $! >> "/tmp/$NM/PIDs" +sleep 1 + +print "Starting querierd ..." +../src/querierd -f "/tmp/$NM/config" -l debug -n & +echo $! >> "/tmp/$NM/PIDs" + +sleep 6 +kill_pids + +print "Analyzing pcap ..." +lines1=$(tshark -n -r "/tmp/$NM/eth0.pcap" 2>/dev/null | grep "IGMPv3 50 Membership Query" | tee -a "/tmp/$NM/result" | wc -l) +lines2=$(tshark -n -r "/tmp/$NM/eth1.pcap" 2>/dev/null | grep "IGMPv3 50 Membership Query" | tee -a "/tmp/$NM/result" | wc -l) +cat "/tmp/$NM/result" + +echo " => $lines1 IGMP Query on eth0, expected 2" +echo " => $lines2 IGMP Query on eth1, expected 2" +# shellcheck disable=SC2086 disable=SC2166 +[ $lines1 -eq 2 -a $lines2 -eq 2 ] || FAIL + +OK