mirror of
https://github.com/golang/go
synced 2024-11-17 09:04:44 -07:00
cmd/go/testdata/script: consistently set GOCACHE in fuzz tests
The fuzzing cache for interesting inputs is shared across all invocations of scripts by default. When 'go clean -fuzzcache' is called, or fuzz targets in different scripts have the same names, we can get race-y unexpected behavior. Since there isn't a easy way to set just the fuzz cache directory (test has the flag -test.fuzzcachedir, but it requires setting it on each call to 'go test'), instead we just consistently set GOCACHE to point to a directory in the WORK dir. As a byproduct this also prevents usage of a shared build cache, so we see an increase in build time for these tests. Updates #59062 Change-Id: Ie78f2943b94f3302c5bdf1f8a1e93b207853666a Reviewed-on: https://go-review.googlesource.com/c/go/+/476755 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
785ab2fa65
commit
f594a3ec85
2
src/cmd/go/testdata/script/test_fuzz.txt
vendored
2
src/cmd/go/testdata/script/test_fuzz.txt
vendored
@ -1,4 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Test that running a fuzz target that returns without failing or calling
|
||||
# f.Fuzz fails and causes a non-zero exit status.
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Run chatty fuzz targets with an error.
|
||||
! go test -v chatty_error_fuzz_test.go
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Cleanup should run after F.Skip.
|
||||
go test -run=FuzzTargetSkip
|
||||
|
2
src/cmd/go/testdata/script/test_fuzz_cov.txt
vendored
2
src/cmd/go/testdata/script/test_fuzz_cov.txt
vendored
@ -4,10 +4,10 @@
|
||||
|
||||
[short] skip
|
||||
[!fuzz-instrumented] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# TODO(#51484): enabled debugging info to help diagnose a deadlock in the fuzzer
|
||||
env GODEBUG=fuzzdebug=1
|
||||
go clean --fuzzcache
|
||||
! go test -fuzz=FuzzCov -v
|
||||
! stderr 'cov instrumentation working'
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# The fuzz function should be able to detect whether -timeout
|
||||
# was set with T.Deadline. Note there is no F.Deadline, and
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# This test checks that cached corpus loading properly handles duplicate entries (this can
|
||||
# happen when a f.Add value has a duplicate entry in the cached corpus.) Duplicate entries
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# There are no seed values, so 'go test' should finish quickly.
|
||||
go test
|
||||
@ -14,8 +15,6 @@ exec ./fuzz.test$GOEXE -test.timeout=3s -test.fuzz=FuzzFast -test.fuzztime=5s -t
|
||||
# Timeout should not cause inputs to be written as crashers.
|
||||
! exists testdata/fuzz
|
||||
|
||||
env GOCACHE=$WORK/tmp
|
||||
|
||||
# When we use fuzztime with an "x" suffix, it runs a specific number of times.
|
||||
# This fuzz function creates a file with a unique name ($pid.$count) on each
|
||||
# run. We count the files to find the number of runs.
|
||||
|
@ -7,6 +7,7 @@
|
||||
# due to ^C and EOF errors which are more common. We don't report those.
|
||||
[short] skip
|
||||
[!fuzz] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# If the I/O error occurs before F.Fuzz is called, the coordinator should
|
||||
# stop the worker and say that.
|
||||
|
@ -1,12 +1,12 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# FuzzA attempts to cause the mutator to create duplicate inputs that generate
|
||||
# new coverage. Previously this would trigger a corner case when the fuzzer
|
||||
# had a execution limit, causing it to deadlock and sit in the coordinator
|
||||
# loop indefinitely, failing to exit once the limit had been exhausted.
|
||||
|
||||
go clean --fuzzcache
|
||||
go test -fuzz=FuzzA -fuzztime=100x -parallel=1
|
||||
|
||||
-- go.mod --
|
||||
|
@ -1,4 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Matches only fuzz targets to test.
|
||||
go test standalone_fuzz_test.go
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# With fuzzing disabled, multiple targets can be tested.
|
||||
go test ./...
|
||||
|
@ -6,6 +6,7 @@
|
||||
# to the seed corpus in testdata, and failing the next time the test is run.
|
||||
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Running the seed corpus for all of the targets should pass the first
|
||||
# time, since nothing in the seed corpus will cause a crash.
|
||||
|
@ -4,6 +4,7 @@
|
||||
# 'go test' exits non-zero and no crasher is recorded.
|
||||
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
! go test -fuzz=FuzzReturn
|
||||
! exists testdata
|
||||
|
@ -8,6 +8,7 @@
|
||||
# tests seed values and the worker tests mutated values on the fuzz target.
|
||||
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
go test -fuzz=FuzzA -fuzztime=100x -parallel=1 -log=fuzz
|
||||
go run check_logs.go fuzz fuzz.worker
|
||||
|
@ -6,6 +6,7 @@
|
||||
# to the coordinator.
|
||||
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Start fuzzing. The worker crashes after 100 iterations.
|
||||
# The fuzz function writes the crashing input to "want" before exiting.
|
||||
|
@ -3,6 +3,7 @@
|
||||
[GOOS:windows] skip
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# FuzzNonCrash sends itself a signal that does not appear to be a crash.
|
||||
# We should not save a crasher.
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# When running seed inputs, T.Parallel should let multiple inputs run in
|
||||
# parallel.
|
||||
|
@ -1,5 +1,6 @@
|
||||
[!fuzz] skip
|
||||
[short] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
go test -fuzz=FuzzA -fuzztime=100x fuzz_setenv_test.go
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
[short] skip
|
||||
[!fuzz] skip
|
||||
[!race] skip
|
||||
env GOCACHE=$WORK/cache
|
||||
|
||||
# Test with coverage instrumentation enabled (-fuzz) and race instrumentation
|
||||
# but without actually fuzzing the target (by using a non-matching pattern)
|
||||
|
Loading…
Reference in New Issue
Block a user