pssm

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pssm reads the OMG PSSM state-machine test suite (ptc/18-11-06, PSSM_TestSuite.xmi), classifies each of its tests by the UML constructs the test's state machine uses, and translates the expressible ones into SysML v2 textual notation for cmd/pssm-referee. The suite is downloaded by scripts/download-pssm-suite.sh and never vendored; docs/project/pssm-referee.md records what a result from it means.

Index

Constants

View Source
const (
	DocumentEnv = "PSSM_DOCUMENT"
	VersionEnv  = "PSSM_VERSION"
	URLEnv      = "PSSM_SUITE_URL"
	SHA256Env   = "PSSM_SUITE_SHA256"
)

The script's variables; an environment value overrides each for the downloader, so it overrides here too, or the two would fetch and verify different pins.

View Source
const BaselinePath = "docs/project/pssm-referee-baseline.json"

BaselinePath is the committed baseline, relative to the repository root.

View Source
const DefaultRoot = "build/pssm"

DefaultRoot is the suite root relative to the repository root, where scripts/download-pssm-suite.sh installs the pinned suite.

View Source
const LogAttribute = "log"

LogAttribute is the machine attribute the emitted model appends each trace segment to; its value at the end of a run is the run's trace.

View Source
const MaxSteps = 100000

MaxSteps is the step budget one run of a translated test has unless the environment names another (runtime.MaxStepsEnvVar). The runtime's own default lets a runaway machine run for minutes before it reports; a translated test that needs more than this many steps is looping, and exhausting the budget is a run error, never a trace.

View Source
const Meaning = "A pass checks that the runtime reproduces UML behavior where the model has a " +
	"defensible SysML v2 mapping, provides a second opinion on the tool-choice rows, and is " +
	"never evidence of SysML v2 conformance."

Meaning is what a pass means, and the first sentence of everything the referee prints about itself.

View Source
const PinPath = "scripts/pssm-pin.sh"

PinPath is the script every fetch of the suite sources its pin from.

View Source
const RequireEnv = "OPENSYSML_REQUIRE_PSSM_SUITE"

RequireEnv names the environment variable CI sets so an absent suite fails a gate instead of skipping it.

View Source
const SuiteFile = "PSSM_TestSuite.xmi"

SuiteFile is the file name of the PSSM test suite within its root.

Variables

Buckets lists every bucket in report order.

DefaultBudget is the exploration budget a translated test is run under; a test that exhausts it fails, since its reachable traces are then unknown.

View Source
var ErrSuiteAbsent = errors.New("PSSM test suite is absent")

ErrSuiteAbsent reports that no suite file exists at the root looked in.

View Source
var Rows = map[string]Row{
	"SM7":  {"SM7", RowToolChoice, "Deferral against a transition elsewhere in the configuration"},
	"SM11": {"SM11", RowToolChoice, "What the completion of a composite state completes"},
	"SM15": {"SM15", RowDiffersByDesign, "A do activity and the machine competing for one occurrence"},
	"SM28": {"SM28", RowToolChoice, "History with nothing to restore"},
	"SM30": {"SM30", RowToolChoice, "Choice: guards read on arrival"},
	"SM32": {"SM32", RowToolChoice, "Junction with no path through"},
}

Rows are the note's rows the suite's tests report on, by row label.

View Source
var TestRows = map[string]string{

	"Deferred 006 A": "SM15",
	"Deferred 006 B": "SM15",
	"Deferred 006 C": "SM15",

	"Deferred 004 A": "SM7",
	"Deferred 004 B": "SM7",

	"Deferred 003": "SM7",

	"Final001":    "SM11",
	"Event 016 A": "SM11",

	"History 002-C": "SM28",

	"Choice 001": "SM30",
	"Choice 002": "SM30",

	"Junction 002": "SM32",
}

TestRows maps a test to the note row its requirement lands on. It is written by hand from the note, never inferred from a run: a mapped test that fails is `differs-by-design` when its row is v2's verdict and stays `fail` when the row is a tool choice, with the row cited either way; a mapped test that passes is a `pass` reporting on the row.

