gvisorgvisor.dev/gvisor/pkg/tcpip/testutil Index | Files

package testutil

import "gvisor.dev/gvisor/pkg/tcpip/testutil"

Package testutil provides helper functions for netstack unit tests.

Index

Functions

func MustParse4

func MustParse4(addr string) tcpip.Address

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

func MustParse6(addr string) tcpip.Address

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(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

func MustParseSubnet4(subnet string) tcpip.Subnet

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.