More licenses converted to SPDX.
[metze/wireshark/wip.git] / test / config.sh
1 #!/bin/bash
2 #
3 # Configuration of the command line tests
4 #
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 2005 Ulf Lamping
8 #
9 # SPDX-License-Identifier: GPL-2.0-or-later
10 #
11
12 # The files we want to test are in the build directory.
13 WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1
14 export WIRESHARK_RUN_FROM_BUILD_DIRECTORY
15
16 # Set WS_SYSTEM to our system type, e.g. Windows, Linux, Darwin
17 # http://support.microsoft.com/kb/100843
18 if [ -n "${OS#Windows}" ] ; then
19         WS_SYSTEM="Windows"
20         export CYGWIN="$CYGWIN error_start=c:\cygwin\bin\dumper.exe -d %1 %2"
21 else
22         WS_SYSTEM=`uname -s`
23 fi
24
25 #
26 #
27 ENDIANNESS="little"
28 echo -n I | od -to2 | awk '{ lastbit = substr($2,6,1); exit lastbit }'
29 if [ $? -eq 0 ] ; then
30         ENDIANNESS="big"
31 fi
32
33 # Absolute path to the source tree
34 SOURCE_DIR="$(cd "$(dirname "$0")" && cd .. && pwd)"
35
36 # Absolute path to this test directory (for capture and config files)
37 TESTS_DIR="$SOURCE_DIR/test"
38
39 # Are we allowed to open interfaces or capture on this system?
40 SKIP_CAPTURE=${SKIP_CAPTURE:-1}
41
42 # Override the last two items if we're running Windows
43 if [ "$WS_SYSTEM" = "Windows" ] ; then
44         WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR/wireshark-gtk2}
45         WS_QT_BIN_PATH=${WS_QT_BIN_PATH:-$SOURCE_DIR/wireshark-qt-release}
46         SKIP_CAPTURE=0
47 fi
48
49 # Path to the Wireshark binaries, default to source dir if unset
50 WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR}
51 WS_QT_BIN_PATH=${WS_QT_BIN_PATH:-$WS_BIN_PATH}
52
53 # Tweak the following to your liking.
54 WIRESHARK=$WS_QT_BIN_PATH/wireshark
55 WIRESHARK_GTK=$WS_BIN_PATH/wireshark-gtk
56 TSHARK=$WS_BIN_PATH/tshark
57 RAWSHARK=$WS_BIN_PATH/rawshark
58 CAPINFOS=$WS_BIN_PATH/capinfos
59 MERGECAP=$WS_BIN_PATH/mergecap
60 TEXT2PCAP=$WS_BIN_PATH/text2pcap
61 DUMPCAP=$WS_BIN_PATH/dumpcap
62
63 # interface with at least a few packets/sec traffic on it
64 # (e.g. start a web radio to generate some traffic :-)
65 # an interfaces index (1 based) should do well for recent devbuilds
66 if [ "$WS_SYSTEM" = "Windows" -a -z "$TRAFFIC_CAPTURE_IFACE" ] ; then
67         # Try to fetch the first Ethernet interface.
68         TRAFFIC_CAPTURE_IFACE=`$TSHARK -D 2>&1 | \
69                 egrep 'Ethernet|Network Connection|VMware|Intel|Realtek' | \
70                 head -1 | cut -c 1`
71 fi
72 TRAFFIC_CAPTURE_IFACE=${TRAFFIC_CAPTURE_IFACE:-1}
73
74 # time to capture some traffic (in seconds)
75 # (you may increase this if you get errors caused by very low traffic)
76 TRAFFIC_CAPTURE_DURATION=10
77
78 # the default is to not capture in promiscuous mode
79 # (this makes known trouble with some Windows WLAN adapters)
80 # if you need promiscuous mode, comment this line out
81 TRAFFIC_CAPTURE_PROMISC=-p
82
83 # only test capturing from a fifo if we're not on Windows
84 #  and we have a mkfifo. (Windows cygwin has a mkfifo but
85 #   Windows dumpcap & etc use Windows named pipes which
86 #   are different than the cygwin named pipes).
87 #
88 if [ "$WS_SYSTEM" != "Windows" ] && which mkfifo &>/dev/null ; then
89         TEST_FIFO=1
90 fi
91
92 # Tell Wireshark to quit after capuring packets.
93 export WIRESHARK_QUIT_AFTER_CAPTURE="True"
94
95 CAPTURE_DIR="$TESTS_DIR/captures/"
96
97 TSHARK_VERSION=$($TSHARK -v | tr '\n' ' ')
98
99 # Figure out if we were built with lua or not so we can skip the lua tests if we
100 # don't have it.
101 echo "$TSHARK_VERSION" | grep -q "with Lua"
102 HAVE_LUA=$?
103
104 # Check whether we need to skip the HTTP2/HPACK decryption test.
105 echo "$TSHARK_VERSION" | grep -q "with nghttp2"
106 HAVE_NGHTTP2=$?
107
108 # Check whether we need to skip a certain decryption test.
109 # XXX What do we print for Nettle?
110 echo "$TSHARK_VERSION" | egrep -q "with MIT Kerberos|with Heimdal Kerberos"
111 HAVE_KERBEROS=$?
112
113 # first version is "compiled with", second is "running on" version.
114 GCRY_VERSION=$(echo "$TSHARK_VERSION" | grep -oE 'Gcrypt [1-9]+(\.[1-9]+)?' | sed -n '1s/Gcrypt //p')
115 if [ -n "$GCRY_VERSION" ] && ! echo "$GCRY_VERSION" | grep -q '1\.[456]'; then
116         # Current minimum Gcrypt version is 1.4.2,
117         # assume 1.7 or newer if not 1,4, 1.5 or 1.6.
118         HAVE_LIBGCRYPT17=true
119 else
120         HAVE_LIBGCRYPT17=false
121 fi
122
123 HAVE_ICONV="False"
124 hash iconv 2>/dev/null && HAVE_ICONV="True"
125
126 # Display our environment
127
128 ##printf "\n ------- Info =-----------------\n"
129 ##printf "Syms :$WS_SYSTEM: :$TRAFFIC_CAPTURE_IFACE: :$SKIP_CAPTURE: :$TEST_FIFO:\n"
130 ##
131 ##ls -l $WIRESHARK $TSHARK $DUMPCAP
132 ##ls -l $(which wireshark) $(which tshark) $(which dumpcap)
133 ##printf " ----------------------------------\n\n"
134
135 # Editor modelines
136 #
137 # Local Variables:
138 # sh-basic-offset: 8
139 # tab-width: 8
140 # indent-tabs-mode: t
141 # End:
142 #
143 # ex: set shiftwidth=8 tabstop=8 noexpandtab:
144 # :indentSize=8:tabSize=8:noTabs=false: