Movatterモバイル変換


[0]ホーム

URL:


testgen

packagestandard library
go1.25.2Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License:BSD-3-ClauseImports:12Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (NoString = ""NoStack  = []trace.StackFrame{})

Functions

funcMain

func Main(verversion.Version, f func(*Trace))

Types

typeBatch

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

Batch represents an event batch.

func (*Batch)Event

func (b *Batch) Event(namestring, args ...any)

Event emits an event into a batch. name must correspond to oneof the names in Specs() result for the version that was passed tothis trace. Callers must omit the timestamp delta.

func (*Batch)RawEvent

func (b *Batch) RawEvent(typtracev2.EventType, data []byte, args ...uint64)

RawEvent emits an event into a batch. name must correspond to oneof the names in Specs() result for the version that was passed tothis trace.

typeGeneration

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

Generation represents a single generation in the trace.

func (*Generation)Batch

func (g *Generation) Batch(threadtrace.ThreadID, timeTime) *Batch

Batch starts a new event batch in the trace data.

This is convenience function for generating correct batches.

func (*Generation)Stack

func (g *Generation) Stack(stk []trace.StackFrame)uint64

Stack registers a stack with the trace.

This is a convenience function for easily adding correctstacks to traces.

func (*Generation)String

func (g *Generation) String(sstring)uint64

String registers a string with the trace.

This is a convenience function for easily adding correctstrings to traces.

func (*Generation)Sync

func (g *Generation) Sync(frequint64, timeTime, monouint64, walltime.Time)

Sync configures the sync batch for the generation. For go1.25 and later,the time value is the timestamp of the EvClockSnapshot event. For earlierversion, the time value is the timestamp of the batch containing a loneEvFrequency event.

typeSeq

type Sequint64

Seq represents a sequence counter.

typeTime

type Timeuint64

Time represents a low-level trace timestamp (which does not necessarilycorrespond to nanoseconds, like trace.Time does).

typeTrace

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

Trace represents an execution trace for testing.

It does a little bit of work to ensure that the produced trace is valid,just for convenience. It mainly tracks batches and batch sizes (so they'retrivially correct), tracks strings and stacks, and makes sure emitted stringand stack batches are valid. That last part can be controlled by a few options.

Otherwise, it performs no validation on the trace at all.

funcNewTrace

func NewTrace(verversion.Version) *Trace

NewTrace creates a new trace.

func (*Trace)DisableTimestamps

func (t *Trace) DisableTimestamps()

DisableTimestamps makes the timestamps for all events generated afterthis call zero. Raw events are exempted from this because the callerhas to pass their own timestamp into those events anyway.

func (*Trace)ExpectFailure

func (t *Trace) ExpectFailure(patternstring)

ExpectFailure writes down that the trace should be broken. The callermust provide a pattern matching the expected error produced by the parser.

func (*Trace)ExpectSuccess

func (t *Trace) ExpectSuccess()

ExpectSuccess writes down that the trace should successfully parse.

func (*Trace)Generate

func (t *Trace) Generate() []byte

Generate creates a test file for the trace.

func (*Trace)Generation

func (t *Trace) Generation(genuint64) *Generation

Generation creates a new trace generation.

This provides more structure than Event to allow for more easilycreating complex traces that are mostly or completely correct.

func (*Trace)RawEvent

func (t *Trace) RawEvent(typtracev2.EventType, data []byte, args ...uint64)

RawEvent emits an event into the trace. name must correspond to oneof the names in Specs() result for the version that was passed tothis trace.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp