package testkit
import "golang.org/x/exp/trace/internal/testgen/go122"
Index ¶
- Variables
- func Main(f func(*Trace))
- type Batch
- func (b *Batch) Event(name string, args ...any)
- func (b *Batch) RawEvent(typ event.Type, data []byte, args ...uint64)
- type Generation
- func (g *Generation) Batch(thread trace.ThreadID, time Time) *Batch
- func (g *Generation) Stack(stk []trace.StackFrame) uint64
- func (g *Generation) String(s string) uint64
- type Seq
- type Time
- type Trace
Variables ¶
var ( NoString = "" NoStack = []trace.StackFrame{} )
Functions ¶
func Main ¶
func Main(f func(*Trace))
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch represents an event batch.
func (*Batch) Event ¶
Event emits an event into a batch. name must correspond to one of the names in Specs() result for the version that was passed to this trace. Callers must omit the timestamp delta.
func (*Batch) RawEvent ¶
RawEvent emits an event into a batch. name must correspond to one of the names in Specs() result for the version that was passed to this trace.
type Generation ¶
type Generation struct {
// contains filtered or unexported fields
}
Generation represents a single generation in the trace.
func (*Generation) Batch ¶
func (g *Generation) Batch(thread trace.ThreadID, time Time) *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 correct stacks to traces.
func (*Generation) String ¶
func (g *Generation) String(s string) uint64
String registers a string with the trace.
This is a convenience function for easily adding correct strings to traces.
type Seq ¶
type Seq uint64
Seq represents a sequence counter.
type Time ¶
type Time uint64
Time represents a low-level trace timestamp (which does not necessarily correspond to nanoseconds, like trace.Time does).
type Trace ¶
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're trivially correct), tracks strings and stacks, and makes sure emitted string and stack batches are valid. That last part can be controlled by a few options.
Otherwise, it performs no validation on the trace at all.
func NewTrace ¶
func NewTrace() *Trace
NewTrace creates a new trace.
func (*Trace) DisableTimestamps ¶
func (t *Trace) DisableTimestamps()
DisableTimestamps makes the timestamps for all events generated after this call zero. Raw events are exempted from this because the caller has to pass their own timestamp into those events anyway.
func (*Trace) ExpectFailure ¶
ExpectFailure writes down that the trace should be broken. The caller must 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 ¶
Generate creates a test file for the trace.
func (*Trace) Generation ¶
func (t *Trace) Generation(gen uint64) *Generation
Generation creates a new trace generation.
This provides more structure than Event to allow for more easily creating complex traces that are mostly or completely correct.
func (*Trace) RawEvent ¶
RawEvent emits an event into the trace. name must correspond to one of the names in Specs() result for the version that was passed to this trace.
Source Files ¶
trace.go
- Version
- v0.0.0-20250218142911-aa4b98e5adaa (latest)
- Published
- Feb 18, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 3 days ago –
Tools for package owners.