reporters

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package reporters is a collection of canonical methods to obtain test-relevant information about a DUT. It should not modify the DUT state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RootPartition

func RootPartition(ctx context.Context, r *Reporter) (string, error)

RootPartition gets the root partition as reported by the 'rootdev -s' command.

Types

type BootedDeviceInfo

type BootedDeviceInfo struct {
	MainfwType string
	Removable  bool
	KernvfyKey string
}

BootedDeviceInfo groups all the info required to determine the correct BootedDeviceType

type BootedDeviceType

type BootedDeviceType string

BootedDeviceType is the set of mode,device,kernel verifier for the DUT.

const (
	BootedDeviceNormalInternalSig      BootedDeviceType = "normal mode booted from internal device, signature verified kernel key"
	BootedDeviceDeveloperInternalSig   BootedDeviceType = "developer mode booted from internal device, signature verified kernel key"
	BootedDeviceDeveloperRemovableSig  BootedDeviceType = "developer mode booted from removable device, signature verified kernel key"
	BootedDeviceDeveloperRemovableHash BootedDeviceType = "developer mode booted from removable device, hash verified kernel key"
	BootedDeviceRecoveryRemovableSig   BootedDeviceType = "recovery mode booted from removable device, signature verified kernel key"
	BootedDeviceRecoveryRemovableHash  BootedDeviceType = "recovery mode booted from removable device, hash verified kernel key"
)

The set of all possible BootedDeviceTypes, add more as needed.

type CrossystemParam

type CrossystemParam string

CrossystemParam represents known Crossystem attributes.

const (
	CrossystemParamBackupNvramRequest CrossystemParam = "backup_nvram_request"
	CrossystemParamDevBootUsb         CrossystemParam = "dev_boot_usb"
	CrossystemParamDevDefaultBoot     CrossystemParam = "dev_default_boot"
	CrossystemParamDevBootAltfw       CrossystemParam = "dev_boot_altfw"
	CrossystemParamDevswBoot          CrossystemParam = "devsw_boot"
	CrossystemParamFWBTries           CrossystemParam = "fwb_tries"
	CrossystemParamFWTryNext          CrossystemParam = "fw_try_next"
	CrossystemParamFWTryCount         CrossystemParam = "fw_try_count"
	CrossystemParamFWUpdatetries      CrossystemParam = "fwupdate_tries"
	CrossystemParamFWVboot2           CrossystemParam = "fw_vboot2"
	CrossystemParamKernkeyVfy         CrossystemParam = "kernkey_vfy"
	CrossystemParamLocIdx             CrossystemParam = "loc_idx"
	CrossystemParamMainfwAct          CrossystemParam = "mainfw_act"
	CrossystemParamMainfwType         CrossystemParam = "mainfw_type"
	CrossystemParamWpswCur            CrossystemParam = "wpsw_cur"
)

Crossystem params used by tests, add more as needed.

type Event

type Event struct {
	Timestamp time.Time
	Message   string
	Index     int
}

Event contains the contents of one line from `elogtool list`.

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter provides information about the DUT.

func New

func New(d *dut.DUT) *Reporter

New creates a reporter.

func (*Reporter) BatteryStatus

func (r *Reporter) BatteryStatus(ctx context.Context) (string, error)

BatteryStatus reports the device's battery status.

func (*Reporter) Board

func (r *Reporter) Board(ctx context.Context) (string, error)

Board reports the name of the DUT board, such as coral or veyron_minnie.

func (*Reporter) BootID

func (r *Reporter) BootID(ctx context.Context) (string, error)

BootID reports the device's Boot ID, which changes upon reboot.

func (*Reporter) BootedDevice

func (r *Reporter) BootedDevice(ctx context.Context) (BootedDeviceType, error)

BootedDevice reports the current BootedDeviceType of the DUT.

func (*Reporter) BuilderPath

func (r *Reporter) BuilderPath(ctx context.Context) (string, error)

BuilderPath reports release path of the build, such as grunt-release/R93-14023.0.0.

func (*Reporter) CatFile

func (r *Reporter) CatFile(ctx context.Context, path string) (string, error)

CatFile reports the file contents as a single string.

func (*Reporter) CatFileLines

func (r *Reporter) CatFileLines(ctx context.Context, path string) ([]string, error)

CatFileLines parses file contents by line and reports the list of lines.

func (*Reporter) CheckBootMode

func (r *Reporter) CheckBootMode(ctx context.Context, expected fwCommon.BootMode) (bool, error)

CheckBootMode verifies that the DUT's active firmware boot mode (normal, dev, rec) matches an expected boot mode.

func (*Reporter) CombinedOutput

func (r *Reporter) CombinedOutput(ctx context.Context, format string, args ...string) (string, error)

CombinedOutput reports the command stdout+stderr as a single string.

func (*Reporter) CommandOutput

func (r *Reporter) CommandOutput(ctx context.Context, format string, args ...string) (string, error)

CommandOutput reports the command output as a single string.

func (*Reporter) CommandOutputLines

func (r *Reporter) CommandOutputLines(ctx context.Context, format string, args ...string) ([]string, error)

CommandOutputLines parses command output by line and report the list of lines.

func (*Reporter) Crossystem

func (r *Reporter) Crossystem(ctx context.Context, requiredKeys ...CrossystemParam) (map[CrossystemParam]string, error)

Crossystem returns crossystem output as a map. Any required params not found in the output will cause an error. You must add `SoftwareDeps: []string{"crossystem"},` to your `testing.Test` to use this.

func (*Reporter) CrossystemParam

func (r *Reporter) CrossystemParam(ctx context.Context, param CrossystemParam) (string, error)

CrossystemParam returns the value of the param from crossystem <param> command.

func (*Reporter) CurrentBootMode

func (r *Reporter) CurrentBootMode(ctx context.Context) (fwCommon.BootMode, error)

CurrentBootMode reports the DUT's active firmware boot mode (normal, dev, rec). You must add `SoftwareDeps: []string{"crossystem"},` to your `testing.Test` to use this.

func (*Reporter) DoAllPathsExist

func (r *Reporter) DoAllPathsExist(ctx context.Context, paths []string) (bool, error)

DoAllPathsExist reports whether all given paths exist on the DUT.

func (*Reporter) EventlogList

func (r *Reporter) EventlogList(ctx context.Context) ([]Event, error)

EventlogList returns the result of `elogtool list`. The returned events are sorted from oldest to newest.

func (*Reporter) EventlogListAfter

func (r *Reporter) EventlogListAfter(ctx context.Context, previousEvent Event) ([]Event, error)

EventlogListAfter returns a list of events that occurred after a given index.

func (*Reporter) FWTries

FWTries returns the currently booted firmware, the next firmware that should be booted, and the try_count.

func (*Reporter) Model

func (r *Reporter) Model(ctx context.Context) (string, error)

Model reports the name of the DUT model, such as robo360 or minnie.

func (*Reporter) Now

func (r *Reporter) Now(ctx context.Context) (time.Time, error)

Now reports the output of the `date` command as a Go Time.

func (*Reporter) Vboot2

func (r *Reporter) Vboot2(ctx context.Context) (bool, error)

Vboot2 determines whether the DUT's current firmware was selected by vboot2.

Jump to

Keyboard shortcuts

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