Documentation ¶
Overview ¶
Package quantity contains the quantity sets for various parts of the tester.
These sets appear grouped into this package primarily for reasons of dependency cycle breaking; various bits of the tester at various different levels need access to them.
Index ¶
- func GenericOverride(old, new interface{})
- func LogWorkers(l *log.Logger, nworkers int)
- type BatchSet
- type FuzzSet
- type MachNodeSet
- type MachineSet
- type PerturbSet
- type PlanSet
- type RootSet
- type Timeout
- func (t Timeout) IsActive() bool
- func (t Timeout) Log(l *log.Logger)
- func (t Timeout) MarshalText() (text []byte, err error)
- func (t Timeout) OnContext(parent context.Context) (context.Context, context.CancelFunc)
- func (t *Timeout) Override(new Timeout)
- func (t Timeout) String() string
- func (t *Timeout) UnmarshalText(in []byte) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenericOverride ¶
func GenericOverride(old, new interface{})
GenericOverride substitutes any quantities in new that are non-zero for those in *old (which must be a pointer).
func LogWorkers ¶
LogWorkers dumps the number of workers configured by nworkers to the logger l.
Types ¶
type BatchSet ¶
type BatchSet struct { // Timeout is the timeout for each runner. // Non-positive values disable the timeout. Timeout Timeout `toml:"timeout,omitzero" json:"timeout,omitempty"` // NWorkers is the number of parallel run workers that should be spawned. // Anything less than or equal to 1 will sequentialise the run. NWorkers int `toml:"workers,omitzero" json:"workers,omitempty"` }
BatchSet contains the tunable quantities for either a batch compiler or a batch runner.
type FuzzSet ¶
type FuzzSet struct { // CorpusSize is the sampling size for the corpus after fuzzing. // It has a similar effect to CorpusSize in planner.Planner. CorpusSize int `toml:"corpus_size,omitzero" json:"corpus_size,omitempty"` // SubjectCycles is the number of times to fuzz each file. SubjectCycles int `toml:"subject_cycles,omitzero" json:"subject_cycles,omitempty"` // NWorkers is the number of workers to use when fuzzing. NWorkers int `toml:"workers,omitzero" json:"num_workers,omitempty"` }
FuzzSet represents the part of a configuration that holds various tunable parameters for the fuzzer.
func (*FuzzSet) Override ¶
Override substitutes any quantities in new that are non-zero for those in this set.
Example ¶
ExampleFuzzSet_Override is a runnable example for FuzzSet.Override.
package main import ( "fmt" "github.com/c4-project/c4t/internal/quantity" ) func main() { q1 := quantity.FuzzSet{ CorpusSize: 27, SubjectCycles: 53, } q2 := quantity.FuzzSet{ SubjectCycles: 42, } q1.Override(q2) fmt.Println("corpus size: ", q1.CorpusSize) fmt.Println("subject cycles:", q1.SubjectCycles) }
Output: corpus size: 27 subject cycles: 42
type MachNodeSet ¶
type MachNodeSet struct { // Compiler is the quantity set for the compiler. Compiler BatchSet `toml:"compiler,omitzero" json:"compiler,omitempty"` // Runner is the quantity set for the runner. Runner BatchSet `toml:"runner,omitzero" json:"runner,omitempty"` }
MachNodeSet contains the tunable quantities for both batch-compiler and batch-runner.
func (*MachNodeSet) Log ¶
func (q *MachNodeSet) Log(l *log.Logger)
Log logs q to l.
Example ¶
ExampleMachNodeSet_Log is a testable example for MachNodeSet.Log.
package main import ( "log" "os" "time" "github.com/c4-project/c4t/internal/quantity" ) func main() { qs := quantity.MachNodeSet{ Compiler: quantity.BatchSet{ Timeout: quantity.Timeout(1 * time.Minute), NWorkers: 2, }, Runner: quantity.BatchSet{ Timeout: quantity.Timeout(2 * time.Minute), NWorkers: 1, }, } l := log.New(os.Stdout, "", 0) qs.Log(l) }
Output: [Compiler] running across 2 workers timeout at 1m0s [Runner] running across 1 worker timeout at 2m0s
func (*MachNodeSet) Override ¶
func (q *MachNodeSet) Override(new MachNodeSet)
Override overrides the quantities in this set with any new quantities supplied in new.
type MachineSet ¶
type MachineSet struct { // Fuzz is the quantity set for the fuzz stage. Fuzz FuzzSet `toml:"fuzz,omitzero" json:"fuzz,omitempty"` // Mach is the quantity set for the machine-local stage, as well as any machine-local stages run remotely. Mach MachNodeSet `toml:"mach,omitzero" json:"mach,omitempty"` // Perturb is the quantity set for the planner stage. Perturb PerturbSet `toml:"perturb,omitzero" json:"perturb,omitempty"` }
MachineSet contains overridable quantities for each stage operating on a particular machine. Often, but not always, these quantities will be shared between machines.
func (*MachineSet) Override ¶
func (q *MachineSet) Override(new MachineSet)
Override substitutes any quantities in new that are non-zero for those in this set.
type PerturbSet ¶
type PerturbSet struct { // CorpusSize is the requested size of the test corpus. // If zero, no corpus sampling is done, but the perturber will still error if the final corpus size is 0. // If nonzero, the corpus will be sampled if larger than the size, and an error occurs if the final size is below // that requested. CorpusSize int `toml:"corpus_size,omitzero" json:"corpus_size,omitempty"` }
PerturbSet contains configurable quantities for the perturber.
func (*PerturbSet) Override ¶
func (q *PerturbSet) Override(new PerturbSet)
Override substitutes any quantities in new that are non-zero for those in this set.
type PlanSet ¶
type PlanSet struct { // NWorkers is the number of workers to use when probing the corpus. NWorkers int `toml:"workers,omitzero"` }
PlanSet contains configurable quantities for the planner.
type RootSet ¶
type RootSet struct { // GlobalTimeout is the top-level timeout for the director. GlobalTimeout Timeout `toml:"global_timeout,omitzero"` // Plan is the quantity set for the planner stage. Plan PlanSet `toml:"plan,omitempty"` // This part of the quantity set is effectively a default for all machines that don't have overrides. MachineSet }
RootSet is the top-level set of tunable quantities for a director.
func (*RootSet) Log ¶
Log logs q to l.
Example ¶
ExampleRootSet_Log is a runnable example for RootSet.Log.
package main import ( "log" "os" "time" "github.com/c4-project/c4t/internal/quantity" ) func main() { qs := quantity.RootSet{ MachineSet: quantity.MachineSet{ Fuzz: quantity.FuzzSet{ CorpusSize: 10, SubjectCycles: 5, NWorkers: 4, }, Mach: quantity.MachNodeSet{ Compiler: quantity.BatchSet{ Timeout: quantity.Timeout(3 * time.Minute), NWorkers: 6, }, Runner: quantity.BatchSet{ Timeout: quantity.Timeout(2 * time.Minute), NWorkers: 7, }, }, Perturb: quantity.PerturbSet{ CorpusSize: 80, }, }, Plan: quantity.PlanSet{ NWorkers: 9, }, } qs.Log(log.New(os.Stdout, "", 0)) }
Output: [Plan] running across 9 workers [Perturb] target corpus size: 80 subjects [Fuzz] running across 4 workers fuzzing each subject 5 times target corpus size: 10 subjects [Mach] [Compiler] running across 6 workers timeout at 3m0s [Runner] running across 7 workers timeout at 2m0s
type Timeout ¶
Timeout is a Duration with the semantics of non-positive values being an absence of timeout.
func (Timeout) MarshalText ¶
MarshalText marshals a timeout by stringifying it.
func (Timeout) OnContext ¶
OnContext lifts this timeout to a context with the given parent. If this timeout is active, the semantics are as context.WithTimeout; else, context.WithCancel.
func (*Timeout) UnmarshalText ¶
UnmarshalText unmarshals a timeout by using ParseDuration.