graphics

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: 31 Imported by: 0

Documentation

Overview

Package graphics contains graphics-related utility functions for local tests.

Package graphics contains graphics-related utility functions for local tests.

Package graphics contains graphics-related utility functions for local tests.

Package graphics contains graphics-related utility functions for local tests.

Package graphics contains graphics-related utility functions for local tests.

Package graphics contains graphics-related utility functions for local tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DEQPEnvironment

func DEQPEnvironment(env []string) []string

DEQPEnvironment returns a list of environment variables of the form "key=value" that are appropriate for running DEQP binaries. To build it, the function starts from the given environment and modifies the LD_LIBRARY_PATH to insert /usr/local/lib:/usr/local/lib64 in the front, even if those two folders are already in the value. This is a port of part of the functionality of the initialization defined in autotest/files/client/site_tests/graphics_dEQP/graphics_dEQP.py.

func DEQPExecutable

func DEQPExecutable(api APIType) (string, error)

DEQPExecutable maps an API identifier to the path of the appropriate DEQP executable (or an empty string if the API identifier is not valid). This is a port of part of the functionality of GraphicsApiHelper defined in autotest/files/client/cros/graphics/graphics_utils.py.

func DEQPOutcomeIsFailure

func DEQPOutcomeIsFailure(s string) bool

DEQPOutcomeIsFailure decides if an outcome found in the output of a DEQP test is considered a failure.

func DumpModetestOnError

func DumpModetestOnError(ctx context.Context, outDir string, hasError func() bool)

DumpModetestOnError dumps the output of modetest to a file if the test failed.

func GLESVersion

func GLESVersion(ctx context.Context) (major, minor int, err error)

GLESVersion returns the OpenGL major and minor versions extracted from the output of the wflinfo command. This is roughly a port of get_gles_version() defined in autotest/files/client/cros/graphics/graphics_utils.py.

func GetDirtyWritebackDuration

func GetDirtyWritebackDuration() (time.Duration, error)

GetDirtyWritebackDuration reads the dirty_writeback_centisecs kernel parameter and returns it as a time.Duration (in nanoseconds). Note that it is possible for the returned value to be negative. This is a port of the get_dirty_writeback_centisecs() function in autotest/files/client/bin/utils.py.

func GetHangCheckTimer

func GetHangCheckTimer() (time.Duration, error)

GetHangCheckTimer returns the current hangcheck duration timer. If multiple hangcheck configuration paths are found, it returns the smallest timer among all the configurations. Notice that it is expected to fail if running on older kernels and it is better to produce a warning instead of failing.

func MeasureCPUUsageAndPower

func MeasureCPUUsageAndPower(ctx context.Context, stabilization, measurement time.Duration, p *perf.Values) error

MeasureCPUUsageAndPower measures CPU usage and power consumption (if supported) for measurement time into p. If the optional stabilization duration is specified, the test will sleep for such amount of time before measuring.

Optionally, clients of this method might like to call cpu.SetUpBenchmark() and cpu.WaitUntilIdle() before starting the actual test logic, to set up and wait for the CPU usage to stabilize to a low level. Example:

import "chromiumos/tast/local/media/cpu"

cleanUpBenchmark, err := cpu.SetUpBenchmark(ctx)
if err != nil {
  return errors.Wrap(err, "failed to set up CPU benchmark")
}
defer cleanUpBenchmark(ctx)

if err := cpu.WaitUntilIdle(ctx); err != nil {
  return errors.Wrap(err, "failed waiting for CPU to become idle")
}

func MeasureFdCount

func MeasureFdCount(ctx context.Context, duration time.Duration, p *perf.Values) error

MeasureFdCount counts the average and peak number of open FDs by the GPU process(es) during playback. Polls every 1 seconds up until the duration given.

func MeasureGPUCounters

func MeasureGPUCounters(ctx context.Context, t time.Duration, p *perf.Values) error

MeasureGPUCounters measures GPU usage for a period of time t into p.

func MeasurePackageCStateCounters

