testsupport

package
v0.0.0-...-1028ecd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableDynamicDebug

func EnableDynamicDebug(tb testing.TB, filter string)

EnableDynamicDebug enables the dynamic kernel debug printing for the given filter.

Filter syntax: https://docs.kernel.org/admin-guide/dynamic-debug-howto.html

func Payload

func Payload(tb testing.TB, length int) gopacket.Payload

Payload returns a new gopacket.Payload with the given length which can be used for test packets.

func PrependPacket

func PrependPacket(tb testing.TB, vnethdr virtio.NetHdr, pkt []byte) []byte

PrependPacket encodes the given virtio.NetHdr, puts it in front of the given packet slice and returns the new slice.

func SetSysctl

func SetSysctl(tb testing.TB, name, value string)

SetSysctl sets the given sysctl to the given value.

func TestPacket

func TestPacket(tb testing.TB, mac net.HardwareAddr, length int) (virtio.NetHdr, []byte)

TestPacket returns a new test packet which consists of Ethernet, IPv4 and UDP headers and a variable length payload. The given MAC address will be used as the source and destination MAC in the Ethernet header and the packet will have the given total length.

Additionally, a virtio.NetHdr is returned that configures the necessary offloads that would be needed to transmit this packet over an MTU 1500 link. It configures checksum offloads and GSO, if needed.

func VirtrunOnly

func VirtrunOnly(tb testing.TB)

VirtrunOnly marks that a test or testing helper must only be run within the virtual environment created by virtrun.

This function should be used at the beginning of every test function or helper that (temporarily) modifies the state of the local system. When the test does not run in a virtrun VM, then it will fail. This protects developer systems from undesired side effects.

See: https://github.com/aibor/virtrun

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL