-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework tests to actually check something
- Loading branch information
Showing
3 changed files
with
67 additions
and
15 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
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 |
---|---|---|
@@ -1,22 +1,50 @@ | ||
#!/bin/bash -e | ||
if=dummy0 | ||
if [ ! -e /sys/class/net/$if ]; then | ||
ip l add $if type dummy | ||
ip l set $if up | ||
ip r add 100::/64 dev $if | ||
fi | ||
pcap=test.pcap | ||
log=out.txt | ||
|
||
args=( | ||
--interface $if | ||
--quiet | ||
--interface "dump:$pcap" | ||
--source-mac 02:00:00:00:00:f0 | ||
--router-mac 02-00-00-00-00-0F | ||
--source-ip 2001:db8::1 | ||
--source-port 64000 | ||
) | ||
|
||
echo "ICMP:" | ||
./fi6s "${args[@]}" --icmp 100::x | ||
echo "TCP:" | ||
./fi6s "${args[@]}" -b -p 1 100::x | ||
echo "UDP:" | ||
./fi6s "${args[@]}" -bu -p 53 100::x | ||
ecode=0 | ||
dotest () { | ||
echo "=== Running test: $id ===" | ||
./fi6s "${args[@]}" "${args2[@]}" || : | ||
tcpdump -nn -v -r "$pcap" >$log 2>/dev/null | ||
if ! grep -aP "$regex" $log; then | ||
echo "FAILED, actual dump:" | ||
cat $log | ||
ecode=1 | ||
else | ||
echo "Passed." | ||
fi | ||
echo | ||
} | ||
|
||
## | ||
|
||
id="ICMP" | ||
args2=(--icmp 100::x) | ||
regex='2001:db8::1 > 100::a: \[icmp6 sum ok\] ICMP6, echo request' | ||
dotest | ||
|
||
id="TCP" | ||
args2=(-b -p 1 100::x) | ||
regex='2001:db8::1\.64000 > 100::b\.1: Flags \[S\], cksum [^ ]+ \(correct\).*, length 0' | ||
dotest | ||
|
||
id="UDP 53" | ||
args2=(-bu -p 53 100::x) | ||
regex='2001:db8::1\.64000 > 100::c\.53: \[udp sum ok\] [^ ]+ TXT [^ ]+ version\.bind\.' | ||
dotest | ||
|
||
## | ||
|
||
echo "=== Done ===" | ||
rm -f $pcap $log | ||
exit $ecode |
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,14 @@ | ||
#!/bin/bash -e | ||
args=( | ||
--interface lo | ||
--router-mac 01:01:01:01:01:01 | ||
--source-ip ::1 | ||
) | ||
|
||
./fi6s "${args[@]}" --icmp ::1 | tee out.txt | ||
if ! grep -q "^icmp up 0 ::1 " out.txt; then | ||
echo "FAILED!" | ||
exit 1 | ||
fi | ||
echo "Passed." | ||
exit 0 |