crostini

package
v0.0.0-...-683b059 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CrostiniAppTest = hwdep.D(hwdep.Model("hatch", "eve", "atlas", "nami"), CrostiniMinDiskSizeCond)

CrostiniAppTest is a hardware dependency limiting the boards on which app testing is run. App testing uses a large container which needs large space. Many DUTs in the lab do not have enough space. The boards listed have enough space.

View Source
var CrostiniMinDiskSize = hwdep.D(CrostiniMinDiskSizeCond)

CrostiniMinDiskSize is a hardware dependency that only runs tests on devices with at least 16 GB of storage.

View Source
var CrostiniMinDiskSizeCond = hwdep.MinStorage(16)

CrostiniMinDiskSizeCond is a hardware condition that only runs tests on models with > 12GB of disk size. Crostini needs a minimum of 3GB of free space to install which is frequently not available on devices with 8GB disks. For more see http://crbug.com/1039403

CrostiniStable is a hardware dependency that only runs a test on models that can run Crostini tests without known flakiness issues.

View Source
var CrostiniStableCond = hwdep.SkipOnModel(UnstableModels...)

CrostiniStableCond is a hardware condition that only runs a test on models that can run Crostini tests without known flakiness issues.

CrostiniUnstable is a hardware dependency that is the inverse of CrostiniStable. It only runs a test on models that are known to be flaky when running Crostini tests.

View Source
var CrostiniUnstableCond = hwdep.Model(UnstableModels...)

CrostiniUnstableCond is a hardware condition that is the inverse of CrostiniStableCond. It only runs a test on models that are known to be flaky when running Crostini tests.

View Source
var PostTimeout = 30 * time.Second

PostTimeout is the standard time reserved for post-test tasks.

View Source
var UnstableModels = []string{

	"paine",
	"yuna",

	"bob",

	"buddy",

	"astronaut",
	"blacktip360",
	"blacktiplte",
	"bruce",
	"lava",
	"nasher",

	"elm",

	"edgar",

	"wukong",

	"jax",

	"gandof",

	"aleena",
	"barla",
	"careena",
	"treeya",

	"guado",

	"hana",

	"kevin",

	"krane",

	"lulu",

	"nocturne",

	"ampton",
	"apel",
	"bloog",
	"bluebird",
	"droid",
	"fleex",
	"foob",
	"garg",
	"laser14",
	"mimrock",
	"phaser360",
	"sparky",
	"vorticon",
	"vortininja",

	"electro",

	"arcada",

	"samus",

	"banon",
	"celes",
	"cyan",
	"relm",
	"terra",
	"wizpig",
	"ultima",
	"kefka",
	"reks",

	"tidus",

	"lazor",
	"limozeen",
	"pompom",
}

UnstableModels is list of models that are too flaky for the CQ. Use the standard tast criteria at go/tast-add-test to judge whether it should be on the CQ.

Functions

func BasicCommandWorks

func BasicCommandWorks(ctx context.Context, cont *vm.Container) error

BasicCommandWorks executes a command in the container and returns an error if it fails.

func CloseAllWindows

func CloseAllWindows(ctx context.Context, tconn *chrome.TestConn) error

CloseAllWindows closes all currently open windows by iterating over the shelf icons and calling autotestPrivate.closeApp on each one.

func GaiaLoginAvailable

func GaiaLoginAvailable(s varState) bool

GaiaLoginAvailable returns whether or not a real gaia account is in use. This requires some variables from tast-tests-private

func GetContainerMetadataArtifact

func GetContainerMetadataArtifact(debianVersion vm.ContainerDebianVersion, largeContainer bool) string

GetContainerMetadataArtifact gets the container metadata artifact for the container parameters. Note that this function will return different values on different architectures.

func GetContainerRootfsArtifact

func GetContainerRootfsArtifact(debianVersion vm.ContainerDebianVersion, largeContainer bool) string

GetContainerRootfsArtifact gets the container rootfs artifact for the container parameters. Note that this function will return different values on different architectures.

func GetInstallerOptions

func GetInstallerOptions(s testingState, debianVersion vm.ContainerDebianVersion, largeContainer bool, userName string) *cui.InstallationOptions

