Documentation
¶
Index ¶
- func DefaultVirtualDevice(arch string) *fvdpb.VirtualDevice
- type Arch
- type Disk
- type Distribution
- func (d *Distribution) Create(fvd *fvdpb.VirtualDevice) (*Instance, error)
- func (d *Distribution) Delete() error
- func (d *Distribution) RunNonInteractive(toRun, hostPathMinfsBinary, hostPathZbiBinary string, fvd *fvdpb.VirtualDevice) (string, string, error)
- func (d *Distribution) TargetCPU() (Arch, error)
- type DistributionParams
- type Emulator
- type Instance
- func (i *Instance) AssertLogMessageNotSeenWithinTimeout(notSeen string, timeout time.Duration) error
- func (i *Instance) CaptureLinesContaining(msg string, stop string) ([]string, error)
- func (i *Instance) Kill() error
- func (i *Instance) RunCommand(cmd string) error
- func (i *Instance) Start() error
- func (i *Instance) StartPiped(piped *exec.Cmd) error
- func (i *Instance) Wait() (*os.ProcessState, error)
- func (i *Instance) WaitForAnyLogMessage(msgs ...string) (string, error)
- func (i *Instance) WaitForLogMessage(msg string) error
- func (i *Instance) WaitForLogMessageAssertNotSeen(msg string, notSeen string) error
- func (i *Instance) WaitForLogMessages(msgs []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultVirtualDevice ¶
func DefaultVirtualDevice(arch string) *fvdpb.VirtualDevice
DefaultVirtualDevice returns a virtual device configuration for testing.
The returned virtual device is compatible with the image manifest produced by a Fuchsia build for the specified architecture.
Types ¶
type Distribution ¶
type Distribution struct { Emulator Emulator // contains filtered or unexported fields }
Distribution is a collection of QEMU-related artifacts.
Delete must be called once done with it.
func UnpackFrom ¶
func UnpackFrom(path string, distroParams DistributionParams) (*Distribution, error)
UnpackFrom unpacks the emulator distribution.
path is the path to host_x64/test_data containing the emulator. emulator is the emulator to unpack.
func (*Distribution) Create ¶
func (d *Distribution) Create(fvd *fvdpb.VirtualDevice) (*Instance, error)
Create creates an instance of the emulator with the given parameters.
func (*Distribution) Delete ¶
func (d *Distribution) Delete() error
Delete removes the emulator-related artifacts.
func (*Distribution) RunNonInteractive ¶
func (d *Distribution) RunNonInteractive(toRun, hostPathMinfsBinary, hostPathZbiBinary string, fvd *fvdpb.VirtualDevice) (string, string, error)
RunNonInteractive runs an instance of the emulator that runs a single command and returns the log that results from doing so.
This mode is non-interactive and is intended specifically to test the case where the serial port has been disabled. The following modifications are made to the emulator invocation compared with Create()/Start():
- amalgamate the given ZBI into a larger one that includes an additional entry of a script which includes commands to run.
- that script mounts a disk created on the host in /tmp, and runs the given command with output redirected to a file also on the /tmp disk
- the script triggers shutdown of the machine
- after emulator shutdown, the log file is extracted and returned.
In order to achieve this, here we need to create the host minfs file system, write the commands to run, build the augmented .zbi to be used to boot. We then use Start() and wait for shutdown. Finally, extract and return the log from the minfs disk.
func (*Distribution) TargetCPU ¶
func (d *Distribution) TargetCPU() (Arch, error)
TargetCPU returns the target CPU used by the build that produced this library.
type DistributionParams ¶
type DistributionParams struct {
Emulator Emulator
}
DistributionParams is passed to UnpackFrom().
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a live emulator instance.
func (*Instance) AssertLogMessageNotSeenWithinTimeout ¶
func (i *Instance) AssertLogMessageNotSeenWithinTimeout(notSeen string, timeout time.Duration) error
AssertLogMessageNotSeenWithinTimeout will fail if |notSeen| is seen within the |timeout| period. This function will timeout as success if more than |timeout| has passed without seeing |notSeen|.
func (*Instance) CaptureLinesContaining ¶
CaptureLinesContaining returns all the lines that contain the given msg, up until a line containing stop is found.
func (*Instance) RunCommand ¶
RunCommand runs the given command in the serial console for the emulator instance.
func (*Instance) StartPiped ¶
StartPiped starts the emulator instance with stdin/stdout piped through a different process.
Assumes that the stderr from the piped process should replace the stdout from the emulator.
func (*Instance) Wait ¶
func (i *Instance) Wait() (*os.ProcessState, error)
Wait for the emulator instance to terminate
func (*Instance) WaitForAnyLogMessage ¶
WaitForAnyLogMessage reads log messages from the emulator instance looking for any line that contains a message from msgs. Returns the first message that was found, or an error.
func (*Instance) WaitForLogMessage ¶
WaitForLogMessage reads log messages from the emulator instance until it reads a message that contains the given string.
func (*Instance) WaitForLogMessageAssertNotSeen ¶
WaitForLogMessageAssertNotSeen is the same as WaitForLogMessage() but with the addition that it will return an error if |notSeen| is contained in a retrieved message.
func (*Instance) WaitForLogMessages ¶
WaitForLogMessages reads log messages from the emulator instance until it reads all message in |msgs|. The log messages can appear in *any* order. Only one expected message from |msgs| is retired per matching actual message even if multiple messages from |msgs| match the log line.
Directories
¶
Path | Synopsis |
---|---|
Package emulatortest wraps package emulator for use in unit tests.
|
Package emulatortest wraps package emulator for use in unit tests. |