runner

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNormalizePacket

func DefaultNormalizePacket(pkt gopacket.Packet)

DefaultNormalizePacket zeroes-out all the fields in the packet that can't generally be predicted by the test, both in received and in expected packet and thus makes them equal even if the field value varies among test runs.

Types

type Case

type Case struct {
	Name              string
	WriteTo, ReadFrom string
	Input, Want       []byte
	StoreDir          string
	IgnoreNonMatching bool
	// NormalizePacket is a function that will be called both on actual and
	// expected packet. It can modify the packet fields so that unpredictable
	// values are zeroed out and the packets match.
	NormalizePacket NormalizePacketFn
}

Case represents a border router test case.

func (*Case) Run

func (t *Case) Run(cfg *RunConfig) error

Run executes a test case. It writes input pkt to interface `WriteTo` and listens for want pkt in interface `ReadFrom`. It stores all the packets in the artifact directory for further debug.

type ExpectedPacket

type ExpectedPacket struct {
	Storer            packetStorer
	DevName           string
	Timeout           time.Duration
	IgnoreNonMatching bool
	Pkt               gopacket.Packet
}

ExpectedPacket fully describes a packet to be expected. To expect an empty packet a nil Pkt value can be used.

type NormalizePacketFn

type NormalizePacketFn func(gopacket.Packet)

type RunConfig

type RunConfig struct {
	// contains filtered or unexported fields
}

RunConfig contains handles to all devices used in the acceptance test and should be used to read/write from devices.

func NewRunConfig

func NewRunConfig() (*RunConfig, error)

NewRunConfig creates a new run configuration. After usage Close should be called and the object should be GC'ed before it is safe to use again.

func (*RunConfig) Close

func (c *RunConfig) Close()

Close tears down the state.

func (*RunConfig) ExpectPacket

func (c *RunConfig) ExpectPacket(pkt ExpectedPacket, normalizeFn NormalizePacketFn) error

ExpectPacket expects packet pkt on the device devName. It stores all received packets using the storer. If the received packet in the device is matching the expected packet and no other packet is received nil is returned. Otherwise details of what went wrong are returned in the error.

func (*RunConfig) WritePacket

func (c *RunConfig) WritePacket(devName string, pkt []byte) error

WritePacket writes the given packet to given device.

Jump to

Keyboard shortcuts

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