GetInstallerOptions returns an InstallationOptions struct with data paths, and debian version set appropriately for the test.

func LaunchGUIApp

func LaunchGUIApp(ctx context.Context, tconn *chrome.TestConn, cmd *testexec.Cmd) (string, func(), error)

LaunchGUIApp runs the given command, which is meant to be a crostini application with a GUI, and returns:

  • A string, containing the ID of the app that was ran (i.e., a handle which can be used to inspect/close the app).
  • A callback which can be executed to close the application. Users of this function should immediately defer the callback if one is returned.
  • An error, which indicates something went wrong, or nil otherwise.

func MakeTestParams

func MakeTestParams(t genparams.TestingT) string

MakeTestParams generates the default set of crostini test parameters using MakeTestParamsFromList. If your test only needs to be parameterized over how crostini is acquired and which version is installed, use this. Otherwise, you may need to use MakeTestParamsFromList.

Sub-tests which are not eligible for being on the CQ (unstable or download tests) will be tagged informational. Whether the test as a whole is CQ-critical should be controlled by a test-level informational attribute.

func MakeTestParamsFromList

func MakeTestParamsFromList(t genparams.TestingT, baseCases []Param) string

MakeTestParamsFromList takes a list of test cases (in the form of crostini.Param objects) and generates a set of crostini test parameters for each. See the documentation for crostini.Param for how these values effect the results. Each crostini.Param object is treated independently, producing its own set of sub-tests.

Normally you should use MakeTestParams instead, but if your test is parameterized beyond which crostini preconditions it uses, you will need this.

func MatchScreenshotDominantColor

func MatchScreenshotDominantColor(ctx context.Context, cr *chrome.Chrome, expectedColor color.Color, screenshotPath string) error

MatchScreenshotDominantColor takes a screenshot and attempts to verify if it mostly (>= 1/2) contains the expected color. Will retry for up to 10 seconds if it fails. For logging purposes, the screenshot will be saved at the given path.

func PollWindowSize

func PollWindowSize(ctx context.Context, tconn *chrome.TestConn, name string, timeout time.Duration) (sz coords.Size, err error)

PollWindowSize returns the the width and the height of the window in pixels with polling to wait for asynchronous rendering on the DUT.

func PrimaryDisplayScaleFactor

func PrimaryDisplayScaleFactor(ctx context.Context, tconn *chrome.TestConn) (factor float64, err error)

PrimaryDisplayScaleFactor returns the primary display's scale factor.

func RemoveContainerFile

func RemoveContainerFile(ctx context.Context, cont *vm.Container, containerPath string) error

RemoveContainerFile removes a file from the container's file system. This is useful for cleaning up files placed in the container by TransferToContainer().

func RunCrostiniPostTest

func RunCrostiniPostTest(ctx context.Context, p PreData)

