Skip to content

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

@elias-orijtech

Description

@elias-orijtech

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions