Add a test for rawshark.

svn path=/trunk/; revision=51494
This commit is contained in:
Gerald Combs 2013-08-23 18:54:22 +00:00
parent a4a6af3c5a
commit a8c728533d
3 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,5 @@
1 1 -
2 1 -
3 1 -
4 1 -

View File

@ -32,6 +32,13 @@ else
WS_SYSTEM=`uname -s`
fi
#
#
ENDIANNESS="little"
echo -n I | od -to2 | awk '{ lastbit = substr($2,6,1); exit lastbit }'
if [ $? -eq 0 ] ; then
ENDIANNESS="big"
fi
# Path to the Wireshark binaries, only used for the settings below
WS_BIN_PATH=..
@ -48,6 +55,7 @@ fi
# Tweak the following to your liking.
WIRESHARK=$WS_BIN_PATH/wireshark
TSHARK=$WS_BIN_PATH/tshark
RAWSHARK=$WS_BIN_PATH/rawshark
CAPINFOS=$WS_BIN_PATH/capinfos
DUMPCAP=$WS_BIN_PATH/dumpcap

View File

@ -29,6 +29,8 @@ EXIT_OK=0
EXIT_COMMAND_LINE=1
EXIT_ERROR=2
IO_RAWSHARK_DHCP_PCAP_BASELINE=./baseline/io-rawshark-dhcp-pcap.txt
IO_RAWSHARK_DHCP_PCAP_TESTOUT=./io-rawshark-dhcp-pcap-testout.txt
# input of file
io_step_input_file() {
@ -121,10 +123,28 @@ io_step_input_piping() {
cat ./testout.txt
cat ./testout2.txt
$TSHARK -D
test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
test_step_failed "No or not enough traffic captsured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
fi
}
# Read a pcap from stdin
io_step_rawshark_pcap_stdin() {
if [ $ENDIANNESS != "little" ] ; then
test_step_skipped
return
fi
tail -c +25 "${CAPTURE_DIR}dhcp.pcap" | $RAWSHARK -dencap:1 -R "udp.port==68" -nr - > $IO_RAWSHARK_DHCP_PCAP_TESTOUT 2> /dev/null
diff -u $IO_RAWSHARK_DHCP_PCAP_BASELINE $IO_RAWSHARK_DHCP_PCAP_TESTOUT > $DIFF_OUT 2>&1
RETURNVALUE=$?
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
test_step_failed "Output of rawshark read pcap via stdin differs from baseline"
cat $DIFF_OUT
return
fi
test_step_ok
}
wireshark_io_suite() {
# Q: quit after cap, k: start capture immediately
DUT="$WIRESHARK"
@ -145,11 +165,16 @@ dumpcap_io_suite() {
test_step_add "Input file" io_step_input_file
}
rawshark_io_suite() {
test_step_add "Rawshark pcap stdin" io_step_rawshark_pcap_stdin
}
io_cleanup_step() {
rm -f ./testout.txt
rm -f ./testout2.txt
rm -f ./testout.pcap
rm -f ./testout2.pcap
rm -f $IO_RAWSHARK_DHCP_PCAP_TESTOUT
}
io_suite() {
@ -158,6 +183,7 @@ io_suite() {
test_suite_add "TShark file I/O" tshark_io_suite
#test_suite_add "Wireshark file I/O" wireshark_io_suite
#test_suite_add "Dumpcap file I/O" dumpcap_io_suite
test_suite_add "Rawshark file I/O" rawshark_io_suite
}
#
# Editor modelines - http://www.wireshark.org/tools/modelines.html