Documentation
¶
Overview ¶
Package testing provides public API for tests.
Package testing provides public API for tests.
Index ¶
- Constants
- func AddFixture(f *Fixture)
- func AddService(s *Service)
- func AddTest(t *Test)
- func ContextEnsurePrivateAttr(ctx context.Context, name string)
- func ContextLog(ctx context.Context, args ...interface{})
- func ContextLogf(ctx context.Context, format string, args ...interface{})
- func ContextOutDir(ctx context.Context) (dir string, ok bool)
- func ContextSoftwareDeps(ctx context.Context) ([]string, bool)
- func ContextVLog(ctx context.Context, args ...interface{})
- func ContextVLogf(ctx context.Context, format string, args ...interface{})
- func NewTestGlobRegexp(g string) (*regexp.Regexp, error)
- func Poll(ctx context.Context, f func(context.Context) error, opts *PollOptions) error
- func PollBreak(err error) error
- func RegistrationErrors() []error
- func Sleep(ctx context.Context, d time.Duration) error
- type CloudStorage
- type FixtState
- type FixtTestState
- type Fixture
- type FixtureImpl
- type FixtureParam
- type Logger
- type Meta
- type Param
- type PollOptions
- type PreState
- type Precondition
- type RPCHint
- type Service
- type ServiceState
- type State
- type StringPair
- type Test
- type TestHookState
- type TestInstance
- type VarString
Constants ¶
const ( // LacrosVariantUnknown indicates that this test has not yet been checked as to whether it requires a lacros variant. // New tests should not use this value, i.e. new tests should always consider lacros. LacrosVariantUnknown = testing.LacrosVariantUnknown // LacrosVariantNeeded indicates that a lacros variant for this is needed but hasn't been created yet. LacrosVariantNeeded = testing.LacrosVariantNeeded // LacrosVariantExists indicates that all required lacros variants for this test have been created. LacrosVariantExists = testing.LacrosVariantExists // LacrosVariantUnneeded indicates that lacros variants for this test are not needed. LacrosVariantUnneeded = testing.LacrosVariantUnneeded )
const ( // LifeCycleProductionReady indicates the test can be run in the lab and is expected to pass. // Most tests will be in this stage, and this value will be assumed if no other value is provided. LifeCycleProductionReady = testing.LifeCycleProductionReady // LifeCycleDisabled indicates that the test should not run in the lab and code will be deleted if not cleaned // up in a timely manner. LifeCycleDisabled = testing.LifeCycleDisabled // LifeCycleInDevelopment indicates that the test is either new or broken. It can still run in the lab // (ideally at a reduced frequency) but should not be included in flakiness reports or used to make // decisions like release qualification. LifeCycleInDevelopment = testing.LifeCycleInDevelopment // LifeCycleManualOnly indicates that the test is not meant to be scheduled in the lab - it will only be // triggered manually or outside of a lab environment. The code should not be deleted unless test owners // do not maintain the test. LifeCycleManualOnly = testing.LifeCycleManualOnly // LifeCycleOwnerMonitored indicates that the test has inherently ambiguous usage and should not be run by // or interpreted by anyone other than the test owner. These tests can run in the lab but should not // be run in release-blocking suites or any other situation where a non-owner will need to use the results. LifeCycleOwnerMonitored = testing.LifeCycleOwnerMonitored )
const (
// SatlabRPCServer is the container:port where Satlab RPC server runs and listens to.
SatlabRPCServer = "satlab_rpcserver:6003"
)
Variables ¶
This section is empty.
Functions ¶
func AddService ¶
func AddService(s *Service)
AddService adds service s to the global registry. This should be called only once in a service main file's init().
func AddTest ¶
func AddTest(t *Test)
AddTest adds test t to the global registry. This should be called only once in a test main file's init(), and it should be the top level statement of the init()'s body. The argument of AddTest() in the case should be a pointer to a composite literal of testing.Test.
func ContextEnsurePrivateAttr ¶
ContextEnsurePrivateAttr ensures the current entity declares a privateAttr in its metadata. Otherwise it will panic.
func ContextLog ¶
ContextLog formats its arguments using default formatting and logs them via ctx. It is intended to be used for informational logging by packages providing support for tests. If testing.State is available, just call State.Log or State.Logf instead.
func ContextLogf ¶
ContextLogf is similar to ContextLog but formats its arguments using fmt.Sprintf.
func ContextOutDir ¶
ContextOutDir is similar to OutDir but takes context instead. It is intended to be used by packages providing support for tests that need to write files.
func ContextSoftwareDeps ¶
ContextSoftwareDeps is similar to SoftwareDeps but takes context instead. It is intended to be used by packages providing support for tests that want to make sure tests declare proper dependencies.
func ContextVLog ¶
ContextVLog formats its arguments using default formatting and logs them via ctx at the debug (verbose) level. It is intended to be used for verbose logging by packages providing support for tests. If testing.State is available, just call State.VLog or State.VLogf instead.
func ContextVLogf ¶
ContextVLogf is similar to ContextVLog but formats its arguments using fmt.Sprintf.
func NewTestGlobRegexp ¶
NewTestGlobRegexp returns a compiled regular expression corresponding to g, a glob for matching test names.
DEPRECATED: Tests should not use this function.
func Poll ¶
Poll runs f repeatedly until f returns nil and then itself returns nil. If ctx returns an error before then or opts.Timeout is reached, the last error returned by f is returned. f should use the context passed to it, as it may have an adjusted deadline if opts.Timeout is set. If ctx's deadline has already been reached, f will not be invoked. If opts is nil, reasonable defaults are used.
Polling often results in increased load and slower execution (since there's a delay between when something happens and when the next polling cycle notices it). It should only be used as a last resort when there's no other way to watch for an event. The preferred approach is to watch for events in select{} statements. Goroutines can be used to provide notifications over channels. If an error wrapped by PollBreak is returned, then it immediately terminates the polling, and returns the unwrapped error.
func PollBreak ¶
PollBreak creates an error wrapping err that may be returned from a function passed to Poll to terminate polling immediately. For example:
err := testing.Poll(ctx, func(ctx context.Context) error { if err := mustSucceed(ctx); err != nil { return testing.PollBreak(err) } ... })
func RegistrationErrors ¶
func RegistrationErrors() []error
RegistrationErrors returns errors generated by calls to AddTest.
Types ¶
type CloudStorage ¶
type CloudStorage = testing.CloudStorage
CloudStorage allows Tast tests to read files on Google Cloud Storage.
type FixtState ¶
FixtState holds state relevant to the execution of a fixture.
This is a State for fixtures. See State's documentation for general guidance on how to treat FixtState in fixtures.
type FixtTestState ¶
type FixtTestState = testing.FixtTestState
FixtTestState holds state relevant to the execution of test hooks in a fixture.
This is a State for fixtures. See State's documentation for general guidance on how to treat FixtTestState in fixtures.
type FixtureImpl ¶
type FixtureImpl = testing.FixtureImpl
FixtureImpl is an interface fixtures should implement.
type FixtureParam ¶
type FixtureParam = testing.FixtureParam
FixtureParam defines parameters for a parameterized fixture.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger allows test helpers to log messages when no context.Context or testing.State is available.
func ContextLogger ¶
ContextLogger returns Logger from a context.
func (*Logger) Print ¶
func (l *Logger) Print(args ...interface{})
Print formats its arguments using default formatting and logs them.
type Meta ¶
Meta contains information about how the "tast" process used to initiate testing was run. It is used by remote tests in the "meta" category that run the tast executable to test Tast's behavior.
type Param ¶
Param defines parameters for a parameterized test case. See also https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/writing_tests.md#Parameterized-tests
type PollOptions ¶
type PollOptions = testingutil.PollOptions
PollOptions may be passed to Poll to configure its behavior.
type PreState ¶
PreState holds state relevant to the execution of a single precondition.
This is a State for preconditions. See State's documentation for general guidance on how to treat PreState in preconditions.
type Precondition ¶
type Precondition = testing.Precondition
Precondition represents a precondition that must be satisfied before a test is run.
type ServiceState ¶
type ServiceState = testing.ServiceState
ServiceState holds state relevant to a gRPC service.
type State ¶
State holds state relevant to the execution of a single test.
Parts of its interface are patterned after Go's testing.T type.
State contains many pieces of data, and it's unclear which are actually being used when it's passed to a function. You should minimize the number of functions taking State as an argument. Instead you can pass State's derived values (e.g. s.DataPath("file.txt")) or ctx (to use with ContextLog or ContextOutDir etc.).
It is intended to be safe when called concurrently by multiple goroutines while a test is running.
type StringPair ¶
type StringPair = protocol.StringPair
StringPair represents a string key-value pair. Typically used for SearchFlags.
type Test ¶
Test describes a registration of one or more test instances.
Test can be passed to testing.AddTest to actually register test instances to the framework.
In the most basic form where Params field is empty, Test describes exactly one test instance. If Params is not empty, multiple test instances are generated on registration by merging each testing.Param to the base Test.
type TestHookState ¶
type TestHookState = testing.TestHookState
TestHookState holds state relevant to the execution of a test hook.
This is a State for test hooks. See State's documentation for general guidance on how to treat TestHookState in test hooks.
type TestInstance ¶
type TestInstance = testing.TestInstance
TestInstance represents a test instance registered to the framework.
A test instance is the unit of "tests" exposed to outside of the framework. For example, in the command line of the "tast" command, users specify which tests to run by names of test instances. Single testing.AddTest call may register multiple test instances at once if testing.Test passed to the function has non-empty Params field.
type VarString ¶
type VarString struct {
// contains filtered or unexported fields
}
VarString define a structure for global runtime variables of string type.
func RegisterVarString ¶
RegisterVarString creates and registers a new VarString
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package cellularconst defines the constants for Cellular This package is defined under common/ as they might be used in both local and remote tests.
|
Package cellularconst defines the constants for Cellular This package is defined under common/ as they might be used in both local and remote tests. |
Package hwdep provides the hardware dependency mechanism to select tests to run on a DUT based on its hardware features and setup.
|
Package hwdep provides the hardware dependency mechanism to select tests to run on a DUT based on its hardware features and setup. |
Package testcheck provides common functions to check test definitions.
|
Package testcheck provides common functions to check test definitions. |
Package wlan provides the information of the wlan device.
|
Package wlan provides the information of the wlan device. |