// Otherwise, it performs no validation on the trace at all.
type Trace struct {
// Trace data state.
- ver version.Version
- names map[string]event.Type
- specs []event.Spec
- events []raw.Event
- gens []*Generation
+ ver version.Version
+ names map[string]event.Type
+ specs []event.Spec
+ events []raw.Event
+ gens []*Generation
+ validTimestamps bool
// Expectation state.
bad bool
func NewTrace() *Trace {
ver := version.Go122
return &Trace{
- names: event.Names(ver.Specs()),
- specs: ver.Specs(),
+ names: event.Names(ver.Specs()),
+ specs: ver.Specs(),
+ validTimestamps: true,
}
}
t.events = append(t.events, t.createEvent(typ, data, args...))
}
+// 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 (t *Trace) DisableTimestamps() {
+ t.validTimestamps = false
+}
+
// Generation creates a new trace generation.
//
// This provides more structure than Event to allow for more easily
//
// This is convenience function for generating correct batches.
func (g *Generation) Batch(thread trace.ThreadID, time Time) *Batch {
+ if !g.trace.validTimestamps {
+ time = 0
+ }
b := &Batch{
gen: g,
thread: thread,
var uintArgs []uint64
argOff := 0
if b.gen.trace.specs[ev].IsTimedEvent {
- uintArgs = []uint64{1}
+ if b.gen.trace.validTimestamps {
+ uintArgs = []uint64{1}
+ } else {
+ uintArgs = []uint64{0}
+ }
argOff = 1
}
spec := b.gen.trace.specs[ev]