Documentation
¶
Overview ¶
Package conform is the shared test suite every packetio backend must pass.
The contract in the packetio package doc is prose, and prose does not fail a build. Every bug the backends have had in practice was a place where one of them quietly meant something different from the interface: frames returned to the pool that the caller still owned, a Reclaim that reclaimed nothing, a build callback whose zero return meant three different things. Those are the cases here.
A backend's own test calls Run with a function that opens a device. It is in internal/ because it is a test of this module's backends, not something an out-of-tree backend can use -- if that is ever wanted, move it up.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Required ¶
func Required() bool
Required is set by PACKETIO_CONFORM_REQUIRED. When it is on, a suite that cannot open a device fails instead of skipping.
This exists because of how AF_XDP went unverified for the whole life of this module. Its test opened a device in a way that backend always refuses, so every subtest skipped, "go test ./..." printed ok, and the suite reported nothing at all -- for months. The first time it actually ran it found a contract violation on the first check.
A test that skips silently is indistinguishable from a test that passes, and the difference matters most exactly where it is hardest to see: a backend that needs hardware. So on a machine that has the hardware, say so, and a suite that skips is then a failure rather than a quiet nothing.
func RunSteering ¶
func RunSteering(t *testing.T, openWith func(t *testing.T, f packetio.SteeringFilter) (Device, error))
RunSteering checks a backend's handling of receive filters: a filter it accepts is reported, and one it cannot express is refused at Open with ErrUnsupported rather than installed as something wider. openWith opens a device with the given filter, returning nil to skip and the error Open gave.
func RunTimestamps ¶ added in v0.1.2
RunTimestamps checks a backend that claims Capabilities.RxTimestamps: the interface is really there, and the times it reports are usable.
It needs traffic, which the suite cannot make on its own, so send is the caller's: it puts packets on the wire and returns how many, or zero if it cannot. A run that sees nothing skips rather than passes, on the rule that a skipped test and a passing test must not print the same word.