func MeasurePackageCStateCounters(ctx context.Context, t time.Duration, p *perf.Values) error

MeasurePackageCStateCounters measures the Package C-State residencies for a period of time t into p. Package C-States counters report how many cycles the package was in a given state, with a larger index corresponding to deeper sleep states. The total elapsed cycles is available under the first CPU's TSC (Time Stamp Counter) register. The "active " state, which would be c0, is the remaining cycles. See e.g. https://en.wikichip.org/wiki/acpi/c-states.

func NumberOfOutputsConnected

func NumberOfOutputsConnected(ctx context.Context) (int, error)

NumberOfOutputsConnected parses the output of modetest to determine the number of connected displays. And returns the number of connected displays.

func ParseDEQPOutput

func ParseDEQPOutput(p string) (stats map[string]uint, nonFailed []string, err error)

ParseDEQPOutput parses the given DEQP log file to extract the number of tests per outcome (returned in the stats map) and the names of the non-failed tests (returned in the nonFailed slice). An error is returned if an unrecoverable error occurs, i.e., an error that suggests problems with the DEQP output.

The returned stats map might look something like

"pass": 3
"fail": 1

This means that 3 tests passed and 1 failed. The keys are always lowercase. When a recoverable error occurs, it is reported in the stats map with the reserved outcome "parsefailed".

This parser expects the format explained in https://android.googlesource.com/platform/external/deqp/+/deqp-dev/doc/qpa_file_format.txt but only cares about the #beginTestCaseResult ... #endTestCaseResult or #beginTestCaseResult ... #terminateTestCaseResult sections.

func RotateDisplayToLandscapePrimary

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

RotateDisplayToLandscapePrimary rotates the display to landscape-primary defined in https://w3c.github.io/screen-orientation/#screenorientation-interface.

func SetDirtyWritebackDuration

func SetDirtyWritebackDuration(ctx context.Context, d time.Duration) error

SetDirtyWritebackDuration flushes pending data to disk and sets the dirty_writeback_centisecs kernel parameter to a specified time. If the time is negative, it only flushes pending data without changing the kernel parameter. This function should be used before starting graphics tests to shorten the time between flushes so that logs retain as much information as possible in case the system hangs/reboots. Note that the specified time is rounded down to the nearest centisecond. This is a port of the set_dirty_writeback_centisecs() function in autotest/files/client/bin/utils.py.

func SetHangCheckTimer

func SetHangCheckTimer(ctx context.Context, d time.Duration) error

SetHangCheckTimer sets the hangcheck timer to d to allow longer gpu runtime before hangcheck kicks in. If multiple hangcheck configuration paths are found, all of them are modified. Notice that it is expected to fail if running on older kernels. Notice that the unit of hangcheck timer is millisecond and the function would fail if d is smaller or equal to 1 millisecond.

func SupportsVulkanForDEQP

func SupportsVulkanForDEQP(ctx context.Context) (bool, error)

SupportsVulkanForDEQP decides whether the board supports Vulkan for DEQP testing. An error is returned if something unexpected happens while deciding. This is a port of part of the functionality of GraphicsApiHelper defined in autotest/files/client/cros/graphics/graphics_utils.py.

func UpdatePerfMetricFromHistogram

func UpdatePerfMetricFromHistogram(ctx context.Context, tconn *chrome.TestConn, histogramName string, initHistogram *metrics.Histogram, perfValues *perf.Values, metricName string) error

UpdatePerfMetricFromHistogram takes a snapshot of histogramName and calculates the average difference with initHistogram. The result is then logged to perfValues with metricName.

func VerifyGraphicsMemory

func VerifyGraphicsMemory(ctx context.Context, payload func() error, backend Backend, sizes []Size) (err error)

VerifyGraphicsMemory uses the backend to detect memory leaks during or after the execution of payload.

Types

type APIType

type APIType int

APIType identifies a graphics API that can be tested by DEQP.