Functions

func Digest

func Digest(path string) (string, error)

Digest is the sha256 of the suite file at path, as the pin spells it.

func Locate

func Locate(root string) (string, error)

Locate returns the suite file under root, or an error wrapping ErrSuiteAbsent with the provisioning hint when it does not exist.

func Reproduces

func Reproduces(committed, fresh *Report) error

Reproduces is the gate CI applies: the fresh run must measure the same suite as the committed baseline and land the same count in every bucket. The rows are not compared — they are for whoever adjudicates a moved count — and the date and develop commit say when and on what the baseline was recorded.

func Required

func Required() bool

Required reports whether the environment demands the suite be present.

func Validate

func Validate(m *Model) []string

Validate parses and validates an emitted model with the front end and lowers its machine, returning every error diagnostic and the lowering error.

func WriteBaseline

func WriteBaseline(path string, r *Report) error

WriteBaseline records a fresh report as the committed baseline.

Types

type Argument

type Argument struct {
	Name  string
	Value *Literal
}

Argument is one argument of a queued operation call.

type Attribute

type Attribute struct {
	Name    string
	Type    string
	Default *Literal
}

Attribute is a typed property with an optional default.

type Behavior

type Behavior struct {
	ID     string
	Name   string
	Type   string
	Params []Param
	// Body is the activity's content as statements; nil for an opaque behavior.
	Body *Body
	// Opaque holds an OpaqueBehavior's body and language.
	Opaque *OpaqueText
	// Source is the Alf text the suite records for the behavior in a comment,
	// when it does; it is documentation for a reader, not what is translated.
	Source string
}

Behavior is a UML behavior: an activity whose graph is read into Body, or an opaque behavior whose text is Body's single opaque statement.

type Body

type Body struct {
	Statements  []Statement
	Unsupported []string
}

Body is an activity read as a sequence of statements in control-flow order, with every node the reading could not express listed under Unsupported.

func (*Body) Empty

func (b *Body) Empty() bool

Empty reports whether the body has neither statements nor unsupported nodes.

type Bucket

type Bucket string

Bucket is the verdict the referee files a test under.

const (
	BucketPass            Bucket = "pass"
	BucketFail            Bucket = "fail"
	BucketNotExpressible  Bucket = "not-expressible"
	BucketTerminateGap    Bucket = "terminate-gap"
	BucketDiffersByDesign Bucket = "differs-by-design"
)

The five buckets, in report order.

type Class

type Class struct {
	ID       string
	Name     string
	Generals []string
	// Attributes are the class's own properties.
	Attributes []Attribute
	// Operations are the class's own operations, with the method that implements each.
	Operations []*Operation
	// Behaviors are the class's owned behaviors other than the classifier behavior.
	Behaviors []*Behavior
	// ClassifierBehavior is the behavior a started instance runs: a state
	// machine (Machine set) or an activity (Activity set).
	Machine  *StateMachine
	Activity *Behavior
	// Standalone marks a class that is itself a state machine: the suite's
	// standalone tests give the machine features and operations of its own.
	Standalone bool
}

Class is a UML class of the suite: its attributes, operations, owned behaviors and classifier behavior, and its generalizations by name.

type Classification

type Classification struct {
	Class Expressibility
	// Uses lists every recorded construct, those deciding the class first,
	// then by class and document order. A Standard test has at most strays.
	Uses []Use
}

Classification is a test's class and the construct uses that decided it.

func Classify

func Classify(t *Test) Classification

Classify decides a test's expressibility from the constructs its state machine uses.

func (Classification) Reason

func (c Classification) Reason() string

Reason spells the uses that decided the class, for a report.

type Construct

type Construct string

Construct is one UML construct the classifier looks for, named as the alignment note's table names it.

