wireshark/test
John Thacker e972a755d2 dfilter: Handle null arguments to min, max
min and max need to handle null arguments where the GPtrArray
is null, generated when there have been other opcodes between
the field loading and the function. (They are ignored, not
treated as zero, so they don't change the minimum.)

Prevents crashes with filters where a field does not exist in the tree:

min(tcp.srcport * 10, tcp.dstport * 10) == 800
min(len(tcp.payload), len(udp.payload)) == 153
min(len(tcp.payload[2:]) + 2, len(udp.payload[2:]) + 2) == 153

where a register is loaded where it has not had its GPtrArray created:

./run/dftest 'min(len(tcp.payload), len(udp.payload))'
Filter:
 min(len(tcp.payload), len(udp.payload))

Instructions:
 0000 READ_TREE        tcp.payload      -> R1
 0001 IF_FALSE_GOTO    3
 0002 LENGTH           R1               -> R2
 0003 STACK_PUSH       R2
 0004 READ_TREE        udp.payload      -> R3
 0005 IF_FALSE_GOTO    7
 0006 LENGTH           R3               -> R4
 0007 STACK_PUSH       R4
 0008 CALL_FUNCTION    min(R2, R4)      -> R0
 0009 STACK_POP        [2]
 0010 IF_FALSE_GOTO    12
 0011 NOT_ALL_ZERO     R0
 0012 RETURN

Related to fcb6bb5763
(Prior to that commit, this worked because a NULL pointer is a
valid, empty GSList.)
2024-02-06 15:32:57 +00:00
..
baseline Ethernet: Implementation of conversations with stream identifiers 2024-01-02 07:40:49 +00:00
captures HTTP3, QUIC: Desegment HTTP3 QPACK Encoder Streams 2023-12-10 07:36:41 -05:00
config dot11decrypt: Add partial FT-EAP decryption support 2021-01-20 16:10:12 +00:00
keys TLS: Fix TLS tunneled within TLS 2023-06-12 17:09:09 +00:00
lua LUA: allow conversion from string to uint64 in any base 2024-01-20 13:33:27 +00:00
protobuf_lang_files GRPC: Add support for gRPC-Web 2022-03-01 10:19:47 +00:00
suite_dfilter dfilter: Handle null arguments to min, max 2024-02-06 15:32:57 +00:00
suite_dissectors Test: Disable an ASTERIX test 2023-12-04 10:56:23 -08:00
README.test Qt: Add a packet diagram view. 2020-08-10 18:17:50 +00:00
conftest.py Tests: Fix default option argument 2023-09-24 12:37:42 +00:00
fixtures_ws.py test: Skip mongo zstd test if we don't have zstd 2024-01-24 09:55:12 -05:00
hosts.custom
hosts.global
hosts.personal
matchers.py Tools+test: Call python3 explicitly. 2020-11-05 06:46:35 +00:00
sampleif.py test: fix sampleif.py on weird systems using Python 3.6 and older 2019-04-16 03:28:43 +00:00
subprocesstest.py Test and handle spaces in our build directory 2023-09-26 06:54:46 +00:00
suite_capture.py Test and handle spaces in our build directory 2023-09-26 06:54:46 +00:00
suite_clopts.py Test: Make sure sampleif.py uses our current Python executable 2023-12-03 18:22:49 +00:00
suite_decryption.py tshark: Escape delimiter separated value in compliant ways 2023-11-09 09:17:03 +00:00
suite_dissection.py test: Skip mongo zstd test if we don't have zstd 2024-01-24 09:55:12 -05:00
suite_extcaps.py Tests: Remove unittest depenency (extcaps) 2023-06-05 18:26:34 +01:00
suite_fileformats.py Test and handle spaces in our build directory 2023-09-26 06:54:46 +00:00
suite_follow.py Tests: Add tests for follow websocket stream 2023-09-11 01:02:07 +00:00
suite_follow_dccp.py Tests: Remove unittest dependency (follow_dccp) 2023-06-05 18:27:24 +01:00
suite_follow_multistream.py http2: Human readable follow HTTP/2 headers 2023-06-14 00:59:15 +00:00
suite_io.py Tests: Remove unittest dependency (io) 2023-06-05 18:27:24 +01:00
suite_mergecap.py Tests: Remove unittest dependency (mergecap) 2023-06-05 18:26:34 +01:00
suite_nameres.py addr_resolv: Remove confusing "only use profile hosts" preference 2023-11-01 14:57:25 +00:00
suite_outputformats.py Tests: Remove unittest dependency (outputformats) 2023-06-05 18:26:34 +01:00
suite_release.py GitLab CI+Tests: Add a --disable-gui option 2023-09-09 18:42:04 -07:00
suite_sharkd.py sharkd: Fix displayed delta times in "frames" method 2023-11-07 20:35:24 +00:00
suite_text2pcap.py Test and handle spaces in our build directory 2023-09-26 06:54:46 +00:00
suite_unittests.py Tests: Remove unittest dependency (unittests) 2023-06-05 18:27:24 +01:00
suite_wslua.py test: Add Lua ByteArray integer tests 2023-08-22 13:15:20 +00:00
travis-upload-artifacts.sh test,travis: dump a screenshot for hanging GUI tests 2019-01-24 00:26:22 +00:00
util_dump_dhcp_pcap.py Dumpcap+Qt: Add support for `-a packets:NUM` and `-b packets:NUM`. 2018-11-09 05:55:11 +00:00

README.test

Wireshark Tests

The recommended steps to prepare for and to run tests:

* Install two Python packages, pytest: `pip install pytest pytest-xdist`
* Build programs (“wireshark”, “tshark”, etc.): `ninja`
* Build additional programs for the “unittests” suite: `ninja test-programs`
* Run tests in the build directory: `pytest`

Replace `ninja test-programs` by `make test-programs` as needed.

See the “Wireshark Tests” chapter of the Developer's Guide for details:
https://www.wireshark.org/docs/wsdg_html_chunked/ChapterTests.html

If you need to update the baseline files use the following commands (on a Linux system)
mkdir ~/.config/wireshark/profiles/ctest
TZ=UTC WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 build/run/tshark -C ctest -T ek -r test/captures/dhcp.pcap > test/baseline/dhcp.ek
TZ=UTC WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 build/run/tshark -C ctest -T json -r test/captures/dhcp.pcap > test/baseline/dhcp.json
TZ=UTC WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 build/run/tshark -C ctest -T jsonraw -r test/captures/dhcp.pcap > test/baseline/dhcp.jsonraw
TZ=UTC WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 build/run/tshark -C ctest -T ek -r test/captures/dhcp.pcap -x > test/baseline/dhcp-raw.ek