Documentation ¶
Overview ¶
Package genltest provides utilities for generic netlink testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Func ¶
A Func is a function that can be used to test genetlink.Conn interactions. The function can choose to return zero or more generic netlink messages, or an error if needed.
For a netlink request/response interaction, the requests greq and nreq are populated by genetlink.Conn.Send and passed to the function. greq is created from the body of nreq.
For multicast interactions, both greq and nreq are empty when passed to the function when genetlink.Conn.Receive is called.
If a Func returns an error, the error will be returned as-is to the caller. If no messages and io.EOF are returned, no messages and no error will be returned to the caller, simulating a multi-part message with no data.
func CheckRequest ¶
CheckRequest returns a Func that verifies that an incoming request message has the specified generic netlink family, command, and netlink header flags, and then passes the request through to fn.
If family, command, or flags are set to the zero value, the specific check for that value will be skipped for request message.
func ServeFamily ¶
ServeFamily returns a Func that intercepts "get family" commands to the generic netlink controller, verifies that the requested family name matches the provided one, and then returns family information specified by f.
Requests which are not related to requesting a family are passed through to fn.
ServeFamily is primarily useful in tests for packages which interact with a specific generic netlink family.