-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
fuzz_test.go
58 lines (39 loc) · 965 Bytes
/
fuzz_test.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
package dbresolver
import (
"fmt"
"testing"
fuzz "github.com/google/gofuzz"
)
func FuzzMultiWrite(f *testing.F) {
func() { // generate corpus
var rdbCount, wdbCount, lbPolicyID uint8 = 1, 1, 1
if !testing.Short() {
fuzzer := fuzz.New()
fuzzer.Fuzz(&rdbCount)
fuzzer.Fuzz(&wdbCount)
fuzzer.Fuzz(&lbPolicyID)
}
f.Add(wdbCount, rdbCount, lbPolicyID)
}()
f.Fuzz(func(t *testing.T, wdbCount, rdbCount, lbPolicyID uint8) { //next-release: uint8 -> uint
policyID := lbPolicyID % uint8(len(LoadBalancerPolicies))
config := DBConfig{
wdbCount, rdbCount, LoadBalancerPolicies[policyID],
}
if config.primaryDBCount == 0 {
t.Skipf("skipping due to mising primary db")
}
t.Log("dbConf", config)
t.Run(fmt.Sprintf("%v", config), func(t *testing.T) {
dbConf := config
testMW(t, dbConf)
})
})
}
/*func FuzzTest(f *testing.F) {
f.Add(1)
f.Fuzz(func(t *testing.T, dbCount int) {
t.Fatal(dbCount)
})
}
*/