Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: respect -count when running fuzz corpus tests #52464

Open
elias-orijtech opened this issue Apr 21, 2022 · 1 comment
Open

testing: respect -count when running fuzz corpus tests #52464

elias-orijtech opened this issue Apr 21, 2022 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@elias-orijtech
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.18 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/e/.cache/go-build"
GOENV="/home/e/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/e/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/e/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/h2w6bc9dpcfvr76cfz8ymv7l5llfjjsj-go-1.18/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/h2w6bc9dpcfvr76cfz8ymv7l5llfjjsj-go-1.18/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/e/Downloads/fuzzcount/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1871101059=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ cat fuzzcount_test.go
package fuzzcount

import "testing"

func TestA(t *testing.T) {
	t.Logf("TestA: ran")
}

func FuzzA(f *testing.F) {
	f.Add([]byte("test"))
	f.Fuzz(func(t *testing.T, _ []byte) {
		t.Logf("FuzzA: ran")
	})
}
$ go mod init fuzzcount
$ go test -count 5 -v .
=== RUN   TestA
    fuzzcount_test.go:6: TestA: ran
--- PASS: TestA (0.00s)
=== RUN   TestA
    fuzzcount_test.go:6: TestA: ran
--- PASS: TestA (0.00s)
=== RUN   TestA
    fuzzcount_test.go:6: TestA: ran
--- PASS: TestA (0.00s)
=== RUN   TestA
    fuzzcount_test.go:6: TestA: ran
--- PASS: TestA (0.00s)
=== RUN   TestA
    fuzzcount_test.go:6: TestA: ran
--- PASS: TestA (0.00s)
=== RUN   FuzzA
=== RUN   FuzzA/seed#0
    fuzzcount_test.go:12: FuzzA: ran
--- PASS: FuzzA (0.00s)
    --- PASS: FuzzA/seed#0 (0.00s)
PASS
ok  	fuzzcount	0.001s

What did you expect to see?

5 instances of FuzzA: ran.

What did you see instead?

Only one instance of FuzzA: ran.

Specifying -count XX to go test is for repeating test runs XX times; I'd expect the same behaviour for tests implied by a fuzz target corpus.

@bcmills bcmills changed the title cmd/go: respect -count when running fuzz corpus tests testing: respect -count when running fuzz corpus tests Apr 21, 2022
@bcmills
Copy link
Contributor

bcmills commented Apr 21, 2022

(attn @golang/fuzzing)

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 22, 2022
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants