testtrace

Imports

Imports #

"bufio"
"bytes"
"fmt"
"regexp"
"strconv"
"strings"
"bytes"
"fmt"
"internal/trace/raw"
"internal/txtar"
"io"
"errors"
"fmt"
"internal/trace"
"slices"
"strings"

Structs

Expectation struct #

Expectation represents the expected result of some operation.

type Expectation struct {
failure bool
errorMatcher *regexp.Regexp
}

Validator struct #

Validator is a type used for validating a stream of trace.Events.

type Validator struct {
lastTs trace.Time
gs map[trace.GoID]*goState
ps map[trace.ProcID]*procState
ms map[trace.ThreadID]*schedContext
ranges map[trace.ResourceID][]string
tasks map[trace.TaskID]string
seenSync bool
Go121 bool
}

errAccumulator struct #

type errAccumulator struct {
errs []error
}

goState struct #

type goState struct {
state trace.GoState
binding *schedContext
}

procState struct #

type procState struct {
state trace.ProcState
binding *schedContext
}

schedContext struct #

type schedContext struct {
M trace.ThreadID
P trace.ProcID
G trace.GoID
}

Functions

Check method #

Check validates whether err conforms to the expectation. Returns an error if it does not conform. Conformance means that if failure is true, then err must be non-nil. If err is non-nil, then it must match errorMatcher.

func (e *Expectation) Check(err error) error

Errorf method #

func (e *errAccumulator) Errorf(f string, args ...any)

Errors method #

func (e *errAccumulator) Errors() error

Event method #

Event validates ev as the next event in a stream of trace.Events. Returns an error if validation fails.

func (v *Validator) Event(ev trace.Event) error

ExpectSuccess function #

ExpectSuccess returns an Expectation that trivially expects success.

func ExpectSuccess() *Expectation

NewValidator function #

NewValidator creates a new Validator.

func NewValidator() *Validator

ParseExpectation function #

ParseExpectation parses the serialized form of an Expectation.

func ParseExpectation(data []byte) (*Expectation, error)

ParseFile function #

ParseFile parses a test file generated by the testgen package.

func ParseFile(testPath string) (io.Reader, *Expectation, error)

addRange method #

func (v *Validator) addRange(r trace.ResourceID, name string)

checkStack function #

func checkStack(e *errAccumulator, stk trace.Stack)

deleteRange method #

func (v *Validator) deleteRange(r trace.ResourceID, name string)

getOrCreateThread method #

func (v *Validator) getOrCreateThread(e *errAccumulator, ev trace.Event, m trace.ThreadID) *schedContext

hasAnyRange method #

func (v *Validator) hasAnyRange(r trace.ResourceID) bool

hasRange method #

func (v *Validator) hasRange(r trace.ResourceID, name string) bool

parseMatcher function #

func parseMatcher(quoted string) (*regexp.Regexp, error)

Generated with Arrow