Documentation ¶
Overview ¶
Package testutils provides utility code needed by multiple packages' test suites, but which should not be referenced in any non-test code.
Index ¶
- Variables
- func CaptureOutput(t *testing.T, f func()) []byte
- func ContainsIPNet(addrs []net.IPNet, predicate func(net.IPNet) bool) bool
- func MakeIPv4Net(a, b, c, d byte, ones int) net.IPNet
- func MakeIPv6(left, right []byte) net.IP
- func MakeIPv6Net(left, right []byte, ones int) net.IPNet
- func MustKey(t require.TestingT) (key wgtypes.Key)
- func MustKeyPair(t require.TestingT) (privateKey, publicKey wgtypes.Key)
- func MustParseKey(t require.TestingT, s string) wgtypes.Key
- func MustRandBytes(t require.TestingT, data []byte) []byte
- func RandIPNet(t *testing.T, size int, left, right []byte, ones int) net.IPNet
- func RandUDP4Addr(t *testing.T) *net.UDPAddr
- func RandUDP6Addr(t *testing.T) *net.UDPAddr
- func SrcDirectory() string
Constants ¶
This section is empty.
Variables ¶
var CIScaleFactor int
CIScaleFactor is an approximate scaling factor by which to multiply time deadlines in performance-sensitive tests to compensate for the running system being slower than the reference system.
var CIScaleFactorDuration time.Duration
CIScaleFactorDuration is just CIScaleFactor cast to a time.Duration for simplicity.
var CIScaleMs time.Duration // nolint:revive,stylecheck // this is like `time.Millisecond`
CIScaleMs is time.Millisecond * CIScaleFactor
var Rand *rand.Rand
Rand is a per-run initialized non-crypto RNG
Functions ¶
func CaptureOutput ¶ added in v0.10.0
CaptureOutput runs f with os.Stdout redirected to a temp file, and then re-reads everything that is written and returns it
func ContainsIPNet ¶ added in v0.8.2
ContainsIPNet runs a predicate across a net.IPNet slice and returns if any match was found
func MakeIPv4Net ¶ added in v0.8.1
MakeIPv4Net creates a net.IPNet with the given address and CIDR mask length
func MakeIPv6 ¶ added in v0.8.1
MakeIPv6 helps build IPv6 values in a similar method to how the "::" marker in an IPv6 literal works
func MakeIPv6Net ¶ added in v0.8.1
MakeIPv6Net uses MakeIPv6 to create a net.IPNet with the built IP and the given CIDR mask length
func MustKeyPair ¶
MustKeyPair generates a real pair of private and public keys, panicing (via require) if this fails
func MustParseKey ¶ added in v0.9.1
MustParseKey parses the string version of a wireguard key, panicing via require if it fails, returning the parsed key otherwise
func MustRandBytes ¶
MustRandBytes fills the given slice with random bytes using rand.Read
func RandIPNet ¶ added in v0.8.1
RandIPNet generates a random IPNet of the given size, and with optional fixed left/right bytes, and with the given CIDR prefix length
func RandUDP4Addr ¶ added in v0.8.1
RandUDP4Addr generates a random IPv4 UDP address for test purposes
func RandUDP6Addr ¶ added in v0.8.1
RandUDP6Addr generates a random IPv6 UDP address for test purposes
func SrcDirectory ¶ added in v0.10.0
func SrcDirectory() string
SrcDirectory uses the call stack to compute the directory of the caller's source file.
Types ¶
This section is empty.