Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
43e1f6ae
Commit
43e1f6ae
authored
Dec 01, 2016
by
Dan Winship
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update gofuzz
parent
44f00e10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
Godeps.json
Godeps/Godeps.json
+1
-1
README.md
vendor/github.com/google/gofuzz/README.md
+4
-4
fuzz.go
vendor/github.com/google/gofuzz/fuzz.go
+10
-3
No files found.
Godeps/Godeps.json
View file @
43e1f6ae
...
...
@@ -1348,7 +1348,7 @@
},
{
"ImportPath"
:
"github.com/google/gofuzz"
,
"Rev"
:
"
bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
"
"Rev"
:
"
44d81051d367757e1c7c6a5a86423ece9afcf63c
"
},
{
"ImportPath"
:
"github.com/gorilla/context"
,
...
...
vendor/github.com/google/gofuzz/README.md
View file @
43e1f6ae
...
...
@@ -14,21 +14,21 @@ This is useful for testing:
Import with
```import "github.com/google/gofuzz"```
You can use it on single variables:
```
```
go
f
:=
fuzz
.
New
()
var
myInt
int
f
.
Fuzz
(
&
myInt
)
// myInt gets a random value.
```
You can use it on maps:
```
```
go
f
:=
fuzz
.
New
()
.
NilChance
(
0
)
.
NumElements
(
1
,
1
)
var
myMap
map
[
ComplexKeyType
]
string
f
.
Fuzz
(
&
myMap
)
// myMap will have exactly one element.
```
Customize the chance of getting a nil pointer:
```
```
go
f
:=
fuzz
.
New
()
.
NilChance
(
.5
)
var
fancyStruct
struct
{
A
,
B
,
C
,
D
*
string
...
...
@@ -37,7 +37,7 @@ f.Fuzz(&fancyStruct) // About half the pointers should be set.
```
You can even customize the randomization completely if needed:
```
```
go
type
MyEnum
string
const
(
A
MyEnum
=
"A"
...
...
vendor/github.com/google/gofuzz/fuzz.go
View file @
43e1f6ae
...
...
@@ -129,7 +129,7 @@ func (f *Fuzzer) genElementCount() int {
if
f
.
minElements
==
f
.
maxElements
{
return
f
.
minElements
}
return
f
.
minElements
+
f
.
r
.
Intn
(
f
.
maxElements
-
f
.
minElements
)
return
f
.
minElements
+
f
.
r
.
Intn
(
f
.
maxElements
-
f
.
minElements
+
1
)
}
func
(
f
*
Fuzzer
)
genShouldFill
()
bool
{
...
...
@@ -229,12 +229,19 @@ func (f *Fuzzer) doFuzz(v reflect.Value, flags uint64) {
return
}
v
.
Set
(
reflect
.
Zero
(
v
.
Type
()))
case
reflect
.
Array
:
if
f
.
genShouldFill
()
{
n
:=
v
.
Len
()
for
i
:=
0
;
i
<
n
;
i
++
{
f
.
doFuzz
(
v
.
Index
(
i
),
0
)
}
return
}
v
.
Set
(
reflect
.
Zero
(
v
.
Type
()))
case
reflect
.
Struct
:
for
i
:=
0
;
i
<
v
.
NumField
();
i
++
{
f
.
doFuzz
(
v
.
Field
(
i
),
0
)
}
case
reflect
.
Array
:
fallthrough
case
reflect
.
Chan
:
fallthrough
case
reflect
.
Func
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment