Documentation ¶
Overview ¶
Package dut provides a connection to a DUT ("Device Under Test") for use by remote tests.
Index ¶
- type DUT
- func (d *DUT) Close(ctx context.Context) error
- func (d *DUT) Conn() *ssh.Conn
- func (d *DUT) Connect(ctx context.Context) error
- func (d *DUT) Connected(ctx context.Context) bool
- func (d *DUT) Disconnect(ctx context.Context) error
- func (d *DUT) GetFile(ctx context.Context, src, dst string) error
- func (d *DUT) Health(ctx context.Context) error
- func (d *DUT) HostName() string
- func (d *DUT) KeyDir() string
- func (d *DUT) KeyFile() string
- func (d *DUT) Reboot(ctx context.Context) error
- func (d *DUT) WaitConnect(ctx context.Context) error
- func (d *DUT) WaitUnreachable(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DUT ¶
type DUT struct {
// contains filtered or unexported fields
}
DUT represents a "Device Under Test" against which remote tests are run.
func New ¶
func New(target, keyFile, keyDir, proxyCommand string, beforeReboot func(context.Context, *DUT) error) (*DUT, error)
New returns a new DUT usable for communication with target (of the form "[<user>@]host[:<port>]") using the SSH key at keyFile or keys located in keyDir. The DUT does not start out in a connected state; Connect must be called.
func (*DUT) Conn ¶
Conn returns the connection to the DUT, or nil if there is no connection. The ownership of the connection is managed by *DUT, so don't call Close for the connection. To disconnect, call DUT.Disconnect. Storing the returned value into a variable is not recommended, because after reconnection (e.g. by Reboot), the instance previous Conn returned is stale. Always call Conn to get the present connection.
Examples:
linuxssh.GetFile(ctx, d.Conn(), src, dst, linuxssh.PreserveSymlinks) d.Conn().CommandContext("uptime")
func (*DUT) Connect ¶
Connect establishes a connection to the DUT. If a connection already exists, it is closed first.
func (*DUT) Disconnect ¶
Disconnect closes the current connection to the DUT. It is a no-op if no connection is currently established.
func (*DUT) GetFile ¶
GetFile copies a file or directory from the DUT to the local machine. dst is the full destination name for the file or directory being copied, not a destination directory into which it will be copied. dst will be replaced if it already exists.
DEPRECATED: use linuxssh.GetFile(ctx, d.Conn(), src, dst, linuxssh.PreserveSymlinks)
func (*DUT) HostName ¶
HostName returns the a string representing the "<dut_hostname>:<ssh_port>" used to connect to the DUT. This is provided for tests that may need to establish direct SSH connections to hosts. (e.g. syzkaller connecting to a host).
func (*DUT) KeyDir ¶
KeyDir returns the path to the directory containing SSH private keys used to connect to the DUT. This is provided for tests that may need to establish SSH connections to additional hosts (e.g. a host running a servod instance).
func (*DUT) KeyFile ¶
KeyFile returns the path to the SSH private key used to connect to the DUT. This is provided for tests that may need to establish SSH connections to additional hosts (e.g. a host running a servod instance).
func (*DUT) WaitConnect ¶
WaitConnect connects to the DUT, waiting for it to become reachable. If a connection already exists, it is closed first.