/
pathset.go
52 lines (41 loc) · 1.43 KB
/
pathset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2020-2021 C4 Project
//
// This file is part of c4t.
// Licenced under the MIT licence; see `LICENSE`.
package fuzzer
import (
"path/filepath"
"github.com/c4-project/c4t/internal/helper/iohelp"
)
const (
// segLitmus is the directory element added to the root directory to form the litmus directory.
segLitmus = "litmus"
// segTrace is the directory element added to the root directory to form the trace directory.
segTrace = "trace"
)
// Pathset contains the pre-computed paths used by a run of the fuzzer.
type Pathset struct {
// DirLitmus is the directory to which litmus tests will be written.
DirLitmus string
// DirTrace is the directory to which traces will be written.
DirTrace string
}
// NewPathset constructs a new pathset from the directory root.
func NewPathset(root string) *Pathset {
return &Pathset{
DirLitmus: filepath.Join(root, segLitmus),
DirTrace: filepath.Join(root, segTrace),
}
}
// Prepare prepares this pathset by making its directories.
func (p *Pathset) Prepare() error {
return iohelp.Mkdirs(p.DirTrace, p.DirLitmus)
}
// SubjectLitmus gets the litmus filepath for the subject/cycle pair c.
func (p *Pathset) SubjectLitmus(c SubjectCycle) string {
return filepath.Join(p.DirLitmus, c.String()+".litmus")
}
// SubjectTrace gets the litmus filepath for the subject/cycle pair c.
func (p *Pathset) SubjectTrace(c SubjectCycle) string {
return filepath.Join(p.DirTrace, c.String()+".trace")
}