const (
	// No spelling.
	ConstructEntryPoint          Construct = "entry point"
	ConstructExitPoint           Construct = "exit point"
	ConstructConnectionPoint     Construct = "connection point reference"
	ConstructLocalTransition     Construct = "local transition"
	ConstructInternalTransition  Construct = "internal transition"
	ConstructExtendedRegion      Construct = "extended region"
	ConstructRedefinedState      Construct = "redefined state"
	ConstructRedefinedTransition Construct = "redefined transition"
	ConstructRedefinedMachine    Construct = "redefined state machine"
	ConstructSubmachine          Construct = "submachine state"
	ConstructStandalone          Construct = "standalone state machine"
	ConstructUnknownVertex       Construct = "unknown pseudostate kind"
	ConstructNoMachine           Construct = "no state machine"
	// No translation: the model's behaviors read what the notation cannot bind.
	ConstructBehaviorParameter Construct = "behavior parameter"
	ConstructOperationResult   Construct = "operation result"
	ConstructTesterTrace       Construct = "tester trace"
	// This project's lowerer refusing a shape UML allows and v2 can spell:
	// a candidate gap of ours, recorded apart from v2's missing spellings.
	ConstructForkedRegionNoEntry Construct = "lowerer refuses fork into a region without an entry transition"
	// Recorded but not deciding: a pseudostate filed as a connection point that
	// is neither an entry nor an exit point and that no transition reaches.
	ConstructStrayConnectionPoint Construct = "stray connection point"
	// The runtime gap.
	ConstructTerminate Construct = "terminate"
	// This project's extensions.
	ConstructDefer          Construct = "defer"
	ConstructFork           Construct = "fork"
	ConstructJoin           Construct = "join"
	ConstructJunction       Construct = "junction"
	ConstructChoice         Construct = "choice"
	ConstructShallowHistory Construct = "shallow history"
	ConstructDeepHistory    Construct = "deep history"
)

The constructs that decide a class. Standard constructs are not recorded: they never move a test out of Standard.

func (Construct) Ours

func (c Construct) Ours() bool

Ours reports whether the construct is unspellable because of this project's lowerer rather than because SysML v2 has no notation for it.

type Constructs

type Constructs map[string]bool

Constructs are the UML constructs a state machine uses, by the names the classifier and the baseline record report.

func (Constructs) Sorted

func (c Constructs) Sorted() []string

Sorted lists the constructs in order.

type Diagnostic

type Diagnostic struct {
	Element string
	Message string
}

Diagnostic is a problem the reader found: which element, and what.

func (Diagnostic) String

func (d Diagnostic) String() string

type Document

type Document struct {
	Root *Element
	// contains filtered or unexported fields
}

Document is a parsed XMI file: its root and an index of every xmi:id.

func Parse

func Parse(r io.Reader) (*Document, error)

Parse reads an XMI document. It returns an error for malformed XML and for an xmi:id declared twice, and never panics on unexpected content.

func (*Document) ByID

func (d *Document) ByID(id string) *Element

ByID resolves an xmi:id within the document, nil when it names nothing.

type Element

type Element struct {
	Tag      string
	Type     string
	ID       string
	Attrs    map[string]string
	Text     string
	Children []*Element
	Parent   *Element
	Line     int
}

Element is one XML element of an XMI document: its local tag, its xmi:type and xmi:id, every other attribute by local name, and its children in document order. A parsed document is never modified after Parse returns.

func (*Element) Attr

func (e *Element) Attr(name string) string

Attr returns the attribute named by its local name, or "" when absent.

func (*Element) Descendants

func (e *Element) Descendants() []*Element

Descendants returns every descendant (not the element itself) in document order.

func (*Element) Describe

func (e *Element) Describe() string

Describe names an element for a diagnostic: its type, name and id.

func (*Element) First

func (e *Element) First(tag string) *Element

First returns the first child with the given tag, or nil.

func (*Element) Href

func (e *Element) Href() string

Href is the cross-document reference the element carries, or "".

func (*Element) Name

func (e *Element) Name() string

Name is the element's name attribute.

