Documentation ¶
Overview ¶
Package dut provides a connection to a DUT ("Device Under Test") for use by remote tests.
Index ¶
- Constants
- Variables
- type DUT
- func (d *DUT) Close(ctx context.Context) error
- func (d *DUT) Command(name string, args ...string) *ssh.Cmd
- func (d *DUT) CompanionDeviceHostname(suffix string) (string, 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) DefaultCameraboxChart(ctx context.Context) (*ssh.Conn, error)
- func (d *DUT) DefaultWifiPcapHost(ctx context.Context) (*ssh.Conn, error)
- func (d *DUT) DefaultWifiRouterHost(ctx context.Context) (*ssh.Conn, error)
- func (d *DUT) Disconnect(ctx context.Context) error
- func (d *DUT) GetFile(ctx context.Context, src, dst string) 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
- func (d *DUT) WifiPeerHost(ctx context.Context, index int) (*ssh.Conn, error)
Constants ¶
const ( // CompanionSuffixPcap is a companion suffix for the pcap. CompanionSuffixPcap = "-pcap" // CompanionSuffixRouter is a companion suffix for the router. CompanionSuffixRouter = "-router" // CompanionSuffixTablet is a companion suffix for the tablet. CompanionSuffixTablet = "-tablet" )
Suffix names for forward compatibility.
Variables ¶
var ErrCompanionHostname = errors.New("cannot derive default companion device hostname")
ErrCompanionHostname is the error of deriving default companion device hostname from dut's hostname. e.g. when DUT is connected with IP address.
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 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) Command ¶
Command returns the Cmd struct to execute the named program with the given arguments.
DEPRECATED: use d.Conn().Command
func (*DUT) CompanionDeviceHostname ¶
CompanionDeviceHostname derives the hostname of companion device from test target with the convention in Autotest. (see server/cros/dnsname_mangler.py in Autotest)
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) d.Conn().Command("uptime")
func (*DUT) Connect ¶
Connect establishes a connection to the DUT. If a connection already exists, it is closed first.
func (*DUT) DefaultCameraboxChart ¶
DefaultCameraboxChart connects to paired chart tablet in camerabox setup and returns SSH object.
func (*DUT) DefaultWifiPcapHost ¶
DefaultWifiPcapHost connects to the default WiFi pcap router and returns SSH object. DEPRECATED: Connect using CompanionDeviceHostname() instead.
func (*DUT) DefaultWifiRouterHost ¶
DefaultWifiRouterHost connects to the default WiFi router and returns SSH object. DEPRECATED: Connect using CompanionDeviceHostname() instead.
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)
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.
func (*DUT) WaitUnreachable ¶
WaitUnreachable waits for the DUT to become unreachable. It requires that a connection is already established to the DUT.