dut

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package dut provides a connection to a DUT ("Device Under Test") for use by remote tests.

Index

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) Close

func (d *DUT) Close(ctx context.Context) error

Close releases the DUT's resources.

func (*DUT) Conn

func (d *DUT) Conn() *ssh.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

func (d *DUT) Connect(ctx context.Context) error

Connect establishes a connection to the DUT. If a connection already exists, it is closed first.

func (*DUT) Connected

func (d *DUT) Connected(ctx context.Context) bool

Connected returns true if a usable connection to the DUT is held.

func (*DUT) Disconnect

func (d *DUT) Disconnect(ctx context.Context) error

Disconnect closes the current connection to the DUT. It is a no-op if no connection is currently established.

func (*DUT) GetFile

func (d *DUT) GetFile(ctx context.Context, src, dst string) error

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) Health

func (d *DUT) Health(ctx context.Context) error

Health checks the connection status with the DUT.

func (*DUT) HostName

func (d *DUT) HostName() string

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

func (d *DUT) KeyDir() string

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

func (d *DUT) KeyFile() string

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) ProxyCommand

func (d *DUT) ProxyCommand() string

ProxyCommand returns the proxy command that is used to connect to the DUT. This is provided for tests that may need to establish SSH connections to additional hosts (e.g. a labstation and you want to test locally without any ssh forwards).

func (*DUT) Reboot

func (d *DUT) Reboot(ctx context.Context) error

Reboot reboots the DUT.

func (*DUT) RebootWithCommand

func (d *DUT) RebootWithCommand(ctx context.Context, cmd string, args ...string) error

RebootWithCommand reboots the DUT with a specific command. The command might be one that causes the DUT to crash or hang which will eventually lead to a reboot of some sort.

func (*DUT) WaitConnect

func (d *DUT) WaitConnect(ctx context.Context) error

WaitConnect connects to the DUT, waiting for it to become reachable. If a connection already exists, it is closed first.

func (*DUT) WaitUnreachable

func (d *DUT) WaitUnreachable(ctx context.Context) error

WaitUnreachable waits for the DUT to become unreachable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL