...
1 package coverage
2
3 import (
4
5 "testing"
6 )
7
8 var (
9 libFuzzertestCase1 = []byte{5, 65, 68, 65, 77, 49, 4, 65, 68, 65, 77, 1, 2, 0, 65, 66, 65, 77, 49, 0, 0, 4}
10 goTestCase1 = `go test fuzz v1
11 string("ADAM1")
12 string("ADAM")
13 int(1)
14 []byte("AB")`
15 fuzzer1 = `package fuzzpackage
16
17 import (
18 "fmt"
19 "testing"
20 )
21
22 func FuzzTest(f *testing.F) {
23 f.Fuzz(func(t *testing.T, data1, data2 string, in int, data3 []byte) {
24 fmt.Println("HERE")
25 })
26 }`
27 )
28
29 func TestGetFuzzArgs(t *testing.T) {
30 args, err := getFuzzArgs(fuzzer1, "FuzzTest")
31 if err != nil {
32 t.Error(err)
33 }
34 if args[0] != "string" {
35 t.Log(fuzzer1)
36 t.Error("args[0] should be []byte but is not")
37 }
38 if args[1] != "string" {
39 t.Log(fuzzer1)
40 t.Error("args[0] should be []byte but is not")
41 }
42 if args[2] != "int" {
43 t.Log(fuzzer1)
44 t.Error("args[0] should be int but is not")
45 }
46 if args[3] != "[]byte" {
47 t.Log(fuzzer1)
48 t.Error("args[0] should be string but is not")
49 }
50
51 libFuzzerTestcase := libFuzzerSeedToGoSeed(libFuzzertestCase1, args)
52 if libFuzzerTestcase != goTestCase1 {
53 t.Error("Failed testcase conversion")
54 }
55 }
56
View as plain text