Testing¶
What the suite has to prove, and what a change has to bring to it, is ruled on
Testing a Change. Check a change module by module as that page describes; the
make targets below run a whole tier.
Running the Tests¶
The unit tests need nothing beyond the package itself and the sample captures tracked in the repository:
make test
The runtime, regression and integration tests additionally read sample captures
that are not tracked (see .gitignore);
examples/generators/make_samples.py reconstructs them into
examples/captures/, and make test-all regenerates them before running
the whole suite:
make samples # write examples/captures/*.pcap and *.pcapng
make test-all # regenerate the fixtures, then run every test
The same fixtures back the demonstration scripts in
examples/legacy_smoke/, which read them as ../captures/….
Continuous integration runs the make test selection, since the fixtures are
not in the repository. Wireshark’s tshark is only required to exercise the
PyShark engine, and is not
needed by the test suite.
The Option Round-Trip Generator¶
One generator works differently from the rest.
examples/generators/options.py does not describe packets it wants; it asks
the library which option, chunk, parameter, message, frame and block codes it
registers, and then constructs one of each through the public construction API,
parses it back, and constructs it again from what was parsed. The
options-*.pcap captures are the cases that survive that round trip, so
they record what this version of pcapkit builds rather than what a
third-party tool builds.
tests/protocols/test_option_roundtrip_unit.py runs the same cases without
needing a fixture at all, and carries a table of the ones that do not close the
cycle, each named against the defect that stops it.