nftest

package
v0.0.0-...-8c25c3f Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Fw represents the nftables Fw object.
	Fw, _ = nftb.Fw()
)

Functions

func AddTestDNATRule

func AddTestDNATRule(t *testing.T, conn *nftables.Conn, exp *[]expr.Any) (*nftables.Rule, *nftables.Chain)

AddTestDNATRule adds a generic table, chain and rule with the given expression.

func AddTestRule

func AddTestRule(t *testing.T, conn *nftables.Conn, exp *[]expr.Any) (*nftables.Rule, *nftables.Chain)

AddTestRule adds a generic table, chain and rule with the given expression.

func AddTestSNATRule

func AddTestSNATRule(t *testing.T, conn *nftables.Conn, exp *[]expr.Any) (*nftables.Rule, *nftables.Chain)

AddTestSNATRule adds a generic table, chain and rule with the given expression.

func AreExprsValid

func AreExprsValid(t *testing.T, test *TestsT, rule *nftables.Rule) bool

AreExprsValid checks if the expressions defined in the given rule are valid according to the expected expressions defined in the tests.

func CleanupSystemConn

func CleanupSystemConn(t *testing.T, newNS netns.NsHandle)

CleanupSystemConn closes the given namespace.

func OpenSystemConn

func OpenSystemConn(t *testing.T) (*nftables.Conn, netns.NsHandle)

OpenSystemConn opens a new connection with the kernel in a new namespace. https://github.com/google/nftables/blob/8f2d395e1089dea4966c483fbeae7e336917c095/internal/nftest/system_conn.go#L15

func SkipIfNotPrivileged

func SkipIfNotPrivileged(t *testing.T)

SkipIfNotPrivileged will skip the test from where it's invoked, to skip the test if we don't have root privileges. This may occur when executing the tests on restricted environments, such as containers, chroots, etc.

Types

type TestsT

type TestsT struct {
	Name             string
	Family           string
	Parms            string
	Values           []*config.ExprValues
	ExpectedExprsNum int
	ExpectedExprs    []interface{}
	ExpectedFail     bool
}

TestsT defines the fields of a test.

Jump to

Keyboard shortcuts

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