Documentation ¶
Index ¶
- Constants
- func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string
- type Constraint
- func NeedDistro(distro string) Constraint
- func NeedDistroEquals(distro string) Constraint
- func NeedDistroNotEquals(distro string) Constraint
- func NeedDistroVersion(version string) Constraint
- func NeedDistroVersionEquals(version string) Constraint
- func NeedDistroVersionGE(version string) Constraint
- func NeedDistroVersionGT(version string) Constraint
- func NeedDistroVersionLE(version string) Constraint
- func NeedDistroVersionLT(version string) Constraint
- func NeedDistroVersionNotEquals(version string) Constraint
- func NeedDistroVersionWithOp(version string, op Operator) Constraint
- func NeedDistroWithOp(distro string, op Operator) 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 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 ¶
This section is empty.
Functions ¶
func MakeRuntimeConfigFileData ¶
func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string
Types ¶
type Constraint ¶
type Constraint func(c *Constraints)
Constraint is a function that operates on a Constraints object to set particular values.
func NeedDistro ¶
func NeedDistro(distro string) Constraint
NeedDistro will skip the test unless running on the specified distro.
func NeedDistroEquals ¶
func NeedDistroEquals(distro string) Constraint
NeedDistroEquals will skip the test unless running on the specified distro.
func NeedDistroNotEquals ¶
func NeedDistroNotEquals(distro string) Constraint
NeedDistroNotEquals will skip the test unless run a distro that does not match the specified name.
func NeedDistroVersion ¶
func NeedDistroVersion(version string) Constraint
NeedDistroVersion will skip the test unless running on the specified (exact) version of some distro.
Note: distro versions vary in format.
func NeedDistroVersionEquals ¶
func NeedDistroVersionEquals(version string) Constraint
NeedDistroVersionEquals will skip the test unless the distro version is the same as the specified version.
Note: distro versions vary in format.
func NeedDistroVersionGE ¶
func NeedDistroVersionGE(version string) Constraint
NeedDistroVersionGE will skip the test unless the distro version is newer than or the same as the specified version.
Note: distro versions vary in format.
func NeedDistroVersionGT ¶
func NeedDistroVersionGT(version string) Constraint
NeedDistroVersionGT will skip the test unless the distro version is newer than the specified version.
Note: distro versions vary in format.
func NeedDistroVersionLE ¶
func NeedDistroVersionLE(version string) Constraint
NeedDistroVersionLE will skip the test unless the distro version is older than or the same as the specified version.
Note: distro versions vary in format.
func NeedDistroVersionLT ¶
func NeedDistroVersionLT(version string) Constraint
NeedDistroVersionLT will skip the test unless the distro version is older than the specified version.
Note: distro versions vary in format.
func NeedDistroVersionNotEquals ¶
func NeedDistroVersionNotEquals(version string) Constraint
NeedDistroVersionNotEquals will skip the test unless the distro version is different to the specified version.
Note: distro versions vary in format.
func NeedDistroVersionWithOp ¶
func NeedDistroVersionWithOp(version string, op Operator) Constraint
NeedDistroVersionWithOp skips the test unless the distro version constraint specified by the arguments is true.
Note: distro versions vary in format.
func NeedDistroWithOp ¶
func NeedDistroWithOp(distro string, op Operator) Constraint
NeedDistroWithOp skips the test unless the distro constraint specified by the arguments is true.
func NeedKernelVersion ¶
func NeedKernelVersion(version string) Constraint
NeedKernelVersion will skip the test unless running on the specified (exact) version of some distro.
Note: distro versions vary in format.
func NeedKernelVersionEquals ¶
func NeedKernelVersionEquals(version string) Constraint
NeedKernelVersionLT will skip the test unless the distro version is older than the specified version.
func NeedKernelVersionGE ¶
func NeedKernelVersionGE(version string) Constraint
NeedKernelVersionGE will skip the test unless the distro version is newer than or the same as the specified version.
Note: distro versions vary in format.
func NeedKernelVersionGT ¶
func NeedKernelVersionGT(version string) Constraint
NeedKernelVersionGT will skip the test unless the distro version is newer than the specified version.
Note: distro versions vary in format.
func NeedKernelVersionLE ¶
func NeedKernelVersionLE(version string) Constraint
NeedKernelVersionLE will skip the test unless the distro version is older than or the same as the specified version.
Note: distro versions vary in format.
func NeedKernelVersionLT ¶
func NeedKernelVersionLT(version string) Constraint
NeedKernelVersionLT will skip the test unless the distro version is older than the specified version.
Note: distro versions vary in format.
func NeedKernelVersionNotEquals ¶
func NeedKernelVersionNotEquals(version string) Constraint
NeedKernelVersionNotEquals will skip the test unless the distro version is different to the specified version.
func NeedKernelVersionWithOp ¶
func NeedKernelVersionWithOp(version string, op Operator) Constraint
NeedKernelVersionWithOp skips the test unless the distro 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 UID int // Not ideal: set when UID needs to be checked. This allows // a test for UID 0 to be detected. UIDSet bool // DistroName is the name of a distro in all lower-case letters. DistroName string // DistroVersion is the version of the particular distro in string // format. It may contain periods and dashes. DistroVersion string // KernelVersion is the version of a particular kernel. KernelVersion string // Operator is the operator to apply to one of the constraints. Operator Operator }
Constraints encapsulates all information about a test constraint.
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 DefaultVCPUCount uint32 DefaultMaxVCPUCount uint32 DefaultMemSize uint32 DefaultMsize9p uint32 DefaultGuestHookPath string KernelPath string ImagePath string KernelParams string MachineType string ShimPath string ProxyPath string NetmonPath string LogPath string BlockDeviceDriver string AgentTraceMode string AgentTraceType string PCIeRootPort uint32 DisableBlock bool EnableIOThreads bool HotplugVFIOOnRootBus bool DisableNewNetNs bool HypervisorDebug bool RuntimeDebug bool RuntimeTrace bool ProxyDebug bool ShimDebug bool NetmonDebug bool AgentDebug bool AgentTrace bool }
type TestConstraint ¶
type TestConstraint struct { Debug bool // Effective user ID of running test ActualEUID int DistroName string DistroVersion string KernelVersion string // Used to record all passed and failed constraints in // human-readable form. Passed []Result Failed []Result // Optionally used to record an issue number that relates to the // constraint. Issue string }
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, distro) 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).