-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
53 lines (44 loc) · 1.12 KB
/
main.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
package main
import (
"fmt"
"io/ioutil"
"os"
)
/*
* Accepts an executable file and an input file to run it with.
*/
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage:", os.Args[0], "<binary>", "<input file>")
return
}
// create channels for mutator and harness
mutatorToHarness := make(chan TestCase)
harnessToInteresting := make(chan TestCase)
input, err := ioutil.ReadFile(os.Args[2])
if err != nil {
fmt.Println("Unable to read input file")
return
}
if isValidCSV(os.Args[2]) {
generatorToHarness := make(chan TestCase)
go generateCSVs(generatorToHarness, os.Args[2])
go harness(5, "./"+os.Args[1], generatorToHarness, harnessToInteresting)
}
// create mutator threads
for i := 0; i < 4; i++ {
go func(i int) {
mutator := createMutator(mutatorToHarness, int64(i))
for {
temp := append([]byte{}, input...)
ts := &TestCase{temp, []string{}}
mutator.mutate(ts)
}
}(i)
}
// create harness threads
for i := 0; i < 4; i++ {
go harness(i, "./"+os.Args[1], mutatorToHarness, harnessToInteresting)
}
harness(4, "./"+os.Args[1], mutatorToHarness, harnessToInteresting)
}