dep

package
v0.0.0-...-d046166 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package dep deals with dependencies of tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	// SkipReasons contains a list of messages describing why some dependencies
	// were not satisfied. They should be reported as informational logs.
	SkipReasons []string

	// Errors contains a list of messages describing errors encountered while
	// evaluating dependencies. They should be reported as test errors.
	Errors []string
}

CheckResult represents the result of the check whether to run a test.

func (*CheckResult) OK

func (r *CheckResult) OK() bool

OK returns whether to run the test.

type Deps

type Deps struct {
	Var      []string
	Software SoftwareDeps
	Hardware HardwareDeps
}

Deps contains all information about dependencies tests have.

func (*Deps) Check

func (d *Deps) Check(f *Features) *CheckResult

Check returns whether d is satisfied on f.

type Features

type Features struct {
	// Var contains runtime variables.
	// If it is nil, variable dependency checks should not be performed.
	Var map[string]string

	// Software contains information about software features.
	// If it is nil, software dependency checks should not be performed.
	Software *SoftwareFeatures

	// Hardware contains information about hardware features.
	// If it is nil, hardware dependency checks should not be performed.
	Hardware *HardwareFeatures
}

Features conveys actual values test dependencies are checked against. TODO(oka): rename the struct name.

type HardwareCondition

type HardwareCondition struct {
	// Satisfied is a pointer to a function which checks if the given HardwareFeatures satisfies
	// the condition.
	Satisfied func(f *HardwareFeatures) error

	// CEL is the CEL expression denoting the condition.
	CEL string

	// Err is an error to be reported on Test registration
	// if instantiation of HardwareCondition fails.
	Err error
}

HardwareCondition is exported as chromiumos/tast/testing/hwdep.Condition. Please find its document for details. Either Satisfied or Err should be nil exclusively.

type HardwareDeps

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

HardwareDeps is exported as chromiumos/tast/testing/hwdep.Deps. Please find its document for details.

func MergeHardwareDeps

func MergeHardwareDeps(d1, d2 HardwareDeps) HardwareDeps

MergeHardwareDeps merges two HardwareDeps instance into one HardwareDeps instance. The returned HardwareDeps is satisfied iff all conditions in d1 and ones in d2 are satisfied.

func NewHardwareDeps

func NewHardwareDeps(conds ...HardwareCondition) HardwareDeps

NewHardwareDeps creates a HardwareDeps from a set of HWConditions.

func (*HardwareDeps) CEL

func (d *HardwareDeps) CEL() string

CEL returns the CEL expression that reflects the conditions.

func (*HardwareDeps) Satisfied

Satisfied returns nil if the given device.Config satisfies the dependencies, i.e., the test can run on the current device setup. Otherwise, this returns an UnsatisfiedError instance, which contains a collection of detailed errors in Reasons.

func (*HardwareDeps) Validate

func (d *HardwareDeps) Validate() error

Validate returns error if one of the conditions failed to be instantiated.

type HardwareFeatures

type HardwareFeatures struct {
	// Deprecated. Use Features instead.
	DC *device.Config

	Features *api.HardwareFeatures
}

HardwareFeatures contains information about hardware features of the DUT. Hardware dependency conditions should decide eligibility based only on this information.

type SoftwareDeps

type SoftwareDeps = []string

SoftwareDeps represents dependencies to software features.

type SoftwareFeatures

type SoftwareFeatures struct {
	// Available contains a list of software features supported by the DUT.
	Available []string

	// Unavailable contains a list of software features not supported by the DUT.
	Unavailable []string
}

SoftwareFeatures contains information about software features of the DUT.

type UnsatisfiedError

type UnsatisfiedError struct {
	*errors.E

	// Reasons contain the detailed reasons why Satisfied failed.
	Reasons []error
}

UnsatisfiedError is reported when Satisfied() fails.

Jump to

Keyboard shortcuts

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