Skip to content

Commit

Permalink
test: new test to verify multiple queries according to .conf
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Feb 3, 2022
1 parent 8b1d32a commit 277583e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ TEST_EXTENSIONS = .sh
TESTS_ENVIRONMENT = unshare -mrun

TESTS = basic.sh
TESTS += two.sh
58 changes: 58 additions & 0 deletions test/two.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF > "/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

0 comments on commit 277583e

Please sign in to comment.