Documentation ¶
Overview ¶
Package ti50 implements shared libraries for ti50 testing.
Index ¶
- func Demo(ctx context.Context, board DevBoard, image string) error
- func DemoCommand(ctx context.Context, i *CrOSImage, cmd string) error
- func DemoHelp(ctx context.Context, i *CrOSImage) error
- func DemoRawCommand(ctx context.Context, i *CrOSImage, cmd string, re *regexp.Regexp) error
- func ListConnectedUltraDebugTargets(ctx context.Context) ([]string, error)
- func ParseUltraDebugTargets(devs string) []string
- type Andreiboard
- func (a *Andreiboard) Close(ctx context.Context) error
- func (a *Andreiboard) FlushSerial(ctx context.Context) error
- func (a *Andreiboard) GetSpiFlash() string
- func (a *Andreiboard) IsOpen() bool
- func (a *Andreiboard) Open(ctx context.Context) error
- func (a *Andreiboard) ReadSerialSubmatch(ctx context.Context, re *regexp.Regexp) (output [][]byte, err error)
- func (a *Andreiboard) WriteSerial(ctx context.Context, b []byte) error
- type CommandImage
- func (i *CommandImage) Command(ctx context.Context, cmd string) (string, error)
- func (i *CommandImage) GetPrompt(ctx context.Context) error
- func (i *CommandImage) RawCommand(ctx context.Context, rawCmd string, re *regexp.Regexp) ([]string, error)
- func (i *CommandImage) WaitUntilBooted(ctx context.Context, interval time.Duration) error
- type ConnectedAndreiboard
- type CrOSImage
- type CrOSImageHelpOutput
- type DevBoard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Demo ¶
Demo uses some of the CrOSImage to control the board. Image is optional, will demo on existing image if set to "".
func DemoCommand ¶
DemoCommand demos the Command method.
func DemoRawCommand ¶
DemoRawCommand demos the RawCommand method.
func ListConnectedUltraDebugTargets ¶
ListConnectedUltraDebugTargets finds list of UltraDebug targets connected.
func ParseUltraDebugTargets ¶
ParseUltraDebugTargets extracts list of UltraDebug target ports from device file listings.
Types ¶
type Andreiboard ¶
type Andreiboard struct {
// contains filtered or unexported fields
}
Andreiboard contains common implementations boards.
func NewAndreiboard ¶
func NewAndreiboard(bufMax int, portOpener serial.PortOpener, spiFlash string) *Andreiboard
NewAndreiboard creates a new port, bufMax should be set to the max number of bytes read that are not yet matched by ReadSerialSubmatch.
func (*Andreiboard) Close ¶
func (a *Andreiboard) Close(ctx context.Context) error
Close closes the console port.
func (*Andreiboard) FlushSerial ¶
func (a *Andreiboard) FlushSerial(ctx context.Context) error
FlushSerial flushes un-read/written chars.
func (*Andreiboard) GetSpiFlash ¶
func (a *Andreiboard) GetSpiFlash() string
GetSpiFlash gets the path to previously set spiflash.
func (*Andreiboard) IsOpen ¶
func (a *Andreiboard) IsOpen() bool
IsOpen returns true iff the port is open.
func (*Andreiboard) Open ¶
func (a *Andreiboard) Open(ctx context.Context) error
Open opens the console port.
func (*Andreiboard) ReadSerialSubmatch ¶
func (a *Andreiboard) ReadSerialSubmatch(ctx context.Context, re *regexp.Regexp) (output [][]byte, err error)
ReadSerialSubmatch reads from the serial port until regex is matched.
func (*Andreiboard) WriteSerial ¶
func (a *Andreiboard) WriteSerial(ctx context.Context, b []byte) error
WriteSerial writes to the serial port.
type CommandImage ¶
type CommandImage struct {
// contains filtered or unexported fields
}
CommandImage displays a prompt and responds to cli commands.
func NewCommandImage ¶
func NewCommandImage(board DevBoard, promptCmd, promptPattern string) *CommandImage
NewCommandImage creates a new CommandImage. Typical examples of promptCmd and promptPattern are "\r" and "\n\r> " respectively.
func (*CommandImage) Command ¶
Command sends the command to the image and returns the output from after the command up to the next prompt.
func (*CommandImage) GetPrompt ¶
func (i *CommandImage) GetPrompt(ctx context.Context) error
GetPrompt gets a fresh prompt from the image by the prompt.
func (*CommandImage) RawCommand ¶
func (i *CommandImage) RawCommand(ctx context.Context, rawCmd string, re *regexp.Regexp) ([]string, error)
RawCommand sends a command to the image and waits for the regex to be matched before returning the captured groups. It does not append the promptCmd as opposed to Command.
func (*CommandImage) WaitUntilBooted ¶
WaitUntilBooted by checking that prompts are consistently displayed.
type ConnectedAndreiboard ¶
type ConnectedAndreiboard struct {
*Andreiboard
}
ConnectedAndreiboard is one that is directly connected via serial port to the localhost. Localhost being the dut for a test in the local bundle and the drone/workstation for one that's in the remote bundle.
func NewConnectedAndreiboard ¶
func NewConnectedAndreiboard(targetDevice string, bufSize int, spiFlash string, readTimeout time.Duration) *ConnectedAndreiboard
NewConnectedAndreiboard creates a ConnectedAndreiboard. bufSize is the max number of expected un-read bytes. spiFlash is the path to the spiflash executable. readTimeout is the max duration of expected silence during reads.
Example:
device, _ := ListConnectedUltraDebugTargets(ctx) if len(device) == 0 { testing.ContextLog(ctx, "Could not find any UD device") } board := NewConnectedAndreiboard(device, 4096, "/path/to/spi/flash", 1 * time.Second)
func (*ConnectedAndreiboard) FlashImage ¶
func (a *ConnectedAndreiboard) FlashImage(ctx context.Context, image string) error
FlashImage flashes an image to the board.
type CrOSImage ¶
type CrOSImage struct {
*CommandImage
}
CrOSImage interacts with a board running ti50.
func NewCrOSImage ¶
NewCrOSImage creates a new CrOSImage.
type CrOSImageHelpOutput ¶
CrOSImageHelpOutput holds relevant data from the 'help' command.
type DevBoard ¶
type DevBoard interface { // Open opens the console port. Open(ctx context.Context) error // ReadSerialSubmatch reads output from port until regex is matched. ReadSerialSubmatch(ctx context.Context, re *regexp.Regexp) (output [][]byte, err error) // WriteSerial writes to port. WriteSerial(ctx context.Context, bytes []byte) error // FlushSerial flushes un-read/written chars from port. FlushSerial(ctx context.Context) error // FlashImage flashes image on DevBoard. FlashImage(ctx context.Context, imagePath string) error // Reset the DevBoard. Reset(ctx context.Context) error // Close closes the console port. Close(ctx context.Context) error }
DevBoard is the generic interface for development boards.