File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change
1
+ _fuzz /
Original file line number Diff line number Diff line change 1
1
GOPATH =$(shell go env GOPATH)
2
2
GOLANGCI_LINT =$(GOPATH ) /bin/golangci-lint
3
+ GOFUZZBUILD = $(GOPATH ) /bin/go-fuzz-build
4
+ GOFUZZ = $(GOPATH ) /bin/go-fuzz
3
5
4
6
.PHONY : lint
5
7
lint : $(GOLANGCI_LINT )
@@ -16,8 +18,20 @@ test-cover:
16
18
@echo " ==> Running Tests with coverage"
17
19
GO111MODULE=on go test -cover .
18
20
21
+ .PHONY : fuzz
22
+ fuzz : $(GOFUZZBUILD ) $(GOFUZZ )
23
+ @echo " ==> Fuzz testing"
24
+ $(GOFUZZBUILD )
25
+ $(GOFUZZ ) -workdir=_fuzz
26
+
19
27
$(GOLANGCI_LINT ) :
20
28
# Install golangci-lint. The configuration for it is in the .golangci.yml
21
29
# file in the root of the repository
22
30
echo ${GOPATH}
23
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH ) /bin v1.17.1
31
+ curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH ) /bin v1.17.1
32
+
33
+ $(GOFUZZBUILD ) :
34
+ cd / && go get -u github.com/dvyukov/go-fuzz/go-fuzz-build
35
+
36
+ $(GOFUZZ ) :
37
+ cd / && go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-dep
Original file line number Diff line number Diff line change
1
+ // +build gofuzz
2
+
3
+ package semver
4
+
5
+ func Fuzz (data []byte ) int {
6
+ d := string (data )
7
+
8
+ // Test NewVersion
9
+ _ , _ = NewVersion (d )
10
+
11
+ // Test StrictNewVersion
12
+ _ , _ = StrictNewVersion (d )
13
+
14
+ // Test NewConstraint
15
+ _ , _ = NewConstraint (d )
16
+
17
+ // The return value should be 0 normally, 1 if the priority in future tests
18
+ // should be increased, and -1 if future tests should skip passing in that
19
+ // data. We do not have a reason to change priority so 0 is always returned.
20
+ // There are example tests that do this.
21
+ return 0
22
+ }
You can’t perform that action at this time.
0 commit comments