tracing

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

Documentation

Overview

Package tracing contains shared functionalities for Perfetto system tracing tests.

Index

Constants

View Source
const (
	// TraceConfigFile is the data path of the trace config file in text proto format.
	TraceConfigFile = "perfetto/system_trace_cfg.pbtxt"

	// TBMTracedProbesConfigFile is the data path of the TBM traced probes config file in text proto format.
	TBMTracedProbesConfigFile = "perfetto/perfetto_tbm_traced_probes.pbtxt"

	// TracedJobName is the upstart job names of the Perfetto system tracing service daemon (traced).
	TracedJobName = "traced"

	// TracedProbesJobName is the upstart job name of the Perfetto system tracing probes (traced_probes).
	TracedProbesJobName = "traced_probes"

	// TraceProcessorAmd64 is the name of tps for architecture: amd64.
	TraceProcessorAmd64 = "trace_processor_shell-amd64"
	// TraceProcessorArm is the name of tps for architecture: arm.
	TraceProcessorArm = "trace_processor_shell-arm"
	// TraceProcessorArm64 is the name of tps for architecture: arm64.
	TraceProcessorArm64 = "trace_processor_shell-arm64"
)

Variables

This section is empty.

Functions

func CheckTracingServices

func CheckTracingServices(ctx context.Context) (tracedPID, tracedProbesPID int, err error)

CheckTracingServices checks the status of job traced and traced_probes. Returns the traced and traced_probes process IDs on success or an error if either job is not in the running state, or either jobs has crashed (and remains in the zombie process status.

func TraceProcessor

func TraceProcessor() string

TraceProcessor returns the TraceProcessor name could be used on the DUT's architecture. Developers should also add the TraceProcessor name in their tests' Data.

Types

type Session

type Session struct {
	TraceResultFile *os.File
	// contains filtered or unexported fields
}

Session stores the cmd and the result file of the trace. Remember to call Session.RemoveTraceResultFile to clean up the temporary file.

func StartSession

func StartSession(ctx context.Context, configFile string) (*Session, error)

StartSession starts a system-wide trace using the perfetto command line tool in the background, and return the PID in string, which the caller should use to call StopTraceDataWithPID. On success, returns the temporary file of the trace data. It's the caller's responsibility for removing it if it's no longer needed.

func StartSessionAndWaitUntilDone

func StartSessionAndWaitUntilDone(ctx context.Context, configFile string) (*Session, error)

StartSessionAndWaitUntilDone collects a system-wide trace using the perfetto command line tool. On success, returns the temporary file of the trace data. It's the caller's responsibility for removing it if it's no longer needed.

func (*Session) RemoveTraceResultFile

func (sess *Session) RemoveTraceResultFile()

RemoveTraceResultFile removes the temp file of trace result.

func (*Session) RunMetrics

func (sess *Session) RunMetrics(ctx context.Context, traceProcessorPath string, metrics []string) (*perfetto_proto.TraceMetrics, error)

RunMetrics collects the result with trace_processor_shell.

func (*Session) RunQuery

func (sess *Session) RunQuery(ctx context.Context, traceProcessorPath, queryPath string) ([][]string, error)

RunQuery processes the trace data with a SQL query and returns the query csv result as [][]string.

func (*Session) Stop

func (sess *Session) Stop() error

Stop stops the system-wide trace, which should be created by StartSession. Note that the session shouldn't be stopped too early (like in 500 milliseconds), so that perfetto_cmd has time to register the signal handler to handle SIGTERM properly.

func (*Session) Wait

func (sess *Session) Wait() error

Wait waits until the tracing session is done, which should be created by StartSession.

Jump to

Keyboard shortcuts

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