func (*Element) Ref

func (e *Element) Ref(name string) string

Ref returns the xmi:id a reference names, whether written as an attribute (`guard="_x"`) or as a child element (`<guard xmi:idref="_x"/>`), or "".

func (*Element) Refs

func (e *Element) Refs(name string) []string

Refs returns every xmi:id a multi-valued reference names: the attribute's space-separated ids and each child element's idref.

func (*Element) Tagged

func (e *Element) Tagged(tag string) []*Element

Tagged returns the children with the given tag, in document order.

func (*Element) Walk

func (e *Element) Walk(fn func(*Element) bool)

Walk visits the element and every descendant in document order until fn returns false.

type Event

type Event struct {
	Kind      EventKind
	Signal    *Signal
	Operation *Operation
	Type      string
}

Event is the event a trigger names: a signal event with its signal, a call event with its operation, or another event type named by Type.

func (*Event) Describe

func (e *Event) Describe() string

Describe names the event for a diagnostic or report.

type EventKind

type EventKind int

EventKind is the kind of a trigger's event.

const (
	EventSignal EventKind = iota
	EventCall
	EventOther
)

The event kinds the reader distinguishes; EventOther carries the xmi:type.

type Execution

type Execution struct {
	// Reached are the distinct traces exploration reached, sorted.
	Reached []string
	// Missing are admitted traces no run reached; Extra are reached traces the
	// suite does not admit. Either makes the test fail.
	Missing []string
	Extra   []string
	// Errors are the distinct errors runs ended in, sorted; any makes the test fail.
	Errors []string
	// Runs is how many linearizations were run; Status is how exploration ended.
	Runs     int
	Status   string
	Complete bool
}

Execution is what running a translated model under the exploring scheduler found, compared against the traces the suite admits.

func Execute

func Execute(stop context.Context, m *Model, expected []string, budget runtime.ExploreBudget, jobs int) (*Execution, error)

Execute builds the model's runtime, drives its machine through the queued events once per linearization within budget, jobs at a time, and compares the traces reached against expected. An error is a model that builds no runtime or an exploration that could not be trusted; a run that fails is recorded, not returned.

func (*Execution) Passed

func (x *Execution) Passed() bool

Passed reports whether the reachable traces are exactly the admitted ones and every run within a complete exploration came to a trace.

func (*Execution) Reasons

func (x *Execution) Reasons() []string

Reasons names why the execution failed, one line each; none for a pass.

type Expr

type Expr struct {
	Kind ExprKind
	// Literal: the literal value.
	Literal *Literal
	// Param: the parameter's name. Event: the accept result it reads. Read:
	// the feature read on Object.
	Name   string
	Object *Expr
	// Apply: the behavior applied, by its library name (Concat, ToString, Not,
	// ...), and its arguments in parameter order. Call: the operation called on
	// Object, with its result used as a value. New: the classifier instantiated, by Name.
	Args []Expr
	// Unknown: what the reader could not follow, for the diagnostic.
	Text string
}

Expr is a value an activity computes: what flows into a pin.

func (Expr) String

func (e Expr) String() string

type ExprKind

type ExprKind int

ExprKind is the kind of an Expr.

const (
	ExprLiteral ExprKind = iota
	ExprSelf
	ExprParam
	ExprEvent
	ExprRead
	ExprApply
	ExprCall
	ExprNew
	ExprUnknown
)

The expression kinds.

type Expressibility

type Expressibility int

Expressibility is whether a test's model can be spelled in SysML v2 textual notation, decided by the UML constructs its state machine uses, in the order of the alignment note's construct-to-notation table: a construct with no spelling makes the test not expressible whatever else it uses; otherwise `terminate` puts it in the gap, any of this project's extensions makes it an extension test, and it is standard otherwise.

const (
	// NotExpressible: the model uses a construct with no SysML v2 spelling.
	NotExpressible Expressibility = iota
	// TerminateGap: spellable, but reaches `terminate`, which the runtime refuses.
	TerminateGap
	// Extension: spellable with this project's extensions (defer, fork, join,
	// junction, choice, history).
	Extension
	// Standard: spellable in standard SysML v2 notation.
	Standard
)

