Documentation
¶
Overview ¶
Package c4f contains wrappers for the external c4f programs.
Index ¶
- Constants
- Variables
- func MakeFuzzConfFile(j fuzzer.Job) (string, error)
- func ParseStats(s *litmus.Statset, r io.Reader) error
- func WriteFuzzConf(w io.Writer, j fuzzer.Job) error
- type CmdSpec
- type DelitmusJob
- type Header
- type Runner
- func (a *Runner) CVersion(ctx context.Context) (string, error)
- func (a *Runner) Delitmus(ctx context.Context, d DelitmusJob) error
- func (a *Runner) DumpHeader(ctx context.Context, h *Header, path string) error
- func (a *Runner) DumpStats(ctx context.Context, s *litmus.Statset, path string) error
- func (a *Runner) Fuzz(ctx context.Context, j fuzzer.Job) error
- func (a *Runner) ProbeSubject(ctx context.Context, path string) (*subject.Named, error)
- func (a *Runner) Run(ctx context.Context, s CmdSpec) error
Examples ¶
Constants ¶
const BinC4fC = "c4f-c"
BinC4fC is the name of the c4f C services binary.
const BinC4fFuzz = "c4f"
BinC4fFuzz is the name of the c4f fuzzer binary.
Variables ¶
var ErrNoBaseRunner = errors.New("no base runner supplied")
ErrNoBaseRunner occurs if we try to use a Runner that has no Runner.Base set.
var ErrStatsetParse = errors.New("statistic parse error")
ErrStatsetParse occurs when there is a parse error reading a statset.
Functions ¶
func MakeFuzzConfFile ¶
MakeFuzzConfFile creates a temporary file, then outputs WriteFuzzConf of j to it and returns the filepath. It is the caller's responsibility to delete the file.
func ParseStats ¶
ParseStats parses a statistics set from r into statistics set s. Each statistic should be in the form "name value\n".
func WriteFuzzConf ¶
WriteFuzzConf writes a fuzzer configuration based on j to w.
Example (Empty) ¶
ExampleWriteFuzzConf_empty is a testable example for WriteFuzzConf, showing an empty config.
package main import ( "fmt" "os" "github.com/c4-project/c4t/internal/model/service/fuzzer" "github.com/c4-project/c4t/internal/c4f" ) func main() { if err := c4f.WriteFuzzConf(os.Stdout, (fuzzer.Job{})); err != nil { fmt.Println("ERROR:", err) } }
Output: # AUTOGENERATED BY TESTER fuzz { }
Example (Machine) ¶
ExampleWriteFuzzConf_machine is a testable example for WriteFuzzConf, showing the effect of adding a machine.
package main import ( "fmt" "os" "github.com/c4-project/c4t/internal/model/service/fuzzer" "github.com/c4-project/c4t/internal/c4f" "github.com/c4-project/c4t/internal/machine" ) func main() { f := fuzzer.Job{Machine: &machine.Machine{Cores: 4}} if err := c4f.WriteFuzzConf(os.Stdout, f); err != nil { fmt.Println("ERROR:", err) } }
Output: # AUTOGENERATED BY TESTER fuzz { ## MACHINE SPECIFIC OVERRIDES ## # Set to number of cores in machine to prevent thrashing. set param cap.threads to 4 }
Example (Params) ¶
ExampleWriteFuzzConf_params is a testable example for WriteFuzzConf, showing the effect of adding parameters.
package main import ( "fmt" "os" "github.com/c4-project/c4t/internal/model/service/fuzzer" "github.com/c4-project/c4t/internal/c4f" ) func main() { // These will be output in ascending alphabetical order of keys. f := fuzzer.Job{Config: &fuzzer.Config{Params: map[string]string{ "int.action.cap.upper": "1000", "int.this.will.not.parse": "six", "bool.mem.unsafe-weaken-orders": "true", "bool.action.enable": "2:1", "bool.action.pick-extra": "false", "bool.this.will.not.parse": ":", "action.var.make": "10", "action.var.nope": "ten", "nonsuch": "thing", "": "nope", }}} if err := c4f.WriteFuzzConf(os.Stdout, f); err != nil { fmt.Println("ERROR:", err) } }
Output: # AUTOGENERATED BY TESTER fuzz { ## CONFIGURATION OVERRIDES ## # unsupported param "": "nope" action var.make weight 10 # unsupported param "action.var.nope": "ten" set flag action.enable to ratio 2:1 set flag action.pick-extra to false set flag mem.unsafe-weaken-orders to true # unsupported param "bool.this.will.not.parse": ":" set param action.cap.upper to 1000 # unsupported param "int.this.will.not.parse": "six" # unsupported param "nonsuch": "thing" }
Types ¶
type CmdSpec ¶
type CmdSpec struct { // Cmd is the name of the c4f command (binary) to run. Cmd string // Subcmd is the name of the c4f subcommand to run. Subcmd string // Args is the argument vector to supply to the c4f subcommand. Args []string // Stdout, if given, redirects the command's stdout to this writer. Stdout io.Writer }
CmdSpec holds all information about the invocation of an c4f command.
type DelitmusJob ¶
type DelitmusJob struct { // InLitmus is the filepath of the input litmus file. InLitmus string // OutAux is the filepath to which the delitmusifier should write the auxiliary file. OutAux string // OutC is the filepath to which the delitmusifier should write the output file. OutC string }
DelitmusJob holds information about a single delitmus run.
func (DelitmusJob) Args ¶
func (d DelitmusJob) Args() []string
Args gets the argument vector for DelitmusJob.
type Header ¶
type Header struct { // Name is the name of the Litmus test. Name string `json:"name"` // Locations is the list of locations present in the Litmus test. Locations []string `json:"locations"` // Init is the initialiser block for the Litmus test. Init map[string]int `json:"init"` // Postcondition is the Litmus postcondition. Postcondition string `json:"postcondition"` }
Header represents a Litmus test header in the form that c4f-c accepts and dumps.
type Runner ¶
type Runner struct { // DuneExec toggles whether c4f should be run through dune. DuneExec bool // Base is the basic service runner the c4f runner is using to run binaries. Base service.Runner }
Runner stores information about how to run the core c4f binaries.
func (*Runner) Delitmus ¶
func (a *Runner) Delitmus(ctx context.Context, d DelitmusJob) error
Delitmus runs c4f-c delitmus as directed by d.
func (*Runner) DumpHeader ¶
DumpHeader runs c4f-c dump-header on the subject at path, writing the results to h.
func (*Runner) DumpStats ¶
DumpStats runs c4f-c dump-stats on the subject at path, writing the stats to s.
func (*Runner) ProbeSubject ¶
ProbeSubject probes the litmus test at path, returning a named subject record.