3 # Test the file I/O of the Wireshark tools
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 2005 Ulf Lamping
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 # common exit status values
34 io_step_input_file() {
35 $DUT -r "${CAPTURE_DIR}dhcp.pcap" -w ./testout.pcap > ./testout.txt 2>&1
37 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
38 test_step_failed "exit status of $DUT: $RETURNVALUE"
39 # part of the Prerequisite checks
40 # probably wrong interface, output the possible interfaces
45 # we should have an output file now
46 if [ ! -f "./testout.pcap" ]; then
47 test_step_failed "No output file!"
51 # ok, we got a capture file, does it contain exactly 10 packets?
52 $CAPINFOS ./testout.pcap > ./testout.txt
53 grep -Ei 'Number of packets:[[:blank:]]+4' ./testout.txt > /dev/null
59 # part of the Prerequisite checks
60 # probably wrong interface, output the possible interfaces
62 test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
66 # piping input file to stdout using "-w -"
67 io_step_output_piping() {
68 $DUT -r "${CAPTURE_DIR}dhcp.pcap" -w - > ./testout.pcap 2>./testout.txt
70 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
71 test_step_failed "exit status of $DUT: $RETURNVALUE"
76 # we should have an output file now
77 if [ ! -f "./testout.pcap" ]; then
78 test_step_failed "No output file!"
82 # ok, we got a capture file, does it contain exactly 10 packets?
83 $CAPINFOS ./testout.pcap > ./testout2.txt 2>&1
84 grep -Ei 'Number of packets:[[:blank:]]+4' ./testout2.txt > /dev/null
92 test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
96 # piping input file to stdout using "-w -"
97 io_step_input_piping() {
98 cat -B "${CAPTURE_DIR}dhcp.pcap" | $DUT -r - -w ./testout.pcap 2>./testout.txt
100 if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
104 test_step_failed "exit status of $DUT: $RETURNVALUE"
108 # we should have an output file now
109 if [ ! -f "./testout.pcap" ]; then
110 test_step_failed "No output file!"
114 # ok, we got a capture file, does it contain exactly 10 packets?
115 $CAPINFOS ./testout.pcap > ./testout2.txt 2>&1
116 grep -Ei 'Number of packets:[[:blank:]]+4' ./testout2.txt > /dev/null
117 if [ $? -eq 0 ]; then
124 test_step_failed "No or not enough traffic captured. Probably the wrong interface: $TRAFFIC_CAPTURE_IFACE!"
128 wireshark_io_suite() {
129 # Q: quit after cap, k: start capture immediately
131 test_step_add "Input file" io_step_input_file
136 test_step_add "Input file" io_step_input_file
137 test_step_add "Output piping" io_step_output_piping
138 #test_step_add "Piping" io_step_input_piping
145 test_step_add "Input file" io_step_input_file
152 rm -f ./testout2.pcap
156 test_step_set_pre io_cleanup_step
157 test_step_set_post io_cleanup_step
158 test_suite_add "TShark file I/O" tshark_io_suite
159 #test_suite_add "Wireshark file I/O" wireshark_io_suite
160 #test_suite_add "Dumpcap file I/O" dumpcap_io_suite
163 # Editor modelines - http://www.wireshark.org/tools/modelines.html
168 # indent-tabs-mode: t
171 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
172 # :indentSize=8:tabSize=8:noTabs=false: