-
Notifications
You must be signed in to change notification settings - Fork 11
/
gobench_executor.go
59 lines (48 loc) · 1.1 KB
/
gobench_executor.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
53
54
55
56
57
58
59
package gobench
import (
"log"
"os"
"time"
)
type Executor interface {
Build()
Run() *SingleRunResult
Done()
GetResult() *BatchRunResult
TestEntryAndFunc() (string, string)
}
type ExecEnvConfig struct {
BugConfigPath string
ClearDirs bool
Tag string // for GoReal only
Count int
Cpu int
Timeout time.Duration
Repeat int
PositiveCheckFunc func(r *SingleRunResult) bool
NegativeCheckFunc func(r *SingleRunResult) bool
}
type ExecBugConfig struct {
ExecEnvConfig
Bug Bug
SourceDir string // source directory of a bug
OutputDir string // output directory of an execution
}
func NewDefaultExecutor(config ExecBugConfig) Executor {
if config.SourceDir == "" {
config.SourceDir = config.Bug.forkedPath
}
if config.OutputDir == "" {
config.OutputDir = config.Bug.forkedPath
}
if IsNotExists(config.OutputDir) {
if err := os.MkdirAll(config.OutputDir, 0775); err != nil {
log.Println(config.OutputDir)
panic(err)
}
}
if config.Bug.isGoReal() {
return newGoRealExecuter(config)
}
return newGoKerExecuter(config)
}