Documentation ¶
Overview ¶
Package vmimpl provides an abstract test machine (VM, physical machine, etc) interface for the rest of the system. For convenience test machines are subsequently collectively called VMs. The package also provides various utility functions for VM implementations.
Index ¶
- Variables
- func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout time.Duration, ...) (<-chan []byte, <-chan error, error)
- func OpenAdbConsole(bin, dev string) (rc io.ReadCloser, err error)
- func OpenConsole(con string) (rc io.ReadCloser, err error)
- func OpenRemoteConsole(bin string, args ...string) (rc io.ReadCloser, err error)
- func RandomPort() int
- func Register(typ string, ctor ctorFunc)
- func SCPArgs(debug bool, sshKey string, port int) []string
- func SSHArgs(debug bool, sshKey string, port int) []string
- func SleepInterruptible(d time.Duration) bool
- func UnusedTCPPort() int
- func WaitForSSH(debug bool, timeout time.Duration, addr, sshKey, sshUser, OS string, port int) error
- type BootError
- type Env
- type Instance
- type MergerError
- type OutputMerger
- type Pool
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Close to interrupt all pending operations in all VMs. Shutdown = make(chan struct{}) ErrTimeout = errors.New("timeout") )
Functions ¶
func OpenAdbConsole ¶
func OpenAdbConsole(bin, dev string) (rc io.ReadCloser, err error)
OpenAdbConsole provides fallback console output using 'adb shell dmesg -w'.
func OpenConsole ¶
func OpenConsole(con string) (rc io.ReadCloser, err error)
Tested on Suzy-Q and BeagleBone.
func OpenRemoteConsole ¶
func OpenRemoteConsole(bin string, args ...string) (rc io.ReadCloser, err error)
Open dmesg remotely
func RandomPort ¶
func RandomPort() int
func Register ¶
func Register(typ string, ctor ctorFunc)
Register registers a new VM type within the package.
func SleepInterruptible ¶
Sleep for d. If shutdown is in progress, return false prematurely.
func UnusedTCPPort ¶
func UnusedTCPPort() int
Types ¶
type Env ¶
type Env struct { // Unique name // Can be used for VM name collision resolution if several pools share global name space. Name string OS string // target OS Arch string // target arch Workdir string Image string SSHKey string SSHUser string Debug bool Config []byte // json-serialized VM-type-specific config }
Env contains global constant parameters for a pool of VMs.
type Instance ¶
type Instance interface { // Copy copies a hostSrc file into VM and returns file name in VM. Copy(hostSrc string) (string, error) // Forward setups forwarding from within VM to host port port // and returns address to use in VM. Forward(port int) (string, error) // Run runs cmd inside of the VM (think of ssh cmd). // outc receives combined cmd and kernel console output. // errc receives either command Wait return error or vmimpl.ErrTimeout. // Command is terminated after timeout. Send on the stop chan can be used to terminate it earlier. Run(timeout time.Duration, stop <-chan bool, command string) (outc <-chan []byte, errc <-chan error, err error) // Diagnose forces VM to dump additional debugging info // (e.g. sending some sys-rq's or SIGABORT'ing a Go program). // Returns true if it did anything. Diagnose() bool // Close stops and destroys the VM. Close() }
Instance represents a single VM.
type MergerError ¶
type MergerError struct { Name string R io.ReadCloser Err error }
func (MergerError) Error ¶
func (err MergerError) Error() string
type OutputMerger ¶
type OutputMerger struct { Output chan []byte Err chan error // contains filtered or unexported fields }
func NewOutputMerger ¶
func NewOutputMerger(tee io.Writer) *OutputMerger
func (*OutputMerger) Add ¶
func (merger *OutputMerger) Add(name string, r io.ReadCloser)
func (*OutputMerger) AddDecoder ¶
func (merger *OutputMerger) AddDecoder(name string, r io.ReadCloser, decoder func(data []byte) (start, size int, decoded []byte))
func (*OutputMerger) Wait ¶
func (merger *OutputMerger) Wait()
Click to show internal directories.
Click to hide internal directories.