diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-08-23 18:54:22 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-08-23 18:54:22 +0000 |
commit | a8c728533d112dcbd39ee510c94c78ef4699ba72 (patch) | |
tree | 4b849f2961ece3ae2471c6a6db14e7b851973e7c /test | |
parent | a4a6af3c5a3245d26245c86cb001b5bc7b7e74b3 (diff) | |
download | wireshark-a8c728533d112dcbd39ee510c94c78ef4699ba72.tar.gz wireshark-a8c728533d112dcbd39ee510c94c78ef4699ba72.tar.bz2 wireshark-a8c728533d112dcbd39ee510c94c78ef4699ba72.zip |
Add a test for rawshark.
svn path=/trunk/; revision=51494
Diffstat (limited to 'test')
-rwxr-xr-x | test/baseline/io-rawshark-dhcp-pcap.txt | 5 | ||||
-rwxr-xr-x | test/config.sh | 8 | ||||
-rwxr-xr-x | test/suite-io.sh | 28 |
3 files changed, 40 insertions, 1 deletions
diff --git a/test/baseline/io-rawshark-dhcp-pcap.txt b/test/baseline/io-rawshark-dhcp-pcap.txt new file mode 100755 index 0000000000..c6fd02080d --- /dev/null +++ b/test/baseline/io-rawshark-dhcp-pcap.txt @@ -0,0 +1,5 @@ + +1 1 - +2 1 - +3 1 - +4 1 - diff --git a/test/config.sh b/test/config.sh index d833503914..872bdbfe3b 100755 --- a/test/config.sh +++ b/test/config.sh @@ -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 diff --git a/test/suite-io.sh b/test/suite-io.sh index 79a9d573e0..b6fe2bd6f8 100755 --- a/test/suite-io.sh +++ b/test/suite-io.sh @@ -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 |