RunCrostiniPostTest runs hooks that should run after every test but before the precondition closes (if it's going to) e.g. collecting logs from the container.

func RunWindowedApp

func RunWindowedApp(ctx context.Context, tconn *chrome.TestConn, cont *vm.Container, keyboard *input.KeyboardEventWriter, timeout time.Duration, condition func(context.Context) error, closeWindow bool, windowName string, cmdline []string) (string, error)

RunWindowedApp Runs the command cmdline in the container, waits for the window windowName to open, sends it a key press event, runs condition, and then closes all open windows. Note that this will close windows other then the one with title windowName! The return value is a string containing the what program wrote to stdout. The intended use of condition is to delay closing the application window until some event has occurred. If condition returns an error then the call will be considered a failure and the error will be propagated.

func StartedByDlcBullseye

func StartedByDlcBullseye() testing.Precondition

StartedByDlcBullseye ensures that a VM running bullseye has started before the test runs. This precondition has complex requirements to use that are best met using the test parameter generator in params.go. Tip: Run tests with -var=keepState=true to speed up local development

func StartedByDlcBullseyeGaia

func StartedByDlcBullseyeGaia() testing.Precondition

StartedByDlcBullseyeGaia is similar to StartedByDlcBullseye, except for logging in to Chrome using gaia user.

func StartedByDlcBuster

func StartedByDlcBuster() testing.Precondition

StartedByDlcBuster ensures that a VM running buster has started before the test runs. This precondition has complex requirements to use that are best met using the test parameter generator in params.go. Tip: Run tests with -var=keepState=true to speed up local development

func StartedByDlcBusterGaia

func StartedByDlcBusterGaia() testing.Precondition

StartedByDlcBusterGaia is similar to StartedByDlcBuster, except for logging in to Chrome using gaia user.

func StartedByDlcBusterLargeContainer

func StartedByDlcBusterLargeContainer() testing.Precondition

StartedByDlcBusterLargeContainer is similar to StartedByDlcBuster, but will download the large container which has apps (Gedit, Emacs, Eclipse, Android Studio, and Visual Studio) installed.

func TakeAppScreenshot

func TakeAppScreenshot(appName string) uiauto.Action

TakeAppScreenshot takes a screenshot and saves it to the test context output directory. On error will print a message and continue.

func TransferToContainer

func TransferToContainer(ctx context.Context, cont *vm.Container, hostPath, containerPath string) error

TransferToContainer copies a file from the host's filesystem to the containers.

func TransferToContainerAsRoot

func TransferToContainerAsRoot(ctx context.Context, cont *vm.Container, hostPath, containerPath string) error

TransferToContainerAsRoot is similar to TransferToContainer() but works as the root user.

func VerifyFileInContainer

func VerifyFileInContainer(ctx context.Context, cont *vm.Container, containerPath string) error

VerifyFileInContainer checks for file existance in the container, returning an error if it fails (or fails to find it).

func VerifyFileNotInContainer

func VerifyFileNotInContainer(ctx context.Context, cont *vm.Container, containerPath string) error

VerifyFileNotInContainer works much like the above, but for absent files.

func VerifyWindowDensities

func VerifyWindowDensities(ctx context.Context, tconn *chrome.TestConn, sizeHighDensity, sizeLowDensity coords.Size) error

VerifyWindowDensities compares the sizes, which should be from PollWindowSize() at low and high density. It returns an error if something is wrong with the sizes (not just if the high-density window is bigger).

Types

type DemoConfig

type DemoConfig struct {
	// Name identifies the demo configuration (e.g. "x11" is the demo which
	// verifies that we can render x11 windows).
	Name string
	// AppPath is the path to the demo's executable.
	AppPath string
	// DominantColot is used to paint the demo's window. By convention, we
	// associate demo windows with colors (in order to easily identify
	// screenshots).
	DominantColor color.Color
}

The DemoConfig object holds a configuration for running a tast test that uses one of the demo applications.

func WaylandDemoConfig

func WaylandDemoConfig() DemoConfig

WaylandDemoConfig returns the configuration needed to run demo tests based on the wayland_demo app.

func X11DemoConfig

func X11DemoConfig() DemoConfig

X11DemoConfig returns the configuration needed to run demo tests based on the x11_demo app.

type FixtureData

type FixtureData struct {
	ParentFixtV chrome.HasChrome
	Tconn       *chrome.TestConn
	Cont        *vm.Container
	KB          *input.KeyboardEventWriter
	PostData    *PostTestData
}

FixtureData is the data returned by SetUp and passed to tests.

type Param

type Param struct {
	// Name of the test case. Generated tests will look like
	// "name_amd64_buster_stable", "name_arm_bullseye_unstable"
	// etc.
	Name string

	// ExtraAttr contains additional attributes to add to the
	// generated test's ExtraAttr field beyond what the generator
	// function adds. For example, if you want this test case to
	// be in the "graphics_daily" group without putting the whole
	// test in, you can add that label here.
	ExtraAttr []string

	// ExtraData contains paths of additional data files needed by
	// the test case. Note that data files required for specific
	// crostini preconditions are added automatically to the
	// generated tests and should not be added here.
	ExtraData []string

	// ExtraSoftwareDeps lists software features that are required
	// to run this test case.
	ExtraSoftwareDeps []string

	// Timeout indicates the timeout for this test case. If
	// unspecified, defaults to 7 * time.Minute.
	Timeout time.Duration

	// Val is a freeform value that can be retrieved from
	// testing.State.Param() method. This string is inserted
	// unmodified and unquoted into the generated test case code
	// as the Val for each test case generated for this object.
	Val string

	// SelfManagedInstall indicates that this test will be
	// installing crostini itself, and therefore there should be
	// no crostini install precondition set.
	SelfManagedInstall bool

	// StableHardwareDep contains a go expression that evaluates
	// to a hardware dependency which controls the collection of
	// boards considered stable.
	StableHardwareDep string

	// UnstableHardwareDep contains a go expression that evaluates
	// to a hardware dependency which controls the collection of
	// boards considered unstable. It should be the inverse of
	// StableHardwareDep.
	UnstableHardwareDep string

	// MinimalSet - if true, generate only a minimal set of test
	// parameters such that each device will have at most one test
	// case it can run. This is useful for things like performance
	// tests, which are too expensive to be run in every possible
	// configuration.
	MinimalSet bool

	// IsNotMainline indicates whether the test case is in
	// group:mainline or not. This is important to get right
	// because we can't add the "informational" attribute to
	// non-mainline tests, but leaving it off of a mainline test
	// will cause the test case to become CQ critical. If in
	// doubt, set to false, and if you're wrong you will get an
	// error message when you try to run your tests.
	//
	// This also controls whether separate stable/unstable tests
	// are generated, since this distinction is only relevant to
	// the CQ.
	IsNotMainline bool

	// UseLargeContainer controls whether to use the normal test
	// container, or a larger container with more applications
	// pre-installed.
	UseLargeContainer bool

	// OnlyStableBoards controls whether to only use the stable
	// board variants and exclude all the unstable variants.
	OnlyStableBoards bool

	// UseGaiaLogin controls whether using gaia user to login
	// to the DUT.
	UseGaiaLogin bool

	// UseFixture controls whether using fixture or precondition to
	// set up Crostini and cleanup tests.
	// This is used to migrate the tests from precondition to fixture.
	// TODO (jinrongwu): remove this once the migration is done.
	UseFixture bool

	// TestLacros controls whether the test case tests Lacros.
	// If yes, an extra param will be added with fixture crostiniBullseyeWithLacros.
	// In addition, an extra val of the browser type will
	// be added to all params of the test case as well.
	TestLacros bool
}

Param specifies how each set of crostini tests should be generated.

type PostTestData

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

PostTestData contains data for post test tasks in post.go that should be persistent across tests.

type PreData

type PreData struct {
	Chrome      *chrome.Chrome
	TestAPIConn *chrome.TestConn
	Container   *vm.Container
	Keyboard    *input.KeyboardEventWriter

	Post *PostTestData
}

The PreData object is made available to users of this precondition via:

func DoSomething(ctx context.Context, s *testing.State) {
	d := s.PreValue().(crostini.PreData)
	...
}

func (*PreData) Connect

func (p *PreData) Connect(ctx context.Context) error

Connect connects the precondition to a running VM/container. If you shutdown and restart the VM you will need to call Connect again.

Directories

Path Synopsis
Package faillog contains a method for dumping useful information on error
Package faillog contains a method for dumping useful information on error
Package lxd is a fake lxd simplestreams server that serves container images for Crostini tests.
Package lxd is a fake lxd simplestreams server that serves container images for Crostini tests.
Package perfutil contains utilities needed for VM performance testing.
Package perfutil contains utilities needed for VM performance testing.
ui
Package ui contains functions to interact with the ChromeOS parts of the crostini UI.
Package ui contains functions to interact with the ChromeOS parts of the crostini UI.
linuxfiles
Package linuxfiles supports actions on Linux files on Files app.
Package linuxfiles supports actions on Linux files on Files app.
settings
Package settings provides support for the Linux settings on the Settings app.
Package settings provides support for the Linux settings on the Settings app.
sharedfolders
Package sharedfolders provides support for sharing folders with Crostini.
Package sharedfolders provides support for sharing folders with Crostini.
terminalapp
Package terminalapp supports actions on Terminal on Chrome OS.
Package terminalapp supports actions on Terminal on Chrome OS.

Jump to

Keyboard shortcuts

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