The four expressibility classes, in decision order.

func (Expressibility) Expressible

func (c Expressibility) Expressible() bool

Expressible reports whether a translated model can be built and run.

func (Expressibility) String

func (c Expressibility) String() string

type Guard

type Guard struct {
	Name     string
	Kind     GuardKind
	Literal  bool
	Opaque   *OpaqueText
	Behavior *Behavior
	Type     string
}

Guard is a transition guard: its literal value, its opaque text, and the behavior the opaque expression is compiled to, when any.

func (*Guard) Describe

func (g *Guard) Describe() string

Describe spells the guard for a diagnostic or report.

type GuardKind

type GuardKind int

GuardKind is the shape of a transition guard's specification.

const (
	GuardLiteral GuardKind = iota // a LiteralBoolean
	GuardElse                     // an Expression whose symbol is "else"
	GuardOpaque                   // an OpaqueExpression with a body in some language
	GuardOther                    // any other specification, named by Type
)

The guard shapes the suite uses.

type Literal

type Literal struct {
	Kind LiteralKind
	// Text is the value attribute as written; Present is false for a literal
	// without one (whose value is the kind's default).
	Text    string
	Present bool
}

Literal is a UML literal specification: its kind and its text as written.

func (*Literal) Bool

func (l *Literal) Bool() bool

Bool is the value of a boolean literal (false when absent, as UML defaults).

func (*Literal) String

func (l *Literal) String() string

type LiteralKind

type LiteralKind int

LiteralKind is the UML literal kind.

const (
	LiteralString LiteralKind = iota
	LiteralBoolean
	LiteralInteger
	LiteralUnlimitedNatural
	LiteralReal
	LiteralNull
)

The UML literal kinds.

type Model

type Model struct {
	Test *Test
	// Name is the model's file name, e.g. "Deferred001_SemanticTest.sysml".
	Name string
	// Package and Machine are the emitted package and the state usage inside
	// it; Qualified is the machine's qualified name, e.g. "Deferred001_SemanticTest::M".
	Package   string
	Machine   string
	Qualified string
	// Text is the model.
	Text string
	// Events are the queued events, in order.
	Events []Stimulus
}

Model is one test's state machine spelled in SysML v2 textual notation, with the events the tester's stimulation queues to drive it. The machine keeps a String attribute `log` to which every trace(...) call appends its segment, "::"-joined, so the final log is comparable with Test.Expected.

func Emit

func Emit(s *Suite, t *Test) (*Model, error)

Emit translates one expressible test into a model. The signals of the suite resolve the sends' payloads.

type OpaqueText

type OpaqueText struct {
	Language string
	Body     string
}

OpaqueText is the body of an opaque behavior or expression in its language.

type Operation

type Operation struct {
	ID     string
	Name   string
	Params []Param
	Method *Behavior
}

Operation is a class operation with its parameters and method.

type Options

type Options struct {
	// Jobs is how many linearizations of one test explore at once; the report
	// is the same for any value.
	Jobs int
	// Keep, when set, is a directory each translated model is written to.
	Keep string
	// Filter, when set, keeps only the tests whose name contains it.
	Filter string
	// Budget bounds each test's exploration.
	Budget runtime.ExploreBudget
}

Options steer a run.

type Param

type Param struct {
	Name      string
	Type      string
	Direction string
}

Param is a behavior or operation parameter: its name, type and direction ("in", "out", "return", "inout").

type Pin

type Pin struct {
	Document string
	Version  string
	URL      string
	SHA256   string
}

Pin is the suite's identity as scripts/pssm-pin.sh records it.

func ReadPin

func ReadPin(repo string) (Pin, error)

ReadPin resolves the pin as scripts/pssm-pin.sh does: the script's defaults under the repository root, each replaced by its environment variable when set.

