stage

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package stage contains plan metadata describing which stages of a test cycle have occurred.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	// Stage is the identifier of the stage completed.
	Stage Stage `json:"stage"`

	// Timespan notes the start and end time of the stage.
	Timespan timing.Span `json:"timespan,omitempty"`
}

Record is the type of stage completion records. These records log the fact that a stage was completed, the time of completion, and the duration.

func (Record) String

func (r Record) String() string

String converts a record to a human-readable string.

Example

ExampleRecord_String is a testable example for Record.String.

package main

import (
	"fmt"
	"time"

	"github.com/c4-project/c4t/internal/timing"

	"github.com/c4-project/c4t/internal/plan/stage"
)

func main() {
	fmt.Println(
		stage.Record{
			Stage:    stage.Fuzz,
			Timespan: timing.SpanFromDuration(timing.MockDate, 10*time.Minute),
		},
	)

}
Output:

Fuzz: 10m0s (from 1997-05-01T21:00:00Z to 1997-05-01T21:10:00Z)

type Stage

type Stage uint8

Stage is the enumeration of stages.

A stage generally corresponds to one of the 'c4t-*' sub-programs, and represents a specific transformation of a plan file.

const (
	// Unknown is a sentinel value for unknown stages.
	Unknown Stage = iota

	// Plan is the required stage corresponding to selecting an input corpus and compiler set for future testing.
	Plan

	// Perturb is the optional stage corresponding to randomising and sampling a preceding plan.
	Perturb

	// Fuzz is the optional stage corresponding to mutating an input corpus.
	Fuzz

	// Lift is the required stage corresponding to generating test harnesses and build recipes for a corpus.
	Lift

	// Invoke is the required stage corresponding to compiling and running a plan.
	Invoke

	// Mach is a sub-stage of Invoke, corresponding to operations residing on the machine node.
	Mach

	// Compile is a sub-stage of Mach, corresponding to compiling the recipes in a plan.
	Compile

	// Run is a sub-stage of Mach, corresponding to running the compiled binaries in a plan.
	Run

	// Analyse is the optional stage corresponding to post-processing an invoked plan.
	// Unlike other stages, it isn't logged in the plan file, and can be repeated.
	Analyse

	// SetCompiler is the stage corresponding to manually setting a compiler.
	SetCompiler

	// Last points to the last stage in the enumeration.
	Last = SetCompiler
)

func FromString

func FromString(s string) (Stage, error)

FromString tries to convert a string into a Stage.

Example

ExampleFromString is a testable example for FromString.

package main

import (
	"fmt"

	"github.com/c4-project/c4t/internal/plan/stage"
)

func main() {
	s, err := stage.FromString("Plan")
	fmt.Println(s, err)

	_, err = stage.FromString("Nonsuch")
	fmt.Println(err)

}
Output:

Plan <nil>
unknown Stage: "Nonsuch"

func (Stage) MarshalJSON

func (i Stage) MarshalJSON() ([]byte, error)

MarshalJSON marshals a stage to JSON using its string form.

Example

ExampleStage_MarshalJSON is a runnable example for MarshalJSON.

package main

import (
	"fmt"

	"github.com/c4-project/c4t/internal/plan/stage"
)

func main() {
	for i := stage.Unknown + 1; i <= stage.Last; i++ {
		bs, _ := i.MarshalJSON()
		fmt.Println(string(bs))
	}

}
Output:

"Plan"
"Perturb"
"Fuzz"
"Lift"
"Invoke"
"Mach"
"Compile"
"Run"
"Analyse"
"SetCompiler"

func (Stage) String

func (i Stage) String() string
Example

ExampleStage_String is a testable example for Stage.String.

package main

import (
	"fmt"

	"github.com/c4-project/c4t/internal/plan/stage"
)

func main() {
	for i := stage.Unknown; i <= stage.Last+1; i++ {
		fmt.Println(i)
	}

}
Output:

Unknown
Plan
Perturb
Fuzz
Lift
Invoke
Mach
Compile
Run
Analyse
SetCompiler
Stage(11)

func (*Stage) UnmarshalJSON

func (i *Stage) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals a stage from JSON using its string form.

Jump to

Keyboard shortcuts

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