Documentation ¶
Index ¶
- Constants
- Variables
- func IsInGitHubActions() bool
- func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string
- func SetupOCIConfigFile(t *testing.T) (rootPath string, bundlePath, ociConfigFile string)
- func WriteOCIConfigFile(spec specs.Spec, configPath string) error
- type Constraint
- func NeedKernelVersion(version string) Constraint
- func NeedKernelVersionEquals(version string) Constraint
- func NeedKernelVersionGE(version string) Constraint
- func NeedKernelVersionGT(version string) Constraint
- func NeedKernelVersionLE(version string) Constraint
- func NeedKernelVersionLT(version string) Constraint
- func NeedKernelVersionNotEquals(version string) Constraint
- func NeedKernelVersionWithOp(version string, op Operator) Constraint
- func NeedNonRoot() Constraint
- func NeedRoot() Constraint
- func NeedUID(uid int, op Operator) Constraint
- func WithIssue(issue string) Constraint
- type Constraints
- type ContainerIDTestDataType
- type Operator
- type Result
- type RuntimeConfigOptions
- type TestConstraint
Constants ¶
const ( TestDisabledNeedRoot = "Test disabled as requires root user" TestDisabledNeedNonRoot = "Test disabled as requires non-root user" )
Variables ¶
var ContainerIDTestData = []ContainerIDTestDataType{ {"", false}, {" ", false}, {".", false}, {"-", false}, {"_", false}, {" a", false}, {".a", false}, {"-a", false}, {"_a", false}, {"..", false}, {"a", false}, {"z", false}, {"A", false}, {"Z", false}, {"0", false}, {"9", false}, {"-1", false}, {"/", false}, {"a/", false}, {"a/../", false}, {"../a", false}, {"../../a", false}, {"../../../a", false}, {"foo/../bar", false}, {"foo bar", false}, {"a.", true}, {"a..", true}, {"aa", true}, {"aa.", true}, {"hello..world", true}, {"hello/../world", false}, {"aa1245124sadfasdfgasdga.", true}, {"aAzZ0123456789_.-", true}, {"abcdefghijklmnopqrstuvwxyz0123456789.-_", true}, {"0123456789abcdefghijklmnopqrstuvwxyz.-_", true}, {" abcdefghijklmnopqrstuvwxyz0123456789.-_", false}, {".abcdefghijklmnopqrstuvwxyz0123456789.-_", false}, {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_", true}, {"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.-_", true}, {" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_", false}, {".ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_", false}, {"/a/b/c", false}, {"a/b/c", false}, {"foo/../../../etc/passwd", false}, {"../../../../../../etc/motd", false}, {"/etc/passwd", false}, }
ContainerIDTestData is a set of test data that lists valid and invalid Container IDs
Functions ¶
func IsInGitHubActions ¶
func IsInGitHubActions() bool
func MakeRuntimeConfigFileData ¶
func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string
func SetupOCIConfigFile ¶
func WriteOCIConfigFile ¶
WriteOCIConfigFile using spec to update OCI config file by path configPath
Types ¶
type Constraint ¶
type Constraint func(c *Constraints)
Constraint is a function that operates on a Constraints object to set particular values.
func NeedKernelVersion ¶
func NeedKernelVersion(version string) Constraint
NeedKernelVersion will skip the test unless the kernel version is same as the specified version.
func NeedKernelVersionEquals ¶
func NeedKernelVersionEquals(version string) Constraint
NeedKernelVersionEquals will skip the test unless the kernel version is same as the specified version.
func NeedKernelVersionGE ¶
func NeedKernelVersionGE(version string) Constraint
NeedKernelVersionGE will skip the test unless the kernel version is newer than or the same as the specified version.
func NeedKernelVersionGT ¶
func NeedKernelVersionGT(version string) Constraint
NeedKernelVersionGT will skip the test unless the kernel version is newer than the specified version.
func NeedKernelVersionLE ¶
func NeedKernelVersionLE(version string) Constraint
NeedKernelVersionLE will skip the test unless the kernel version is older than or the same as the specified version.
func NeedKernelVersionLT ¶
func NeedKernelVersionLT(version string) Constraint
NeedKernelVersionLT will skip the test unless the kernel version is older than the specified version.
func NeedKernelVersionNotEquals ¶
func NeedKernelVersionNotEquals(version string) Constraint
NeedKernelVersionNotEquals will skip the test unless the kernel version is different to the specified version.
func NeedKernelVersionWithOp ¶
func NeedKernelVersionWithOp(version string, op Operator) Constraint
NeedKernelVersionWithOp skips the test unless the kernel version constraint specified by the arguments is true.
func NeedNonRoot ¶
func NeedNonRoot() Constraint
NeedNonRoot skips the test if running as the root user.
func NeedUID ¶
func NeedUID(uid int, op Operator) Constraint
NeedUID skips the test unless running as a user with the specified user ID.
func WithIssue ¶
func WithIssue(issue string) Constraint
WithIssue allows the specification of an issue URL.
Note that the issue is not checked for validity.
type Constraints ¶
type Constraints struct { Issue string // KernelVersion is the version of a particular kernel. KernelVersion string UID int // Operator is the operator to apply to one of the constraints. Operator Operator // Not ideal: set when UID needs to be checked. This allows // a test for UID 0 to be detected. UIDSet bool }
Constraints encapsulates all information about a test constraint.
type ContainerIDTestDataType ¶
ContainerIDTestDataType is a type used to test Container and Sandbox ID's.
type Operator ¶
type Operator int
Operator represents an operator to apply to a test constraint value.
type Result ¶
type Result struct { // Details of the constraint // (human-readable result of testing for a Constraint). Description string // true if constraint was valid Success bool }
Result is the outcome of a Constraint test
type RuntimeConfigOptions ¶
type RuntimeConfigOptions struct { Hypervisor string HypervisorPath string DefaultGuestHookPath string KernelPath string ImagePath string RootfsType string KernelParams string MachineType string LogPath string BlockDeviceDriver string BlockDeviceAIO string VirtioFSDaemon string JaegerEndpoint string JaegerUser string JaegerPassword string PFlash []string HotPlugVFIO config.PCIePort ColdPlugVFIO config.PCIePort DefaultVCPUCount uint32 DefaultMaxVCPUCount uint32 DefaultMemSize uint32 DefaultMaxMemorySize uint64 DefaultMsize9p uint32 DisableBlock bool EnableIOThreads bool DisableNewNetNs bool HypervisorDebug bool RuntimeDebug bool RuntimeTrace bool AgentDebug bool AgentTrace bool EnablePprof bool }
type TestConstraint ¶
type TestConstraint struct { KernelVersion string // Optionally used to record an issue number that relates to the // constraint. Issue string // Used to record all passed and failed constraints in // human-readable form. Passed []Result Failed []Result Debug bool // Effective user ID of running test ActualEUID int }
TestConstraint records details about test constraints.
func NewTestConstraint ¶
func NewTestConstraint(debug bool) TestConstraint
NewKataTest creates a new TestConstraint object and is the main interface to the test constraints feature.
func (*TestConstraint) NotValid ¶
func (tc *TestConstraint) NotValid(constraints ...Constraint) bool
NotValid checks if the specified list of constraints are all valid, returning true if any _fail_.
Notes:
- Constraints are applied in the order specified.
- A constraint type (user, kernel) can only be specified once.
- If the function fails to determine whether it can check the constraints, it will panic. Since this is facility is used for testing, this seems like the best approach as it unburdens the caller from checking for an error (which should never be ignored).