list the new file format on the manpage
[metze/wireshark/wip.git] / test / suite-fileformats.sh
1 #!/bin/bash
2 #
3 # Test file format conversions of the Wireshark tools
4 #
5 # $Id$
6 #
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 2005 Ulf Lamping
10 #
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.
15 #
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.
20 #
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.
24 #
25
26
27 # common exit status values
28 EXIT_OK=0
29 EXIT_COMMAND_LINE=1
30 EXIT_ERROR=2
31
32 TS_FF_ARGS="-Tfields -e frame.number -e frame.time_epoch -e frame.time_delta"
33
34 FF_BASELINE=./ff-ts-usec-pcap-direct.txt
35 DIFF_OUT=./diff-output.txt
36
37 # Microsecond pcap / stdin
38 ff_step_usec_pcap_stdin() {
39         $TSHARK $TS_FF_ARGS -i - < "${CAPTURE_DIR}dhcp.pcap" > ./ff-ts-usec-pcap-stdin.txt 2> /dev/null
40         diff -u $FF_BASELINE ./ff-ts-usec-pcap-stdin.txt > $DIFF_OUT 2>&1
41         RETURNVALUE=$?
42         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
43                 test_step_failed "Output of microsecond pcap direct read vs microsecond pcap via stdin differ"
44                 cat $DIFF_OUT
45                 return
46         fi
47         test_step_ok
48 }
49
50 # Nanosecond pcap / stdin
51 ff_step_nsec_pcap_stdin() {
52         $TSHARK $TS_FF_ARGS -i - < "${CAPTURE_DIR}dhcp-nanosecond.pcap" > ./ff-ts-nsec-pcap-stdin.txt 2> /dev/null
53         diff -u $FF_BASELINE ./ff-ts-nsec-pcap-stdin.txt > $DIFF_OUT 2>&1
54         RETURNVALUE=$?
55         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
56                 test_step_failed "Output of microsecond pcap direct read vs nanosecond pcap via stdin differ"
57                 cat $DIFF_OUT
58                 return
59         fi
60         test_step_ok
61 }
62
63 # Nanosecond pcap / direct
64 ff_step_nsec_pcap_direct() {
65         $TSHARK $TS_FF_ARGS -r "${CAPTURE_DIR}dhcp-nanosecond.pcap" > ./ff-ts-nsec-pcap-direct.txt 2> /dev/null
66         diff -u $FF_BASELINE ./ff-ts-nsec-pcap-direct.txt > $DIFF_OUT 2>&1
67         RETURNVALUE=$?
68         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
69                 test_step_failed "Output of microsecond pcap direct read vs nanosecond pcap direct read differ"
70                 cat $DIFF_OUT
71                 return
72         fi
73         test_step_ok
74 }
75
76 # Microsecond pcap-ng / stdin
77 ff_step_usec_pcapng_stdin() {
78         $TSHARK $TS_FF_ARGS -i - < "${CAPTURE_DIR}dhcp.pcapng" > ./ff-ts-usec-pcapng-stdin.txt 2> /dev/null
79         diff -u $FF_BASELINE ./ff-ts-usec-pcapng-stdin.txt > $DIFF_OUT 2>&1
80         RETURNVALUE=$?
81         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
82                 test_step_failed "Output of microsecond pcap direct read vs microsecond pcap-ng via stdin differ"
83                 cat $DIFF_OUT
84                 return
85         fi
86         test_step_ok
87 }
88
89 # Microsecond pcap-ng / direct
90 ff_step_usec_pcapng_direct() {
91         $TSHARK $TS_FF_ARGS -r "${CAPTURE_DIR}dhcp.pcapng" > ./ff-ts-usec-pcapng-direct.txt 2> /dev/null
92         diff -u $FF_BASELINE ./ff-ts-usec-pcapng-direct.txt > $DIFF_OUT 2>&1
93         RETURNVALUE=$?
94         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
95                 test_step_failed "Output of microsecond pcap direct read vs microsecond pcap-ng direct read differ"
96                 cat $DIFF_OUT
97                 return
98         fi
99         test_step_ok
100 }
101
102 # Nanosecond pcap-ng / stdin
103 ff_step_nsec_pcapng_stdin() {
104         $TSHARK $TS_FF_ARGS -i - < "${CAPTURE_DIR}dhcp-nanosecond.pcapng" > ./ff-ts-nsec-pcapng-stdin.txt 2> /dev/null
105         diff -u $FF_BASELINE ./ff-ts-nsec-pcapng-stdin.txt > $DIFF_OUT 2>&1
106         RETURNVALUE=$?
107         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
108                 test_step_failed "Output of microsecond pcap direct read vs nanosecond pcap-ng via stdin differ"
109                 cat $DIFF_OUT
110                 return
111         fi
112         test_step_ok
113 }
114
115 # Nanosecond pcap-ng / direct
116 ff_step_nsec_pcapng_direct() {
117         $TSHARK $TS_FF_ARGS -r "${CAPTURE_DIR}dhcp-nanosecond.pcapng" > ./ff-ts-nsec-pcapng-direct.txt 2> /dev/null
118         diff -u $FF_BASELINE ./ff-ts-nsec-pcapng-direct.txt > $DIFF_OUT 2>&1
119         RETURNVALUE=$?
120         if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
121                 test_step_failed "Output of microsecond pcap direct read vs nanosecond pcap-ng direct read differ"
122                 cat $DIFF_OUT
123                 return
124         fi
125         test_step_ok
126 }
127
128 tshark_ff_suite() {
129         # Microsecond pcap direct read is used as the baseline.
130         test_step_add "Microsecond pcap via stdin" ff_step_usec_pcap_stdin
131         test_step_add "Nanosecond pcap via stdin" ff_step_nsec_pcap_stdin
132         test_step_add "Nanosecond pcap direct read" ff_step_nsec_pcap_direct
133 #       test_step_add "Microsecond pcap-ng via stdin" ff_step_usec_pcapng_stdin
134         test_step_add "Microsecond pcap-ng direct read" ff_step_usec_pcapng_direct
135 #       test_step_add "Nanosecond pcap-ng via stdin" ff_step_nsec_pcapng_stdin
136         test_step_add "Nanosecond pcap-ng direct read" ff_step_nsec_pcapng_direct
137 }
138
139 ff_cleanup_step() {
140         rm -f ./ff-ts-*.txt
141         rm -f $DIFF_OUT
142 }
143
144 ff_prep_step() {
145         ff_cleanup_step
146         $TSHARK $TS_FF_ARGS -r "${CAPTURE_DIR}dhcp.pcap" > $FF_BASELINE 2> /dev/null
147 }
148
149 fileformats_suite() {
150         test_step_set_pre ff_prep_step
151         test_step_set_post ff_cleanup_step
152         test_suite_add "TShark file format conversion" tshark_ff_suite
153         #test_suite_add "Wireshark file format" wireshark_ff_suite
154         #test_suite_add "Editcap file format" editcap_ff_suite
155 }
156 #
157 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
158 #
159 # Local variables:
160 # c-basic-offset: 8
161 # tab-width: 8
162 # indent-tabs-mode: t
163 # End:
164 #
165 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
166 # :indentSize=8:tabSize=8:noTabs=false:
167 #