Chapter 13. Wireshark Tests

Table of Contents

13.1. Quick Start
13.2. Test suite structure
13.2.1. Test Coverage And Availability
13.2.2. Suites, Cases, and Tests
13.2.3. pytest fixtures
13.3. Listing And Running Tests
13.4. Listing And Running Tests (pytest)
13.5. Adding Or Modifying Built-In Tests
13.6. Adding Or Modifying External Tests

The Wireshark sources include a collection of Python scripts that test the features of Wireshark, TShark, Dumpcap, and other programs that accompany Wireshark. These are located in the test directory of the Wireshark source tree.

The command line options of Wireshark and its companion command line tools are numerous. These tests help to ensure that we don’t introduce bugs as Wireshark grows and evolves.

13.1. Quick Start

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.

The test suite will attempt to test as much as possible and skip tests when its dependencies are not satisfied. For example, packet capture tests require a Loopback interface and capture privileges. To avoid capture tests, pass the --disable-capture option.

List available tests with pytest --collectonly. Enable verbose output with pytest --verbose. For more details, see Section 13.4, “Listing And Running Tests (pytest)”.

If for whatever reason pytest is too old or unavailable, you could use a more limited test runner, test/ Use test/ --help to see all options. For more details, see Section 13.3, “Listing And Running Tests”.

CMake currently runs test/ when the “test” target is built.