const (
	// UnknownAPI represents an unknown API.
	UnknownAPI APIType = iota
	// EGL represents Khronos EGL.
	EGL
	// GLES2 represents OpenGL ES 2.0.
	GLES2
	// GLES3 represents OpenGL ES 3.0.
	GLES3
	// GLES31 represents OpenGL ES 3.1. Note that DEQP also includes OpenGL ES
	// 3.2 in this category to reduce testing time.
	GLES31
	// VK represents Vulkan.
	VK
)

func SupportedAPIs

func SupportedAPIs(glMajor, glMinor int, vulkan bool) []APIType

SupportedAPIs returns an array of supported APIs given the OpenGL version and whether Vulkan is supported. If no APIs are supported, nil is returned. This is a port of part of the functionality of GraphicsApiHelper defined in autotest/files/client/cros/graphics/graphics_utils.py.

func (APIType) String

func (a APIType) String() string

Provided for getting readable API names.

type Backend

type Backend interface {
	// Round implements the platform-specific graphic- or codec- rounding.
	Round(value int) int

	// ReadFramebufferCount tries to retrieve the number of framebuffers of width
	// and height dimensions allocated by the Backend.
	ReadFramebufferCount(ctx context.Context, width, height int) (framebuffers int, err error)
}

Backend contains the necessary methods to interact with the platform debug interface and getting readings.

func GetBackend

func GetBackend() (Backend, error)

GetBackend tries to get the appropriate platform graphics debug backend and returns it, or returns an error.

type Connector

type Connector struct {
	Cid       int    // connector id
	Connected bool   // true if the connector is connected
	Name      string // name of the connector
	Encoders  []int  // encoders id
}

Connector identifies the attributes related to display connector.

func ModetestConnectors

func ModetestConnectors(ctx context.Context) ([]*Connector, error)

ModetestConnectors retrieves a list of connectors using modetest.

type GenericBackend

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

GenericBackend implements Backend for the Generic case (Intel and AMD).

func (GenericBackend) ReadFramebufferCount

func (g GenericBackend) ReadFramebufferCount(ctx context.Context, width, height int) (framebuffers int, e error)

ReadFramebufferCount tries to open the DRM device file and count the amount of lines of dimensions width x height, which corresponds to the amount of framebuffers allocated in the system. See https://dri.freedesktop.org/docs/drm/gpu/amdgpu.html

func (GenericBackend) Round

func (g GenericBackend) Round(value int) int

Round rounds up value for the Generic Debugfs platforms and all codecs.

type I915Backend

type I915Backend struct{}

I915Backend implements Backend for the Intel i915 case.

func (I915Backend) ReadFramebufferCount

func (g I915Backend) ReadFramebufferCount(ctx context.Context, width, height int) (framebuffers int, e error)

ReadFramebufferCount tries to open the i915FramebufferFile and count the amount of lines of dimensions width x height, which corresponds to the amount of framebuffers allocated in the system. See https://dri.freedesktop.org/docs/drm/gpu/i915.html

func (I915Backend) Round

func (g I915Backend) Round(value int) int

Round rounds up value for the Intel platforms and all codecs.

type Size

type Size struct {
	Width  int
	Height int
}

Size represents a Width x Height pair, for example for a video resolution.

Directories

Path Synopsis
Package glbench manipulates the test flow of running glbench test binaries.
Package glbench manipulates the test flow of running glbench test binaries.
Package patrace provides a function to replay a PATrace (GLES) (https://github.com/ARM-software/patrace) in android
Package patrace provides a function to replay a PATrace (GLES) (https://github.com/ARM-software/patrace) in android
Package trace provides common code to replay graphics trace files.
Package trace provides common code to replay graphics trace files.
comm
Package comm contains trace_replay application host <-> guest communication protocol structures.
Package comm contains trace_replay application host <-> guest communication protocol structures.
guestos
Package guestos provides VM guest OS related primitives.
Package guestos provides VM guest OS related primitives.
Package vkbench manipulates the test flow of running vkbench test binaries.
Package vkbench manipulates the test flow of running vkbench test binaries.

Jump to

Keyboard shortcuts

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