func (Pin) Provenance

func (p Pin) Provenance(tests int) Provenance

Provenance ties a report to the pin, which Verify has matched to the bytes read.

func (Pin) Verify

func (p Pin) Verify(suitePath string) error

Verify refuses a suite file whose bytes are not the pinned ones, before anything reads it.

type Provenance

type Provenance struct {
	Document string `json:"document"`
	Version  string `json:"version"`
	URL      string `json:"url"`
	// Digest is the sha256 of the suite file read, so a report is tied to the
	// bytes it measured and not to the pin's promise about them.
	Digest string `json:"suiteDigest"`
	Tests  int    `json:"tests"`
	// Recorded is the date -update stamped; a plain run leaves it empty.
	Recorded string `json:"recorded,omitempty"`
	// Develop is the develop commit whose runtime -update measured; a plain
	// run leaves it empty.
	Develop string `json:"develop,omitempty"`
}

Provenance identifies the suite a report measured.

type Region

type Region struct {
	ID          string
	Name        string
	Vertices    []*Vertex
	Transitions []*Transition
	// ExtendedRegion names the region this one extends, or "".
	ExtendedRegion string
	// Comments are the region's documentation comments.
	Comments []string
	// contains filtered or unexported fields
}

Region is a region of a state machine or composite state.

func (*Region) Owner

func (r *Region) Owner() *Vertex

Owner is the composite state owning the region, nil for a top-level region.

type Report

type Report struct {
	Meaning    string         `json:"meaning"`
	Provenance Provenance     `json:"provenance"`
	Buckets    map[Bucket]int `json:"buckets"`
	Tests      []TestReport   `json:"tests"`
}

Report is one run of the referee over the suite: the buckets' counts, the gate CI compares, and one row per test, for the adjudicator.

func ReadBaseline

func ReadBaseline(path string) (*Report, error)

ReadBaseline decodes a committed baseline.

func Referee

func Referee(stop context.Context, s *Suite, prov Provenance, opts Options) (*Report, error)

Referee runs every test of the suite and files it. Only a problem with the harness itself, or a suite the reader could not read whole, is an error; a test that cannot be run is a row in its bucket.

func (*Report) Encode

func (r *Report) Encode() ([]byte, error)

Encode renders a report as the bytes the baseline holds: indented JSON with a fixed key order, so two runs with equal results are byte-identical.

func (*Report) Summary

func (r *Report) Summary() string

Summary renders the counts and the rows of every bucket but pass, one line per reason, for a terminal.

type Row

type Row struct {
	// ID is the row's label in the note, e.g. "SM15".
	ID    string
	Kind  RowKind
	Title string
}

Row is one row of the alignment note a test's requirement lands on.

func RowOf

func RowOf(test string) (Row, bool)

RowOf is the note row a test reports on, if the table maps it.

type RowKind

type RowKind string

RowKind is which verdict the alignment note reached on a row a test reports on.

const (
	// RowDiffersByDesign: the note's "differs because v2 differs" — the v2
	// library or notation specifies otherwise, so a disagreement is v2's.
	RowDiffersByDesign RowKind = "differs because v2 differs"
	// RowToolChoice: the note's "differs, v2 silent" — v2 says nothing, the
	// runtime chose, and the test is a second opinion on that choice.
	RowToolChoice RowKind = "differs, v2 silent"
)

type Signal

type Signal struct {
	ID         string
	Name       string
	Attributes []Attribute
}

Signal is a signal classifier with its attributes.

type StateMachine

type StateMachine struct {
	ID   string
	Name string
	// Regions are the machine's top-level regions in document order.
	Regions []*Region
	// ConnectionPoints are the machine's own entry and exit points.
	ConnectionPoints []*Vertex
	// Redefines names the state machine this one redefines, or "".
	Redefines string
	// Owner is the class owning the machine, or "" for a standalone machine.
	Owner string
}

StateMachine is a UML state machine with its regions and connection points.

type Statement

