-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: new test to verify multiple queries according to .conf
Signed-off-by: Joachim Wiberg <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ TEST_EXTENSIONS = .sh | |
TESTS_ENVIRONMENT = unshare -mrun | ||
|
||
TESTS = basic.sh | ||
TESTS += two.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |