gvisorgvisor.dev/gvisor/pkg/sentry/contexttest Index | Files

package contexttest

import "gvisor.dev/gvisor/pkg/sentry/contexttest"

Package contexttest builds a test context.Context.

Index

Functions

func Context

func Context(tb testing.TB) context.Context

Context returns a Context that may be used in tests. Uses ptrace as the platform.Platform.

Note that some filesystems may require a minimal kernel for testing, which this test context does not provide. For such tests, see kernel/contexttest.

func RootContext

func RootContext(tb testing.TB) context.Context

RootContext returns a Context that may be used in tests that need root credentials. Uses ptrace as the platform.Platform.

func WithLimitSet

func WithLimitSet(ctx context.Context, l *limits.LimitSet) context.Context

WithLimitSet returns a copy of ctx carrying l.

Types

type TestContext

type TestContext struct {
	context.Context
	// contains filtered or unexported fields
}

TestContext represents a context with minimal functionality suitable for running tests.

func (*TestContext) RegisterValue

func (t *TestContext) RegisterValue(key, value any)

RegisterValue registers additional values with this test context. Useful for providing values from external packages that contexttest can't depend on.

func (*TestContext) Value

func (t *TestContext) Value(key any) any

Value implements context.Context.

Source Files

contexttest.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
13 packages
Last checked
4 hours ago

Tools for package owners.