Documentation ¶
Overview ¶
Package litmus contains the parts of a Herdtools backend specific to litmus7.
Index ¶
- Constants
- Variables
- type Fixset
- type Instance
- type Litmus
- func (l Litmus) LiftExe(ctx context.Context, j backend.LiftJob, r service.RunInfo, x service.Runner) error
- func (l Litmus) LiftStandalone(ctx context.Context, j backend.LiftJob, r service.RunInfo, x service.Runner, ...) error
- func (Litmus) ParsePreTestLine([]string) (obs.Flag, error)
- func (l Litmus) ParseStateCount(fields []string) (k uint64, ok bool, err error)
- func (l Litmus) ParseStateLine(tt parser.TestType, fields []string) (*parser.StateLine, error)
- type Pathset
Examples ¶
Constants ¶
const ( // IncludeStdbool is the include directive that the litmus patcher will insert if needed. // It is exported for testing purposes. IncludeStdbool = "#include <stdbool.h>" )
Variables ¶
var ( // ErrNoFileIn occurs when the input file is empty. ErrNoFileIn = errors.New("need input file") // ErrNoDirOut occurs when the output directory is empty. ErrNoDirOut = errors.New("need output directory") )
Functions ¶
This section is empty.
Types ¶
type Fixset ¶
type Fixset struct { // InjectStdbool is true when the Litmus header needs includes to 'stdbool.h' enabling. InjectStdbool bool // UseAsCall is true when Litmus needs the '-ascall' flag enabling. UseAsCall bool // RemoveAtomicCasts is true when casts to (_Atomic int) in the outcome dumper must be removed. RemoveAtomicCasts bool }
Fixset contains the various fix-ups that the litmus tool needs to do before and after the run to Litmus.
func (*Fixset) Args ¶
Args converts the part of the fixset that relates to litmus7 arguments into an argument slice to send to litmus7.
Example ¶
ExampleFixset_Args is a runnable example for Args.
package main import ( "fmt" "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" ) func main() { f := litmus.Fixset{InjectStdbool: true, UseAsCall: true} for _, s := range f.Args() { fmt.Println(s) } }
Output: -ascall true
func (*Fixset) Dump ¶
Dump dumps a human-readable description of the fixset to the given writer.
Example ¶
ExampleFixset_Dump is a runnable example for Write.
package main import ( "os" "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" ) func main() { f := litmus.Fixset{InjectStdbool: true, UseAsCall: true} _ = f.Dump(os.Stdout) }
Output: injecting stdbool using -ascall
func (*Fixset) NeedsPatch ¶
NeedsPatch checks whether patching the litmus harness is necessary.
Example ¶
ExampleFixset_NeedsPatch is a runnable example for NeedsPatch.
package main import ( "fmt" "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" ) func main() { fmt.Println((&litmus.Fixset{}).NeedsPatch()) fmt.Println((&litmus.Fixset{UseAsCall: true}).NeedsPatch()) fmt.Println((&litmus.Fixset{InjectStdbool: true}).NeedsPatch()) }
Output: false false true
func (*Fixset) PatchMainFile ¶
PatchMainFile patches the main C file represented by rw according to this fixset.
func (*Fixset) PopulateFromLitmus ¶
PopulateFromLitmus switches various fixes on as appropriate for the Litmus file l.
func (*Fixset) PopulateFromStats ¶
PopulateFromStats switches various fixes on according to the statistics in s.
type Instance ¶
type Instance struct { // Job contains the lifting job being processed. Job backend.LiftJob // RunInfo contains the appropriately resolved run info for running Litmus. RunInfo service.RunInfo // Runner is the thing that actually runs Litmus. Runner service.Runner }
Instance holds all state needed to do one run of Litmus.
func (*Instance) Run ¶
Run runs the litmus wrapper according to the configuration c.
Example ¶
ExampleInstance_Run is a testable example for Run.
package main import ( "context" "os" "github.com/c4-project/c4t/internal/model/service/backend" "github.com/c4-project/c4t/internal/helper/srvrun" "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" "github.com/c4-project/c4t/internal/id" mdl "github.com/c4-project/c4t/internal/model/litmus" "github.com/c4-project/c4t/internal/model/service" ) func main() { i := litmus.Instance{ Job: backend.LiftJob{ Arch: id.ArchX8664, In: backend.LiftLitmusInput(mdl.NewOrPanic("in.litmus", mdl.WithArch(id.ArchC))), Out: backend.LiftOutput{Dir: "out", Target: backend.ToExeRecipe}, }, RunInfo: service.RunInfo{Cmd: "litmus7", Args: []string{"-v"}}, Runner: srvrun.DryRunner{Writer: os.Stdout}, } // We don't ask for a fixset, so we won't have any patching. _ = i.Run(context.Background()) }
Output: litmus7 -v -o out -carch X86_64 -c11 true in.litmus
type Litmus ¶
type Litmus struct{}
Litmus describes the parts of a backend invocation that are specific to Litmus.
func (Litmus) LiftExe ¶
func (l Litmus) LiftExe(ctx context.Context, j backend.LiftJob, r service.RunInfo, x service.Runner) error
LiftExe runs litmus in a mode that generates files compilable into an executable.
func (Litmus) LiftStandalone ¶
func (l Litmus) LiftStandalone(ctx context.Context, j backend.LiftJob, r service.RunInfo, x service.Runner, w io.Writer) error
LiftStandalone runs litmus in standalone mode. It currently doesn't do the same patching as LiftExe does.
func (Litmus) ParsePreTestLine ¶
ParsePreTestLine does nothing, as pre-Test lines have no meaning in Litmus.
func (Litmus) ParseStateCount ¶
ParseStateCount parses a Litmus state count.
type Pathset ¶
type Pathset struct { // FileIn is the input file path. FileIn string // DirOut is the output directory path. DirOut string }
Pathset contains the paths used in a litmus invocation.
func (*Pathset) Args ¶
Args gets this pathset's contribution to the litmus invocation arguments. These arguments should go at the end of the invocation.
Example ¶
ExamplePathset_Args is a runnable example for Args.
package main import ( "fmt" litmus2 "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" ) func main() { for _, arg := range (&litmus2.Pathset{ FileIn: "/home/foo/bar/baz.litmus", DirOut: "/tmp/scratch/", }).Args() { fmt.Println(arg) } }
Output: -o /tmp/scratch/ /home/foo/bar/baz.litmus
func (*Pathset) Check ¶
Check checks that the various paths in Pathset are populated. It doesn't check that they exist.
func (*Pathset) MainCFile ¶
MainCFile guesses where Litmus is going to put the main file in its generated harness.
Example ¶
ExamplePathset_MainCFile is a runnable example for MainCFile.
package main import ( "fmt" litmus2 "github.com/c4-project/c4t/internal/serviceimpl/backend/herdstyle/litmus" ) func main() { fmt.Println((&litmus2.Pathset{ FileIn: "/home/foo/bar/baz.litmus", DirOut: "/tmp/scratch/", }).MainCFile()) }
Output: /tmp/scratch/baz.c