type Statement struct {
	Kind StatementKind
	// Call and Send: the operation, behavior or signal named and its arguments
	// in parameter order; Receiver is the object addressed, nil for a behavior.
	Name     string
	Args     []Expr
	Receiver *Expr
	// Accept: the events waited for, and Result the name the accepted
	// occurrence is bound to when the body reads it ("" otherwise).
	Events []*Event
	Result string
	// Assign: the feature written on Receiver and the Value written; Replace
	// distinguishes `x = v` from `x->add(v)`. Return: the Value returned.
	Feature string
	Value   *Expr
	Replace bool
}

Statement is one step of a behavior. Exactly one kind applies.

func (Statement) String

func (s Statement) String() string

type StatementKind

type StatementKind int

StatementKind is the kind of a Statement.

const (
	StmtCall   StatementKind = iota // Receiver.Name(Args...)
	StmtSend                        // send Name(Args...) to Receiver
	StmtAccept                      // accept one of Events
	StmtAssign                      // Receiver.Feature := Value
	StmtReturn                      // return Value
	StmtStart                       // start Receiver's classifier behavior
)

The statement kinds an activity reading produces.

type Stimulus

type Stimulus struct {
	Signal string
	Call   string
	// Value is the scalar payload of a signal, nil for a plain signal.
	Value *Literal
	// Args are the call's arguments in parameter order.
	Args []Argument
}

Stimulus is one event the tester sends the target: a signal, with its scalar payload when the signal carries one, or an operation call with its arguments.

func (Stimulus) String

func (s Stimulus) String() string

String spells the stimulus for a report.

type Suite

type Suite struct {
	Tests []*Test
	// Signals are the protocol signals the tests' machines accept, by name.
	Signals map[string]*Signal
	// Diagnostics are problems reading the suite that are not tied to one test.
	Diagnostics []Diagnostic
}

Suite is the PSSM test suite as read: every registered test in the order the suite registers them, grouped by area in the suite's own area order.

func Read

func Read(src io.Reader) (*Suite, error)

Read parses an XMI document and reads the suite it contains. Malformed XML is an error; anything the reader cannot interpret inside a well-formed document is a diagnostic on the suite or the test concerned.

func ReadDocument

func ReadDocument(doc *Document) (*Suite, error)

ReadDocument reads the suite a parsed document contains.

func ReadFile

func ReadFile(path string) (*Suite, error)

ReadFile parses and reads a PSSM suite file.

func (*Suite) Areas

func (s *Suite) Areas() []string

Areas lists the suite's test areas in first-registration order.

func (*Suite) Problems

func (s *Suite) Problems() []string

Problems is every diagnostic the reader recorded, the suite's own first and then each test's in suite order; a measurement over a suite with any is not a measurement of that suite.

type Test

type Test struct {
	// ID is the name of the suite's SemanticTest class, e.g. "Deferred001_SemanticTest".
	ID string
	// Area is the suite's test area, e.g. "Deferred"; Name its display name, e.g. "Deferred 001".
	Area string
	Name string
	// Expected are the admissible final traces, each segment joined by "::".
	Expected []string
	// Target is the class under test and Tester the class stimulating it. A
	// standalone test has a Machine but no Target class.
	Target  *Class
	Tester  *Class
	Machine *StateMachine
	// Stimulation is the tester's behavior read as a sequence of statements.
	Stimulation *Body
	// Notes are the suite's own documentation comments on the machine and its
	// regions (stimulation sequence, expected execution, run-to-completion
	// steps). They are read for the record and never compared.
	Notes []string
	// Diagnostics are problems reading this test.
	Diagnostics []Diagnostic
}

Test is one registered semantic test: its area and name as the suite registers them, the target class whose state machine is under test, the tester whose behavior stimulates it, and the traces the suite admits.

type TestReport

