3 # Test the file I/O of the Ethereal 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 # common exit status values
34 io_step_input_file() {
35 $DUT -r 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 -i 'Number of packets: 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 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 -i 'Number of packets: 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 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 -i 'Number of packets: 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 ethereal_io_suite() {
129 # Q: quit after cap, k: start capture immediately
131 test_step_add "Input file" io_step_input_file
134 tethereal_io_suite() {
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 "Tethereal file I/O" tethereal_io_suite
159 #test_suite_add "Ethereal file I/O" ethereal_io_suite
160 #test_suite_add "Dumpcap file I/O" dumpcap_io_suite