package testutil
import "gvisor.dev/gvisor/pkg/tcpip/testutil"
Package testutil provides helper functions for netstack unit tests.
Index ¶
- func MustParse4(addr string) tcpip.Address
- func MustParse6(addr string) tcpip.Address
- func MustParseLink(addr string) tcpip.LinkAddress
- func MustParseSubnet4(subnet string) tcpip.Subnet
- func ValidateMultiCounterStats(multi reflect.Value, counters []reflect.Value, options ValidateMultiCounterStatsOptions) error
- type ValidateMultiCounterStatsOptions
Functions ¶
func MustParse4 ¶
MustParse4 parses an IPv4 string (e.g. "192.168.1.1") into a tcpip.Address. Passing an IPv4-mapped IPv6 address will yield only the 4 IPv4 bytes.
func MustParse6 ¶
MustParse6 parses an IPv6 string (e.g. "fe80::1") into a tcpip.Address. Passing an IPv4 address will yield an IPv4-mapped IPv6 address.
func MustParseLink ¶
func MustParseLink(addr string) tcpip.LinkAddress
MustParseLink parses a Link string into a tcpip.LinkAddress, panicking on error.
The string must be in the format aa:bb:cc:dd:ee:ff or aa-bb-cc-dd-ee-ff.
func MustParseSubnet4 ¶
MustParseSubnet4 parses an IPv4 subnet string (e.g. "192.168.1.0/24") into a tcpip.Subnet.
func ValidateMultiCounterStats ¶
func ValidateMultiCounterStats(multi reflect.Value, counters []reflect.Value, options ValidateMultiCounterStatsOptions) error
ValidateMultiCounterStats verifies that every counter stored in multi is correctly tracking its counterpart in the given counters.
Types ¶
type ValidateMultiCounterStatsOptions ¶
type ValidateMultiCounterStatsOptions struct { ExpectMultiCounterStat bool ExpectMultiIntegralStatCounterMap bool }
ValidateMultiCounterStatsOptions holds options used when validating multi counter stat structs.
Source Files ¶
testutil.go testutil_unsafe.go
- Version
- v0.0.0-20250515200445-d30c58e5b8a4 (latest)
- Published
- May 15, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 12 hours ago –
Tools for package owners.