type TestReport struct {
	Name  string `json:"name"`
	Area  string `json:"area"`
	Class string `json:"class"`
	// Row is the alignment note row the test reports on, when the table maps it.
	Row     string `json:"row,omitempty"`
	RowKind string `json:"rowKind,omitempty"`
	Bucket  Bucket `json:"bucket"`
	// Reasons say why the test is in its bucket, one line each; a pass has none.
	Reasons []string `json:"reasons,omitempty"`
	// Expected and Reached are the admitted and reached trace sets of a test
	// that ran; Runs is how many linearizations exploration took.
	Expected []string `json:"expected,omitempty"`
	Reached  []string `json:"reached,omitempty"`
	Runs     int      `json:"runs,omitempty"`
}

TestReport is one test's row.

type Transition

type Transition struct {
	ID       string
	Name     string
	Kind     TransitionKind
	Source   *Vertex
	Target   *Vertex
	Triggers []*Trigger
	Guard    *Guard
	Effect   *Behavior
	// Redefines names the transition this one redefines, or "".
	Redefines string
	// Region is the region owning the transition.
	Region *Region
}

Transition is a UML transition with its triggers, guard and effect.

func (*Transition) Describe

func (t *Transition) Describe() string

Describe spells the transition for a diagnostic or report.

type TransitionKind

type TransitionKind int

TransitionKind is a UML transition kind.

const (
	TransitionExternal TransitionKind = iota
	TransitionLocal
	TransitionInternal
)

The three UML transition kinds.

func (TransitionKind) String

func (k TransitionKind) String() string

type TranslateError

type TranslateError struct {
	Test   string
	Where  string
	Reason string
}

TranslateError reports a construct of a test the emitter has no exact translation for. It never drops the construct instead.

func (*TranslateError) Error

func (e *TranslateError) Error() string

type Trigger

type Trigger struct {
	Name  string
	Event *Event
}

Trigger is a transition or deferrable trigger with its event.

type Use

type Use struct {
	Construct Construct
	// Where names the element using it, e.g. "T3" or "S1.S1.1".
	Where string
}

Use is one occurrence of a deciding construct: which, and where.

func (Use) String

func (u Use) String() string

type Vertex

type Vertex struct {
	ID   string
	Name string
	Kind VertexKind
	// Region is the region owning the vertex; nil for a connection point owned
	// by a state or state machine.
	Region *Region
	// The state-only parts. Regions are the state's own regions (one for a
	// composite state, several for an orthogonal one).
	Regions          []*Region
	Entry, Exit, Do  *Behavior
	Deferred         []*Trigger
	ConnectionPoints []*Vertex
	// ConnectionPointReferences counts the state's references into a submachine.
	ConnectionPointReferences int
	// Submachine names the state machine a submachine state references, or "".
	Submachine string
	// Redefines names the state this one redefines, or "".
	Redefines string
	// Comments are the state's documentation comments.
	Comments []string
}

Vertex is a state, final state or pseudostate in a region.

func (*Vertex) Describe

func (v *Vertex) Describe() string

Describe spells the vertex as `kind name` for a diagnostic or report.

func (*Vertex) Path

func (v *Vertex) Path() string

Path is the state's dotted name from the top of its machine, e.g. "S1.S1.1"; pseudostates and final states are named by their own name.

type VertexKind

type VertexKind int

VertexKind is the kind of a vertex: a state, a final state, or a pseudostate by its kind attribute.

const (
	VertexState VertexKind = iota
	VertexFinal
	VertexInitial
	VertexJunction
	VertexChoice
	VertexFork
	VertexJoin
	VertexShallowHistory
	VertexDeepHistory
	VertexEntryPoint
	VertexExitPoint
	VertexTerminate
	VertexUnknown
)

The vertex kinds the suite uses. Every UML pseudostate kind has a value so an unknown kind attribute is a diagnostic, not a silent default.

func (VertexKind) IsPseudostate

func (k VertexKind) IsPseudostate() bool

IsPseudostate reports whether the vertex kind is a pseudostate.

func (VertexKind) String

func (k VertexKind) String() string

Jump to

Keyboard shortcuts

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