]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.fuzz] all: merge master (af72ddf) into dev.fuzz
authorKatie Hockman <katie@golang.org>
Mon, 20 Sep 2021 19:45:51 +0000 (15:45 -0400)
committerKatie Hockman <katie@golang.org>
Mon, 20 Sep 2021 19:46:10 +0000 (15:46 -0400)
This now includes the fix in CL 350729, which means
we no longer need to skip the test in dev.fuzz.

Conflicts:

- src/cmd/compile/internal/noder/unified_test.go

Merge List:

+ 2021-09-20 af72ddfcd7 cmd/compile: extend dump-to-file to handle "genssa" (asm) case.
+ 2021-09-20 3c764babe7 cmd/go: write go.mod requirements more consistently for go 1.17+
+ 2021-09-20 6268468e02 cmd/link: generate DIE for types referenced only through dictionaries
+ 2021-09-20 6acac8b685 cmd/compile: delay all transforms for generic funcs/methods
+ 2021-09-20 988f18d61d go/types: export Named._Orig as Named.Origin
+ 2021-09-20 b6dddaccd7 cmd/compile: fix transform.AssignOp to deal with tricky case
+ 2021-09-20 9e60c37147 cmd/compile: document register-based ABI for ppc64
+ 2021-09-20 79159f2e83 cmd/compile: fix simplification rules on arm/arm64
+ 2021-09-20 eff27e858b cmd/compile: ensure constant shift amounts are in range for arm
+ 2021-09-20 9ebe7c8ec6 go/test: add a test for issue 48344
+ 2021-09-20 6f35430faa cmd/compile: allow rotates to be merged with logical ops on arm64
+ 2021-09-20 2d9b486420 cmd/compile: update doc at top of iexport.go on the changes for typeparams
+ 2021-09-20 a81b0dc6ee cmd/compile: rename instType -> instanceType
+ 2021-09-20 119213566a cmd/cgo: remove hardcoded '-pie' ldflag for linux/arm
+ 2021-09-20 a83a558733 cmd/compile: fix export/import of range loop.
+ 2021-09-19 315dbd10c9 cmd/compile: fold double negate on arm64
+ 2021-09-19 83b36ffb10 cmd/compile: implement constant rotates on arm64
+ 2021-09-19 771b8ea4f4 cmd/compile: fix missing markHiddenClosureDead in deadcode pass
+ 2021-09-18 c894b442d1 net/rpc: remove warnings on incompatible methods at registration
+ 2021-09-17 4b654c0eec cmd/compile: SSA ".this" variable
+ 2021-09-17 f01721efb9 cmd/compile: remove self copies in tail-call wrappers
+ 2021-09-17 163871feb1 time: re-add space-padded day of year to docs
+ 2021-09-17 ac7c34767d time: support fractional timezone minutes in MarshalBinary
+ 2021-09-17 07b30a4f77 cmd/compile: delay transformAssign if lhs/rhs have typeparam
+ 2021-09-17 c10b980220 cmd/compile: restore tail call for method wrappers
+ 2021-09-17 50e4508269 cmd/compile: fix import/export of Init and Def fields.
+ 2021-09-17 3fa35b5f97 go/types: ensure that we always get a new signature in expandNamed
+ 2021-09-17 3fa7dbeff5 cmd/go: fix GOARCH value in GOAMD64 docs
+ 2021-09-17 974b0166d6 syscall: implement Pipe using pipe2 syscall on all linux platforms
+ 2021-09-17 1a49dcb82f syscall: remove //sysnb comment generating Setreuid for linux/arm64
+ 2021-09-17 cea7a71d40 cmd/compile: fix generic type handling in crawler
+ 2021-09-17 74e384f50d internal/poll: inject a hook into the runtime finalizer to count the closed pipes
+ 2021-09-17 323c6f74d3 log: don't format if writing to io.Discard
+ 2021-09-17 7f36ef0aff cmd/compile/internal/noder: hide TestUnifiedCompare behind -cmp flag
+ 2021-09-17 70493b3eb0 runtime/cgo: save and restore X3 (aka GP) for crosscall1 on riscv64
+ 2021-09-17 6d02ce8584 runtime: fix prettyprinting of parametric types in gdb
+ 2021-09-17 6602c86a38 cmd/internal/obj/riscv: improve instruction validation
+ 2021-09-17 14e812bfc5 syscall: do not use handle lists on windows when NoInheritHandles is true
+ 2021-09-16 8d2a9c32a2 all: remove incorrectly repeated words in comments
+ 2021-09-16 af9da137a9 A+C: update name to real name and add to AUTHORS
+ 2021-09-16 265b59aefd cmd/cgo: for godefs, don't let field prefix removal cause duplicates
+ 2021-09-16 4efdaa7bc7 testing: skip panics when picking the line number for decoration
+ 2021-09-16 e09dcc211a go/types, types2: add an additional shift test case
+ 2021-09-16 5402b4376c spec: fix incorrect type in a shift example
+ 2021-09-16 d09e09bc61 cmd/compile: fixing writebarrier.go for -G=3
+ 2021-09-16 bcdc61d830 cmd/compile: preserve statements better in expandCalls
+ 2021-09-16 48e2b1ea91 cmd/compile: fix LocResults formatting
+ 2021-09-16 b1bedc0774 cmd/go: add GOAMD64 environment variable
+ 2021-09-16 04f5116c98 cmd/go: clean paths before checking same directory
+ 2021-09-16 e7dbe3908e cmd/cgo: add missing tab in exports for a result of void
+ 2021-09-15 cfa233d76b cmd/compile: remove unneeded early transforms, with dictionary change
+ 2021-09-15 59a9a035ff cmd/compile: switch to computing dict format on instantiated functions
+ 2021-09-15 0edc6c4fa0 cmd/internal/obj/ppc64: generate prologue code compatible with new ABI
+ 2021-09-15 03df68d3c3 runtime: fix setting of cpu features for amd64
+ 2021-09-15 6196979365 cmd/go/internal/modload: prevent tidy downgrading disambiguating modules
+ 2021-09-15 72bb8185b5 cmd/compile: emit DWARF info about dictionary entries
+ 2021-09-15 5b48fca1fa cmd/compile: mark wrapper functions with DW_AT_trampoline
+ 2021-09-15 e4dfd788e6 go/internal/gcimporter,cmd/compile: minor clean-up in iimport.go
+ 2021-09-15 4847c47cb8 cmd/compile/internal/types2: eliminate Named.instPos
+ 2021-09-15 3100f54f20 cmd/compile/internal/types2: merge Named type loading and expansion
+ 2021-09-15 738cebb174 cmd/compile/internal/types2: implement Identical for *Union types
+ 2021-09-15 b26d325cb1 cmd/compile/internal/types2: remove some unnecessary loading/expansion of Named types
+ 2021-09-15 9fc28892cb cmd/compile/internal/types2: export TypeHash, return value without blanks
+ 2021-09-15 2da3375e9b runtime: in adjustTimers back up as far as necessary
+ 2021-09-15 c7f2f51fed cmd/go: remove subcommand prefix from error messages
+ 2021-09-15 0bb40b08c4 go/types: implement Identical for *Union types
+ 2021-09-15 cb4e1de021 go/types: minor cleanup of instantiation
+ 2021-09-15 a0f3129466 go/types: instantiate methods when instantiating Named types
+ 2021-09-14 bf26e43d0f go/types: eliminate Named.instPos
+ 2021-09-14 2933c451a0 go/types: merge Named type loading and expansion
+ 2021-09-14 137543bb93 cmd/compile: set IsShape based on type being in the Shapes pkg
+ 2021-09-14 3a72175cdc cmd/compile: fix test/typeparam/mdempsky/4.go for -G=3
+ 2021-09-14 b2c04f0d48 runtime: avoid loop variable capture in test
+ 2021-09-14 181e8cde30 go/internal/gcimporter: remove outdated comment
+ 2021-09-14 8699425b55 syscall: remove use of IN_KUBERNETES in test
+ 2021-09-14 b3c6de9dcd cmd/internal/obj/ppc64: allow VR register arguments to VS registers
+ 2021-09-14 ee91bb8319 cmd/compile: prevent typecheck importer reading type parameter twice
+ 2021-09-14 2953cd0083 go/internal/gcimporter: prevent importReader reading type parameter twice
+ 2021-09-14 b8c802b116 cmd/compile: prevent importReader reading type parameter twice
+ 2021-09-14 4a4221e818 all: remove some unused code
+ 2021-09-14 71adc658de runtime: change time.now to ABIInternal
+ 2021-09-14 146e8d4994 reflect: use Value.Len instead of conversion to slice header
+ 2021-09-13 9a58aa267e spec: fix prose about terminating statements
+ 2021-09-13 42057e9848 cmd/compile: save the note of fields when translating struct
+ 2021-09-13 960d036f8f cmd/go: add missing parenthesis in a call to "PrintVersion"
+ 2021-09-13 81a4fe6fd2 cmd/link/internal/ld: re-enable DWARF tests on solaris/illumos
+ 2021-09-13 f93a63addb reflect: add a floating point section to DeepEqual tests
+ 2021-09-13 a0c409cbc8 reflect: add fast paths for common, simple Kinds to DeepEqual
+ 2021-09-13 ac40c9872f reflect: fix _faststr optimization
+ 2021-09-13 c8a58f29dc cmd/go: add test to check for a potential workspace loading issue
+ 2021-09-13 e74e363a6b strings: add Clone function
+ 2021-09-13 bced369a50 cmd/link: minor code cleanup in dwarf gen
+ 2021-09-13 c3b217a0e5 cmd/go: document 'go install cmd@version' ignores vendor directories
+ 2021-09-12 ad97d204f0 go/types: remove some unnecessary loading/expansion of Named types
+ 2021-09-12 0d8a4bfc96 bufio: add Writer.AvailableBuffer
+ 2021-09-11 23832ba2e2 reflect: optimize for maps with string keys
+ 2021-09-11 a50225a0dc bufio: make Reader.Reset and Writer.Reset work on the zero value
+ 2021-09-10 cf2fe5d6f1 doc/asm: fix HTML markup
+ 2021-09-10 1bf2cd1291 debug/elf: retain original error message when getSymbols fails.
+ 2021-09-10 5a4b9f9494 time: reference -tags=timetzdata in testing panic
+ 2021-09-10 025308fe08 testing: increase alternation precedence
+ 2021-09-10 5a94a90d84 cmd/compile/internal/types2: better error message for invalid array decls
+ 2021-09-10 da1aa65053 cmd/compile/internal/syntax: correct follow token for type parameter lists
+ 2021-09-10 96ab854ab0 cmd/compile/internal: better AST line highlight in ssa.html
+ 2021-09-10 90c5660616 embed: guarantee the returned file of FS.Open implements io.Seeker
+ 2021-09-10 c69f5c0d76 cmd/compile: add support for Abs and Copysign intrinsics on riscv64
+ 2021-09-10 2091bd3f26 cmd/compile: simiplify arm64 bitfield optimizations
+ 2021-09-09 b32209d22d cmd/compile: fix test case for unified IR (fix build)
+ 2021-09-09 1a708bcf1d cmd/compile: don't crash while reporting invalid alias cycle
+ 2021-09-09 426ff3746f cmd/cgo, runtime/cgo: avoid GCC/clang conversion warnings
+ 2021-09-09 73483df406 cmd/compile/internal/syntax: better error message for missing type constraint
+ 2021-09-09 e1c3f2158f time: propagate "," separator for fractional seconds into Format
+ 2021-09-09 c981874a5a cmd/compile: fix implement for closure in a global assignment
+ 2021-09-09 2c4f389c02 cmd/link: enable internal linker in more cases for ppc64le
+ 2021-09-09 fb84e99eb7 test: add compiler regress tests for #46461
+ 2021-09-09 b9e1a24581 cmd/compile: fix case where init info of OAS node is dropped
+ 2021-09-09 f9271e4f85 go/types, types2: rename RParams -> RecvTypeParams
+ 2021-09-09 ea434450c2 reflect: add hooks for dealing with narrow width floats
+ 2021-09-09 a53e3d5f88 net: deprecate (net.Error).Temporary
+ 2021-09-09 19457a58e5 cmd/compile: stenciled conversions might be NOPs
+ 2021-09-09 a295b3cec8 test: re-enable AsmCheck tests for types2-based frontends
+ 2021-09-09 66f0d35f71 go/types: reduce number of delayed functions
+ 2021-09-09 d2a77f1c76 go/types: handle recursive type parameter constraints
+ 2021-09-09 9e1eea6f8b go/types: detect constraint type inference cycles
+ 2021-09-09 b86e8dd0f3 test/typeparam: fix issue48094b test build
+ 2021-09-09 c84f3a4004 syscall: drop fallback to pipe in Pipe on linux/arm
+ 2021-09-09 376a079762 cmd/compile: fix unified IR panic when expanding nested inline function
+ 2021-09-09 6edc57983a internal/poll: report open fds when TestSplicePipePool fails
+ 2021-09-09 2481f6e367 cmd/compile: fix wrong instantiated type for embedded receiver
+ 2021-09-09 d62866ef79 cmd/compile: move checkptr alignment to SSA generation
+ 2021-09-09 8fad81cd62 cmd/compile: fold handling OCONV logic to separate function
+ 2021-09-09 9cbc76bdf9 cmd/internal/obj/arm64: add checks for incorrect use of REGTMP register
+ 2021-09-09 42563f89d7 cmd/compile: remove 'ext' fields from unified IR reader/writer types
+ 2021-09-09 4c52eac49b cmd/compile: simplify value coding for unified IR
+ 2021-09-09 e30a09013b cmd/compile: extrapolate $GOROOT in unified IR
+ 2021-09-08 a1f6208e56 go/types, types2: add Environment to Config
+ 2021-09-08 f5f8a911d8 cmd/compile/internal/types2: spell out 'Type' in type parameter APIs
+ 2021-09-08 bff39cf6cb cmd/compile: add automated rewrite cycle detection
+ 2021-09-08 b61e1ed863 cmd/compile/internal/types2: temporarily pin the Checker to Interface during checking
+ 2021-09-08 47f3e1e02c cmd/compile/internal/types2: move NewTypeParam off of Checker
+ 2021-09-08 ccc927b8f6 cmd/compile/internal/types2: move typeHash to environment.go
+ 2021-09-08 30e9bfbcef cmd/compile/internal/types2: implement deduplication of instances using the Environment
+ 2021-09-08 0406d3a8e5 go/ast: rename MultiIndexExpr to IndexListExpr

Change-Id: I7f917d45b0507c122c212305144b0b455618ff54

1  2 
src/cmd/go/alldocs.go
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/clean/clean.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/test/test.go
src/cmd/go/internal/test/testflag.go
src/cmd/go/internal/work/init.go
src/testing/testing.go

diff --combined src/cmd/go/alldocs.go
index 18afaf1706b984a27f46db3e9ca2bf70c2032ee4,9753ebba3e64e5143869c733d8dfd0075b2f28d1..74522691abd68a45037cd42c938bedc7b7fb65d2
@@@ -53,7 -53,6 +53,7 @@@
  //    private         configuration for downloading non-public code
  //    testflag        testing flags
  //    testfunc        testing functions
 +//    fuzz            fuzzing
  //    vcs             controlling version control with GOVCS
  //
  // Use "go help <topic>" for more information about that topic.
  // download cache, including unpacked source code of versioned
  // dependencies.
  //
 +// The -fuzzcache flag causes clean to remove values used for fuzz testing.
 +//
  // For more about build flags, see 'go help build'.
  //
  // For more about specifying packages, see 'go help packages'.
  //
  // - All arguments must refer to packages in the same module at the same version.
  //
+ // - Package path arguments must refer to main packages. Pattern arguments
+ // will only match main packages.
+ //
  // - No module is considered the "main" module. If the module containing
  // packages named on the command line has a go.mod file, it must not contain
  // directives (replace and exclude) that would cause it to be interpreted
  // differently than if it were the main module. The module must not require
  // a higher version of itself.
  //
- // - Package path arguments must refer to main packages. Pattern arguments
- // will only match main packages.
+ // - Vendor directories are not used in any module. (Vendor directories are not
+ // included in the module zip files downloaded by 'go install'.)
  //
  // If the arguments don't have version suffixes, "go install" may run in
  // module-aware mode or GOPATH mode, depending on the GO111MODULE environment
  //
  // 'Go test' recompiles each package along with any files with names matching
  // the file pattern "*_test.go".
 -// These additional files can contain test functions, benchmark functions, and
 -// example functions. See 'go help testfunc' for more.
 +// These additional files can contain test functions, benchmark functions, fuzz
 +// targets and example functions. See 'go help testfunc' for more.
  // Each listed package causes the execution of a separate test binary.
  // Files whose names begin with "_" (including "_test.go") or "." are ignored.
  //
  // in no time at all,so a successful package test result will be cached and
  // reused regardless of -timeout setting.
  //
 +// Run 'go help fuzz' for details around how the go command handles fuzz targets.
 +//
  // In addition to the build flags, the flags handled by 'go test' itself are:
  //
  //    -args
  //    GO386
  //            For GOARCH=386, how to implement floating point instructions.
  //            Valid values are sse2 (default), softfloat.
+ //    GOAMD64
+ //            For GOARCH=amd64, the microarchitecture level for which to compile.
+ //            Valid values are v1 (default), v2, v3, v4.
+ //            See https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels.
  //    GOMIPS
  //            For GOARCH=mips{,le}, whether to use floating point instructions.
  //            Valid values are hardfloat (default), softfloat.
  //        (for example, -benchtime 100x).
  //
  //    -count n
 -//        Run each test and benchmark n times (default 1).
 +//        Run each test, benchmark, and fuzz targets' seed corpora n times
 +//        (default 1).
  //        If -cpu is set, run n times for each GOMAXPROCS value.
  //        Examples are always run once.
  //
  //        Sets -cover.
  //
  //    -cpu 1,2,4
 -//        Specify a list of GOMAXPROCS values for which the tests or
 -//        benchmarks should be executed. The default is the current value
 +//        Specify a list of GOMAXPROCS values for which the tests, benchmarks or
 +//        fuzz targets should be executed. The default is the current value
  //        of GOMAXPROCS.
  //
  //    -failfast
  //        Do not start new tests after the first test failure.
  //
 +//    -fuzz name
 +//        Run the fuzz target with the given regexp. Must match exactly one fuzz
 +//        target. This is an experimental feature.
 +//
 +//    -fuzztime t
 +//        Run enough iterations of the fuzz test to take t, specified as a
 +//        time.Duration (for example, -fuzztime 1h30s). The default is to run
 +//        forever.
 +//        The special syntax Nx means to run the fuzz test N times
 +//        (for example, -fuzztime 100x).
 +//
  //    -json
  //        Log verbose output and test results in JSON. This presents the
  //        same information as the -v flag in a machine-readable format.
  //
 +//    -keepfuzzing
 +//        Keep running the fuzz target if a crasher is found.
 +//
  //    -list regexp
 -//        List tests, benchmarks, or examples matching the regular expression.
 -//        No tests, benchmarks or examples will be run. This will only
 -//        list top-level tests. No subtest or subbenchmarks will be shown.
 +//        List tests, benchmarks, fuzz targets, or examples matching the regular
 +//        expression. No tests, benchmarks, fuzz targets, or examples will be run.
 +//        This will only list top-level tests. No subtest or subbenchmarks will be
 +//        shown.
  //
  //    -parallel n
 -//        Allow parallel execution of test functions that call t.Parallel.
 +//        Allow parallel execution of test functions that call t.Parallel, and
 +//        f.Fuzz functions that call t.Parallel when running the seed corpus.
  //        The value of this flag is the maximum number of tests to run
 -//        simultaneously; by default, it is set to the value of GOMAXPROCS.
 +//        simultaneously. While fuzzing, the value of this flag is the
 +//        maximum number of workers to run the fuzz function simultaneously,
 +//        regardless of whether t.Parallel has been called; by default, it is set
 +//        to the value of GOMAXPROCS.
  //        Note that -parallel only applies within a single test binary.
  //        The 'go test' command may run tests for different packages
  //        in parallel as well, according to the setting of the -p flag
  //        (see 'go help build').
  //
  //    -run regexp
 -//        Run only those tests and examples matching the regular expression.
 -//        For tests, the regular expression is split by unbracketed slash (/)
 -//        characters into a sequence of regular expressions, and each part
 -//        of a test's identifier must match the corresponding element in
 +//        Run only those tests, examples, and fuzz targets matching the regular
 +//        expression. For tests, the regular expression is split by unbracketed
 +//        slash (/) characters into a sequence of regular expressions, and each
 +//        part of a test's identifier must match the corresponding element in
  //        the sequence, if any. Note that possible parents of matches are
  //        run too, so that -run=X/Y matches and runs and reports the result
  //        of all tests matching X, even those without sub-tests matching Y,
  //
  //    func BenchmarkXxx(b *testing.B) { ... }
  //
 +// A fuzz target is one named FuzzXxx and should have the signature,
 +//
 +//    func FuzzXxx(f *testing.F) { ... }
 +//
  // An example function is similar to a test function but, instead of using
  // *testing.T to report success or failure, prints output to os.Stdout.
  // If the last comment in the function starts with "Output:" then the output
  //
  // The entire test file is presented as the example when it contains a single
  // example function, at least one other function, type, variable, or constant
 -// declaration, and no test or benchmark functions.
 +// declaration, and no fuzz targets or test or benchmark functions.
  //
  // See the documentation of the testing package for more information.
  //
  //
 +// Fuzzing
 +//
 +// By default, go test will build and run the fuzz targets using the target's seed
 +// corpus only. Any generated corpora in $GOCACHE that were previously written by
 +// the fuzzing engine will not be run by default.
 +//
 +// When -fuzz is set, the binary will be instrumented for coverage. After all
 +// tests, examples, benchmark functions, and the seed corpora for all fuzz targets
 +// have been run, go test will begin to fuzz the specified fuzz target.
 +// Note that this feature is experimental.
 +//
 +// -run can be used for testing a single seed corpus entry for a fuzz target. The
 +// regular expression value of -run can be in the form $target/$name, where $target
 +// is the name of the fuzz target, and $name is the name of the file (ignoring file
 +// extensions) to run. For example, -run=FuzzFoo/497b6f87.
 +//
 +// See https://golang.org/s/draft-fuzzing-design for more details.
 +//
 +//
  // Controlling version control with GOVCS
  //
  // The 'go get' command can run version control commands like git
index ac2c70fa60028768f66fb743e38bcc1fedbb22eb,5f4465e06b1d45a2e0277d3596c325b84b759e96..dd0e8cbbd668f82bd3e41387a44b655f5f761e97
@@@ -60,10 -60,6 +60,10 @@@ var 
  
  func defaultContext() build.Context {
        ctxt := build.Default
 +
 +      // TODO(#47037): remove this tag before merging to master.
 +      ctxt.BuildTags = []string{"gofuzzbeta"}
 +
        ctxt.JoinPath = filepath.Join // back door to say "do not use go command"
  
        ctxt.GOROOT = findGOROOT()
@@@ -267,6 -263,7 +267,7 @@@ var 
        // Used in envcmd.MkEnv and build ID computations.
        GOARM    = envOr("GOARM", fmt.Sprint(buildcfg.GOARM))
        GO386    = envOr("GO386", buildcfg.GO386)
+       GOAMD64  = envOr("GOAMD64", fmt.Sprintf("%s%d", "v", buildcfg.GOAMD64))
        GOMIPS   = envOr("GOMIPS", buildcfg.GOMIPS)
        GOMIPS64 = envOr("GOMIPS64", buildcfg.GOMIPS64)
        GOPPC64  = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", buildcfg.GOPPC64))
@@@ -293,6 -290,8 +294,8 @@@ func GetArchEnv() (key, val string) 
                return "GOARM", GOARM
        case "386":
                return "GO386", GO386
+       case "amd64":
+               return "GOAMD64", GOAMD64
        case "mips", "mipsle":
                return "GOMIPS", GOMIPS
        case "mips64", "mips64le":
index 13d6961511672a2ea704be6d76ca12bcabea53c6,1089211f0ce0d3881f4ddbd64cd1779f7263db09..518473c914913a556295a306413f4b2b0cfb768a
@@@ -75,8 -75,6 +75,8 @@@ The -modcache flag causes clean to remo
  download cache, including unpacked source code of versioned
  dependencies.
  
 +The -fuzzcache flag causes clean to remove values used for fuzz testing.
 +
  For more about build flags, see 'go help build'.
  
  For more about specifying packages, see 'go help packages'.
@@@ -87,7 -85,6 +87,7 @@@ var 
        cleanI         bool // clean -i flag
        cleanR         bool // clean -r flag
        cleanCache     bool // clean -cache flag
 +      cleanFuzzcache bool // clean -fuzzcache flag
        cleanModcache  bool // clean -modcache flag
        cleanTestcache bool // clean -testcache flag
  )
@@@ -99,7 -96,6 +99,7 @@@ func init() 
        CmdClean.Flag.BoolVar(&cleanI, "i", false, "")
        CmdClean.Flag.BoolVar(&cleanR, "r", false, "")
        CmdClean.Flag.BoolVar(&cleanCache, "cache", false, "")
 +      CmdClean.Flag.BoolVar(&cleanFuzzcache, "fuzzcache", false, "")
        CmdClean.Flag.BoolVar(&cleanModcache, "modcache", false, "")
        CmdClean.Flag.BoolVar(&cleanTestcache, "testcache", false, "")
  
@@@ -116,7 -112,7 +116,7 @@@ func runClean(ctx context.Context, cmd 
        // or no other target (such as a cache) was requested to be cleaned.
        cleanPkg := len(args) > 0 || cleanI || cleanR
        if (!modload.Enabled() || modload.HasModRoot()) &&
 -              !cleanCache && !cleanModcache && !cleanTestcache {
 +              !cleanCache && !cleanModcache && !cleanTestcache && !cleanFuzzcache {
                cleanPkg = true
        }
  
                                                // This also mimics what os.RemoveAll(dir) would do.
                                                if err := os.RemoveAll(d); err != nil && !printedErrors {
                                                        printedErrors = true
-                                                       base.Errorf("go clean -cache: %v", err)
+                                                       base.Errorf("go: %v", err)
                                                }
                                        }
                                }
                        if !cfg.BuildN {
                                if err := os.RemoveAll(logFile); err != nil && !printedErrors {
                                        printedErrors = true
-                                       base.Errorf("go clean -cache: %v", err)
+                                       base.Errorf("go: %v", err)
                                }
                        }
                }
                        }
                        if err != nil {
                                if _, statErr := os.Stat(dir); !os.IsNotExist(statErr) {
-                                       base.Errorf("go clean -testcache: %v", err)
+                                       base.Errorf("go: %v", err)
                                }
                        }
                }
  
        if cleanModcache {
                if cfg.GOMODCACHE == "" {
-                       base.Fatalf("go clean -modcache: no module cache")
+                       base.Fatalf("go: cannot clean -modcache without a module cache")
                }
                if cfg.BuildN || cfg.BuildX {
                        b.Showcmd("", "rm -rf %s", cfg.GOMODCACHE)
                }
                if !cfg.BuildN {
                        if err := modfetch.RemoveAll(cfg.GOMODCACHE); err != nil {
-                               base.Errorf("go clean -modcache: %v", err)
+                               base.Errorf("go: %v", err)
                        }
                }
        }
 +
 +      if cleanFuzzcache {
 +              fuzzDir := cache.Default().FuzzDir()
 +              if cfg.BuildN || cfg.BuildX {
 +                      b.Showcmd("", "rm -rf %s", fuzzDir)
 +              }
 +              if !cfg.BuildN {
 +                      if err := os.RemoveAll(fuzzDir); err != nil {
 +                              base.Errorf("go clean -fuzzcache: %v", err)
 +                      }
 +              }
 +      }
  }
  
  var cleaned = map[*load.Package]bool{}
@@@ -261,7 -245,7 +261,7 @@@ func clean(p *load.Package) 
        }
        dirs, err := os.ReadDir(p.Dir)
        if err != nil {
-               base.Errorf("go clean %s: %v", p.Dir, err)
+               base.Errorf("go: %s: %v", p.Dir, err)
                return
        }
  
                                        }
                                }
                                if err := os.RemoveAll(filepath.Join(p.Dir, name)); err != nil {
-                                       base.Errorf("go clean: %v", err)
+                                       base.Errorf("go: %v", err)
                                }
                        }
                        continue
@@@ -402,5 -386,5 +402,5 @@@ func removeFile(f string) 
                        return
                }
        }
-       base.Errorf("go clean: %v", err)
+       base.Errorf("go: %v", err)
  }
index 38e15cccc817442a7707791a3460394af77e20fa,4013330bc47f9dc18c1c7b728ad7625ab3a4bf77..317053d9182320b3f95d5bab6ed03b54f050cd61
@@@ -2630,20 -2630,10 +2630,20 @@@ func (e *mainPackageError) ImportPath(
  
  func setToolFlags(pkgs ...*Package) {
        for _, p := range PackageList(pkgs) {
 -              p.Internal.Asmflags = BuildAsmflags.For(p)
 -              p.Internal.Gcflags = BuildGcflags.For(p)
 -              p.Internal.Ldflags = BuildLdflags.For(p)
 -              p.Internal.Gccgoflags = BuildGccgoflags.For(p)
 +              appendFlags(p, &p.Internal.Asmflags, &BuildAsmflags)
 +              appendFlags(p, &p.Internal.Gcflags, &BuildGcflags)
 +              appendFlags(p, &p.Internal.Ldflags, &BuildLdflags)
 +              appendFlags(p, &p.Internal.Gccgoflags, &BuildGccgoflags)
 +      }
 +}
 +
 +func appendFlags(p *Package, flags *[]string, packageFlag *PerPackageFlag) {
 +      if !packageFlag.seenPackages[p] {
 +              if packageFlag.seenPackages == nil {
 +                      packageFlag.seenPackages = make(map[*Package]bool)
 +              }
 +              packageFlag.seenPackages[p] = true
 +              *flags = append(*flags, packageFlag.For(p)...)
        }
  }
  
@@@ -2684,10 -2674,7 +2684,7 @@@ func GoFilesPackage(ctx context.Context
                if fi.IsDir() {
                        base.Fatalf("%s is a directory, should be a Go file", file)
                }
-               dir1, _ := filepath.Split(file)
-               if dir1 == "" {
-                       dir1 = "./"
-               }
+               dir1 := filepath.Dir(file)
                if dir == "" {
                        dir = dir1
                } else if dir != dir1 {
index 173e8a2ee47980d289a4f361244cca0480f6abe1,198afbf4c3d8d1cf0332815e27caa70de810f711..8f5d57eff14cd877a1bdf577c4bd1cd1297a8a6b
@@@ -61,8 -61,8 +61,8 @@@ followed by detailed output for each fa
  
  'Go test' recompiles each package along with any files with names matching
  the file pattern "*_test.go".
 -These additional files can contain test functions, benchmark functions, and
 -example functions. See 'go help testfunc' for more.
 +These additional files can contain test functions, benchmark functions, fuzz
 +targets and example functions. See 'go help testfunc' for more.
  Each listed package causes the execution of a separate test binary.
  Files whose names begin with "_" (including "_test.go") or "." are ignored.
  
@@@ -132,8 -132,6 +132,8 @@@ variables are unchanged. A cached test 
  in no time at all,so a successful package test result will be cached and
  reused regardless of -timeout setting.
  
 +Run 'go help fuzz' for details around how the go command handles fuzz targets.
 +
  In addition to the build flags, the flags handled by 'go test' itself are:
  
        -args
@@@ -210,8 -208,7 +210,8 @@@ control the execution of any test
            (for example, -benchtime 100x).
  
        -count n
 -          Run each test and benchmark n times (default 1).
 +          Run each test, benchmark, and fuzz targets' seed corpora n times
 +          (default 1).
            If -cpu is set, run n times for each GOMAXPROCS value.
            Examples are always run once.
  
            Sets -cover.
  
        -cpu 1,2,4
 -          Specify a list of GOMAXPROCS values for which the tests or
 -          benchmarks should be executed. The default is the current value
 +          Specify a list of GOMAXPROCS values for which the tests, benchmarks or
 +          fuzz targets should be executed. The default is the current value
            of GOMAXPROCS.
  
        -failfast
            Do not start new tests after the first test failure.
  
 +      -fuzz name
 +          Run the fuzz target with the given regexp. Must match exactly one fuzz
 +          target. This is an experimental feature.
 +
 +      -fuzztime t
 +          Run enough iterations of the fuzz test to take t, specified as a
 +          time.Duration (for example, -fuzztime 1h30s). The default is to run
 +          forever.
 +          The special syntax Nx means to run the fuzz test N times
 +          (for example, -fuzztime 100x).
 +
        -json
            Log verbose output and test results in JSON. This presents the
            same information as the -v flag in a machine-readable format.
  
 +      -keepfuzzing
 +          Keep running the fuzz target if a crasher is found.
 +
        -list regexp
 -          List tests, benchmarks, or examples matching the regular expression.
 -          No tests, benchmarks or examples will be run. This will only
 -          list top-level tests. No subtest or subbenchmarks will be shown.
 +          List tests, benchmarks, fuzz targets, or examples matching the regular
 +          expression. No tests, benchmarks, fuzz targets, or examples will be run.
 +          This will only list top-level tests. No subtest or subbenchmarks will be
 +          shown.
  
        -parallel n
 -          Allow parallel execution of test functions that call t.Parallel.
 +          Allow parallel execution of test functions that call t.Parallel, and
 +          f.Fuzz functions that call t.Parallel when running the seed corpus.
            The value of this flag is the maximum number of tests to run
 -          simultaneously; by default, it is set to the value of GOMAXPROCS.
 +          simultaneously. While fuzzing, the value of this flag is the
 +          maximum number of workers to run the fuzz function simultaneously,
 +          regardless of whether t.Parallel has been called; by default, it is set
 +          to the value of GOMAXPROCS.
            Note that -parallel only applies within a single test binary.
            The 'go test' command may run tests for different packages
            in parallel as well, according to the setting of the -p flag
            (see 'go help build').
  
        -run regexp
 -          Run only those tests and examples matching the regular expression.
 -          For tests, the regular expression is split by unbracketed slash (/)
 -          characters into a sequence of regular expressions, and each part
 -          of a test's identifier must match the corresponding element in
 +          Run only those tests, examples, and fuzz targets matching the regular
 +          expression. For tests, the regular expression is split by unbracketed
 +          slash (/) characters into a sequence of regular expressions, and each
 +          part of a test's identifier must match the corresponding element in
            the sequence, if any. Note that possible parents of matches are
            run too, so that -run=X/Y matches and runs and reports the result
            of all tests matching X, even those without sub-tests matching Y,
@@@ -458,10 -436,6 +458,10 @@@ A benchmark function is one named Bench
  
        func BenchmarkXxx(b *testing.B) { ... }
  
 +A fuzz target is one named FuzzXxx and should have the signature,
 +
 +      func FuzzXxx(f *testing.F) { ... }
 +
  An example function is similar to a test function but, instead of using
  *testing.T to report success or failure, prints output to os.Stdout.
  If the last comment in the function starts with "Output:" then the output
@@@ -501,34 -475,12 +501,34 @@@ Here is another example where the order
  
  The entire test file is presented as the example when it contains a single
  example function, at least one other function, type, variable, or constant
 -declaration, and no test or benchmark functions.
 +declaration, and no fuzz targets or test or benchmark functions.
  
  See the documentation of the testing package for more information.
  `,
  }
  
 +var HelpFuzz = &base.Command{
 +      UsageLine: "fuzz",
 +      Short:     "fuzzing",
 +      Long: `
 +By default, go test will build and run the fuzz targets using the target's seed
 +corpus only. Any generated corpora in $GOCACHE that were previously written by
 +the fuzzing engine will not be run by default.
 +
 +When -fuzz is set, the binary will be instrumented for coverage. After all
 +tests, examples, benchmark functions, and the seed corpora for all fuzz targets
 +have been run, go test will begin to fuzz the specified fuzz target.
 +Note that this feature is experimental.
 +
 +-run can be used for testing a single seed corpus entry for a fuzz target. The
 +regular expression value of -run can be in the form $target/$name, where $target
 +is the name of the fuzz target, and $name is the name of the file (ignoring file
 +extensions) to run. For example, -run=FuzzFoo/497b6f87.
 +
 +See https://golang.org/s/draft-fuzzing-design for more details.
 +`,
 +}
 +
  var (
        testBench        string                            // -bench flag
        testC            bool                              // -c flag
        testCoverPaths   []string                          // -coverpkg flag
        testCoverPkgs    []*load.Package                   // -coverpkg flag
        testCoverProfile string                            // -coverprofile flag
 +      testFuzz         string                            // -fuzz flag
        testJSON         bool                              // -json flag
        testList         string                            // -list flag
        testO            string                            // -o flag
@@@ -671,9 -622,6 +671,9 @@@ func runTest(ctx context.Context, cmd *
        if testO != "" && len(pkgs) != 1 {
                base.Fatalf("cannot use -o flag with multiple packages")
        }
 +      if testFuzz != "" && len(pkgs) != 1 {
 +              base.Fatalf("cannot use -fuzz flag with multiple packages")
 +      }
        if testProfile() != "" && len(pkgs) != 1 {
                base.Fatalf("cannot use %s flag with multiple packages", testProfile())
        }
        // to that timeout plus one minute. This is a backup alarm in case
        // the test wedges with a goroutine spinning and its background
        // timer does not get a chance to fire.
 -      if testTimeout > 0 {
 +      // Don't set this if fuzzing, since it should be able to run
 +      // indefinitely.
 +      if testTimeout > 0 && testFuzz == "" {
                testKillTimeout = testTimeout + 1*time.Minute
        }
  
        b.Init()
  
        if cfg.BuildI {
-               fmt.Fprint(os.Stderr, "go test: -i flag is deprecated\n")
+               fmt.Fprint(os.Stderr, "go: -i flag is deprecated\n")
                cfg.BuildV = testV
  
                deps := make(map[string]bool)
                }
        }
  
 +      // Inform the compiler that it should instrument the binary at
 +      // build-time when fuzzing is enabled.
 +      fuzzFlags := work.FuzzInstrumentFlags()
 +      if testFuzz != "" && fuzzFlags != nil {
 +              // Don't instrument packages which may affect coverage guidance but are
 +              // unlikely to be useful. Most of these are used by the testing or
 +              // internal/fuzz concurrently with fuzzing.
 +              var fuzzNoInstrument = map[string]bool{
 +                      "context":       true,
 +                      "internal/fuzz": true,
 +                      "reflect":       true,
 +                      "runtime":       true,
 +                      "sync":          true,
 +                      "sync/atomic":   true,
 +                      "syscall":       true,
 +                      "testing":       true,
 +                      "time":          true,
 +              }
 +              for _, p := range load.TestPackageList(ctx, pkgOpts, pkgs) {
 +                      if fuzzNoInstrument[p.ImportPath] {
 +                              continue
 +                      }
 +                      p.Internal.Gcflags = append(p.Internal.Gcflags, fuzzFlags...)
 +              }
 +      }
 +
        // Prepare build + run + print actions for all packages being tested.
        for _, p := range pkgs {
                // sync/atomic import is inserted by the cover tool. See #18486
@@@ -1167,8 -1087,6 +1167,8 @@@ func declareCoverVars(p *load.Package, 
  }
  
  var noTestsToRun = []byte("\ntesting: warning: no tests to run\n")
 +var noTargetsToFuzz = []byte("\ntesting: warning: no targets to fuzz\n")
 +var tooManyTargetsToFuzz = []byte("\ntesting: warning: -fuzz matches more than one target, won't fuzz\n")
  
  type runCache struct {
        disableCache bool // cache should be disabled for this run
@@@ -1216,10 -1134,10 +1216,10 @@@ func (c *runCache) builderRunTest(b *wo
        }
  
        var buf bytes.Buffer
 -      if len(pkgArgs) == 0 || (testBench != "") {
 +      if len(pkgArgs) == 0 || testBench != "" || testFuzz != "" {
                // Stream test output (no buffering) when no package has
                // been given on the command line (implicit current directory)
 -              // or when benchmarking.
 +              // or when benchmarking or fuzzing.
                // No change to stdout.
        } else {
                // If we're only running a single package under test or if parallelism is
                testlogArg = []string{"-test.testlogfile=" + a.Objdir + "testlog.txt"}
        }
        panicArg := "-test.paniconexit0"
 -      args := str.StringList(execCmd, a.Deps[0].BuiltTarget(), testlogArg, panicArg, testArgs)
 +      fuzzArg := []string{}
 +      if testFuzz != "" {
 +              fuzzCacheDir := filepath.Join(cache.Default().FuzzDir(), a.Package.ImportPath)
 +              fuzzArg = []string{"-test.fuzzcachedir=" + fuzzCacheDir}
 +      }
 +      args := str.StringList(execCmd, a.Deps[0].BuiltTarget(), testlogArg, panicArg, fuzzArg, testArgs)
  
        if testCoverProfile != "" {
                // Write coverage to temporary profile, for merging later.
                if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) {
                        norun = " [no tests to run]"
                }
 +              if bytes.HasPrefix(out, noTargetsToFuzz[1:]) || bytes.Contains(out, noTargetsToFuzz) {
 +                      norun = " [no targets to fuzz]"
 +              }
 +              if bytes.HasPrefix(out, tooManyTargetsToFuzz[1:]) || bytes.Contains(out, tooManyTargetsToFuzz) {
 +                      norun = " [will not fuzz, -fuzz matches more than one target]"
 +              }
                fmt.Fprintf(cmd.Stdout, "ok  \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun)
                c.saveOutput(a)
        } else {
index aca0dbd67b4988f1e2d646ddb411547f27ca6c12,e0a3e010faea80193e75ef7afc6158db31c9cbb0..cb3543884a4a3ce394048dff4d5aad0b1955d799
@@@ -57,7 -57,6 +57,7 @@@ func init() 
        cf.String("cpu", "", "")
        cf.StringVar(&testCPUProfile, "cpuprofile", "", "")
        cf.Bool("failfast", false, "")
 +      cf.StringVar(&testFuzz, "fuzz", "", "")
        cf.StringVar(&testList, "list", "", "")
        cf.StringVar(&testMemProfile, "memprofile", "", "")
        cf.String("memprofilerate", "", "")
@@@ -68,8 -67,6 +68,8 @@@
        cf.String("run", "", "")
        cf.Bool("short", false, "")
        cf.DurationVar(&testTimeout, "timeout", 10*time.Minute, "")
 +      cf.String("fuzztime", "", "")
 +      cf.String("fuzzminimizetime", "", "")
        cf.StringVar(&testTrace, "trace", "", "")
        cf.BoolVar(&testV, "v", false, "")
        cf.Var(&testShuffle, "shuffle", "")
@@@ -387,7 -384,7 +387,7 @@@ func testFlags(args []string) (packageN
                if !testC {
                        buildFlag = "-i"
                }
-               fmt.Fprintf(os.Stderr, "go test: unknown flag %s cannot be used with %s\n", firstUnknownFlag, buildFlag)
+               fmt.Fprintf(os.Stderr, "go: unknown flag %s cannot be used with %s\n", firstUnknownFlag, buildFlag)
                exitWithUsage()
        }
  
index 8674bbd9c955ee57374ac6399ab55dfbb5bfea6d,7aa8dfe55fdfb8a5838fed5c2691523c2c73ac9e..2a605e73ee1f86136444928faa6f732814b361d1
@@@ -13,7 -13,6 +13,6 @@@ import 
        "cmd/go/internal/modload"
        "cmd/internal/str"
        "cmd/internal/sys"
-       "flag"
        "fmt"
        "os"
        "path/filepath"
@@@ -33,7 -32,7 +32,7 @@@ func BuildInit() 
        if cfg.BuildPkgdir != "" && !filepath.IsAbs(cfg.BuildPkgdir) {
                p, err := filepath.Abs(cfg.BuildPkgdir)
                if err != nil {
-                       fmt.Fprintf(os.Stderr, "go %s: evaluating -pkgdir: %v\n", flag.Args()[0], err)
+                       fmt.Fprintf(os.Stderr, "go: evaluating -pkgdir: %v\n", err)
                        base.SetExitStatus(2)
                        base.Exit()
                }
                value := cfg.Getenv(key)
                args, err := str.SplitQuotedFields(value)
                if err != nil {
-                       base.Fatalf("go %s: %s environment variable could not be parsed: %v", flag.Args()[0], key, err)
+                       base.Fatalf("go: %s environment variable could not be parsed: %v", key, err)
                }
                if len(args) == 0 {
                        continue
                }
                path := args[0]
                if !filepath.IsAbs(path) && path != filepath.Base(path) {
-                       base.Fatalf("go %s: %s environment variable is relative; must be absolute path: %s\n", flag.Args()[0], key, path)
+                       base.Fatalf("go: %s environment variable is relative; must be absolute path: %s\n", key, path)
                }
        }
  }
  
 +func FuzzInstrumentFlags() []string {
 +      if cfg.Goarch != "amd64" && cfg.Goarch != "arm64" {
 +              // Instrumentation is only supported on 64-bit architectures.
 +              return nil
 +      }
 +      return []string{"-d=libfuzzer"}
 +}
 +
  func instrumentInit() {
        if !cfg.BuildRace && !cfg.BuildMSan {
                return
        }
        if cfg.BuildRace && cfg.BuildMSan {
-               fmt.Fprintf(os.Stderr, "go %s: may not use -race and -msan simultaneously\n", flag.Args()[0])
+               fmt.Fprintf(os.Stderr, "go: may not use -race and -msan simultaneously\n")
                base.SetExitStatus(2)
                base.Exit()
        }
@@@ -85,7 -76,7 +84,7 @@@
        }
        if cfg.BuildRace {
                if !sys.RaceDetectorSupported(cfg.Goos, cfg.Goarch) {
-                       fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64, darwin/arm64, and windows/amd64\n", flag.Args()[0])
+                       fmt.Fprintf(os.Stderr, "go: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64, darwin/arm64, and windows/amd64\n")
                        base.SetExitStatus(2)
                        base.Exit()
                }
  
        if !cfg.BuildContext.CgoEnabled {
                if runtime.GOOS != cfg.Goos || runtime.GOARCH != cfg.Goarch {
-                       fmt.Fprintf(os.Stderr, "go %s: %s requires cgo\n", flag.Args()[0], modeFlag)
+                       fmt.Fprintf(os.Stderr, "go: %s requires cgo\n", modeFlag)
                } else {
-                       fmt.Fprintf(os.Stderr, "go %s: %s requires cgo; enable cgo by setting CGO_ENABLED=1\n", flag.Args()[0], modeFlag)
+                       fmt.Fprintf(os.Stderr, "go: %s requires cgo; enable cgo by setting CGO_ENABLED=1\n", modeFlag)
                }
  
                base.SetExitStatus(2)
diff --combined src/testing/testing.go
index 18a0657561cff12e690878f90432643e83c3a675,2239e01e22439b804cdaa7c2660a4394d9637bfa..567eb0dfa39230f2201c5b69cca4b1624f6a666d
@@@ -34,7 -34,7 +34,7 @@@
  // its -bench flag is provided. Benchmarks are run sequentially.
  //
  // For a description of the testing flags, see
 -// https://golang.org/cmd/go/#hdr-Testing_flags
 +// https://golang.org/cmd/go/#hdr-Testing_flags.
  //
  // A sample benchmark function looks like this:
  //     func BenchmarkRandInt(b *testing.B) {
  // example function, at least one other function, type, variable, or constant
  // declaration, and no test or benchmark functions.
  //
 +// Fuzzing
 +//
 +// Functions of the form
 +//     func FuzzXxx(*testing.F)
 +// are considered fuzz targets, and are executed by the "go test" command. When
 +// the -fuzz flag is provided, the functions will be fuzzed.
 +//
 +// For a description of the testing flags, see
 +// https://golang.org/cmd/go/#hdr-Testing_flags.
 +//
 +// For a description of fuzzing, see golang.org/s/draft-fuzzing-design.
 +// TODO(#48255): write and link to documentation that will be helpful to users
 +// who are unfamiliar with fuzzing.
 +//
 +// A sample fuzz target looks like this:
 +//
 +//     func FuzzBytesCmp(f *testing.F) {
 +//         f.Fuzz(func(t *testing.T, a, b []byte) {
 +//             if bytes.HasPrefix(a, b) && !bytes.Contains(a, b) {
 +//                 t.Error("HasPrefix is true, but Contains is false")
 +//             }
 +//         })
 +//     }
 +//
  // Skipping
  //
  // Tests or benchmarks may be skipped at run time with a call to
  //         ...
  //     }
  //
 +// The Skip method of *T can be used in a fuzz target if the input is invalid,
 +// but should not be considered a crash. For example:
 +//
 +//     func FuzzJSONMarshalling(f *testing.F) {
 +//         f.Fuzz(func(t *testing.T, b []byte) {
 +//             var v interface{}
 +//             if err := json.Unmarshal(b, &v); err != nil {
 +//                 t.Skip()
 +//             }
 +//             if _, err := json.Marshal(v); err != nil {
 +//                 t.Error("Marshal: %v", err)
 +//             }
 +//         })
 +//     }
 +//
  // Subtests and Sub-benchmarks
  //
  // The Run methods of T and B allow defining subtests and sub-benchmarks,
  // of the top-level test and the sequence of names passed to Run, separated by
  // slashes, with an optional trailing sequence number for disambiguation.
  //
 -// The argument to the -run and -bench command-line flags is an unanchored regular
 +// The argument to the -run, -bench, and -fuzz command-line flags is an unanchored regular
  // expression that matches the test's name. For tests with multiple slash-separated
  // elements, such as subtests, the argument is itself slash-separated, with
  // expressions matching each name element in turn. Because it is unanchored, an
  // empty expression matches any string.
  // For example, using "matching" to mean "whose name contains":
  //
 -//     go test -run ''      # Run all tests.
 -//     go test -run Foo     # Run top-level tests matching "Foo", such as "TestFooBar".
 -//     go test -run Foo/A=  # For top-level tests matching "Foo", run subtests matching "A=".
 -//     go test -run /A=1    # For all top-level tests, run subtests matching "A=1".
 +//     go test -run ''        # Run all tests.
 +//     go test -run Foo       # Run top-level tests matching "Foo", such as "TestFooBar".
 +//     go test -run Foo/A=    # For top-level tests matching "Foo", run subtests matching "A=".
 +//     go test -run /A=1      # For all top-level tests, run subtests matching "A=1".
 +//     go test -fuzz FuzzFoo  # Fuzz the target matching "FuzzFoo"
 +//
 +// The -run argument can also be used to run a specific value in the seed
 +// corpus, for debugging. For example:
 +//     go test -run=FuzzFoo/9ddb952d9814
 +//
 +// The -fuzz and -run flags can both be set, in order to fuzz a target but
 +// skip the execution of all other tests.
  //
  // Subtests can also be used to control parallelism. A parent test will only
  // complete once all of its subtests complete. In this example, all tests are
@@@ -293,7 -246,6 +293,7 @@@ import 
        "io"
        "math/rand"
        "os"
 +      "reflect"
        "runtime"
        "runtime/debug"
        "runtime/trace"
@@@ -355,7 -307,6 +355,7 @@@ func Init() 
        shuffle = flag.String("test.shuffle", "off", "randomize the execution order of tests and benchmarks")
  
        initBenchmarkFlags()
 +      initFuzzFlags()
  }
  
  var (
@@@ -455,7 -406,6 +455,7 @@@ type common struct 
  
        chatty     *chattyPrinter // A copy of chattyPrinter, if the chatty flag is set.
        bench      bool           // Whether the current test is a benchmark.
 +      fuzzing    bool           // Whether the current test is a fuzzing target.
        hasSub     int32          // Written atomically.
        raceErrors int            // Number of races detected during test.
        runner     string         // Function name of tRunner running the test.
@@@ -533,6 -483,9 +533,9 @@@ func (c *common) frameSkip(skip int) ru
        var firstFrame, prevFrame, frame runtime.Frame
        for more := true; more; prevFrame = frame {
                frame, more = frames.Next()
+               if frame.Function == "runtime.gopanic" {
+                       continue
+               }
                if frame.Function == c.cleanupName {
                        frames = runtime.CallersFrames(c.cleanupPc)
                        continue
  // and inserts the final newline if needed and indentation spaces for formatting.
  // This function must be called with c.mu held.
  func (c *common) decorate(s string, skip int) string {
 +      if c.helperNames == nil {
 +              c.helperNames = make(map[string]struct{})
 +              for pc := range c.helperPCs {
 +                      c.helperNames[pcToName(pc)] = struct{}{}
 +              }
 +      }
 +
        frame := c.frameSkip(skip)
        file := frame.File
        line := frame.Line
@@@ -661,17 -607,6 +664,17 @@@ func (c *common) flushToParent(testName
        }
  }
  
 +// isFuzzing returns whether the current context, or any of the parent contexts,
 +// are a fuzzing target
 +func (c *common) isFuzzing() bool {
 +      for com := c; com != nil; com = com.parent {
 +              if com.fuzzing {
 +                      return true
 +              }
 +      }
 +      return false
 +}
 +
  type indenter struct {
        c *common
  }
@@@ -1148,12 -1083,6 +1151,12 @@@ func (t *T) Parallel() 
                panic("testing: t.Parallel called after t.Setenv; cannot set environment variables in parallel tests")
        }
        t.isParallel = true
 +      if t.parent.barrier == nil {
 +              // T.Parallel has no effect when fuzzing.
 +              // Multiple processes may run in parallel, but only one input can run at a
 +              // time per process so we can attribute crashes to specific inputs.
 +              return
 +      }
  
        // We don't want to include the time we spend waiting for serial tests
        // in the test duration. Record the elapsed time thus far and reset the
@@@ -1226,25 -1155,10 +1229,25 @@@ func tRunner(t *T, fn func(t *T)) 
                        t.Errorf("race detected during execution of test")
                }
  
 -              // If the test panicked, print any test output before dying.
 +              // Check if the test panicked or Goexited inappropriately.
 +              //
 +              // If this happens in a normal test, print output but continue panicking.
 +              // tRunner is called in its own goroutine, so this terminates the process.
 +              //
 +              // If this happens while fuzzing, recover from the panic and treat it like a
 +              // normal failure. It's important that the process keeps running in order to
 +              // find short inputs that cause panics.
                err := recover()
                signal := true
  
 +              if err != nil && t.isFuzzing() {
 +                      t.Errorf("panic: %s\n%s\n", err, string(debug.Stack()))
 +                      t.mu.Lock()
 +                      t.finished = true
 +                      t.mu.Unlock()
 +                      err = nil
 +              }
 +
                t.mu.RLock()
                finished := t.finished
                t.mu.RUnlock()
                                }
                        }
                }
 +
                // Use a deferred call to ensure that we report that the test is
                // complete even if a cleanup function calls t.FailNow. See issue 41355.
                didPanic := false
                t.report() // Report after all subtests have finished.
  
                // Do not lock t.done to allow race detector to detect race in case
 -              // the user does not appropriately synchronizes a goroutine.
 +              // the user does not appropriately synchronize a goroutine.
                t.done = true
                if t.parent != nil && atomic.LoadInt32(&t.hasSub) == 0 {
                        t.setRan()
@@@ -1480,16 -1393,6 +1483,16 @@@ func (f matchStringOnly) ImportPath() s
  func (f matchStringOnly) StartTestLog(io.Writer)                      {}
  func (f matchStringOnly) StopTestLog() error                          { return errMain }
  func (f matchStringOnly) SetPanicOnExit0(bool)                        {}
 +func (f matchStringOnly) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error {
 +      return errMain
 +}
 +func (f matchStringOnly) RunFuzzWorker(func(corpusEntry) error) error { return errMain }
 +func (f matchStringOnly) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) {
 +      return nil, errMain
 +}
 +func (f matchStringOnly) CheckCorpus([]interface{}, []reflect.Type) error { return nil }
 +func (f matchStringOnly) ResetCoverage()                                  {}
 +func (f matchStringOnly) SnapshotCoverage()                               {}
  
  // Main is an internal function, part of the implementation of the "go test" command.
  // It was exported because it is cross-package and predates "internal" packages.
  // new functionality is added to the testing package.
  // Systems simulating "go test" should be updated to use MainStart.
  func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) {
 -      os.Exit(MainStart(matchStringOnly(matchString), tests, benchmarks, examples).Run())
 +      os.Exit(MainStart(matchStringOnly(matchString), tests, benchmarks, nil, examples).Run())
  }
  
  // M is a type passed to a TestMain function to run the actual tests.
  type M struct {
 -      deps       testDeps
 -      tests      []InternalTest
 -      benchmarks []InternalBenchmark
 -      examples   []InternalExample
 +      deps        testDeps
 +      tests       []InternalTest
 +      benchmarks  []InternalBenchmark
 +      fuzzTargets []InternalFuzzTarget
 +      examples    []InternalExample
  
        timer     *time.Timer
        afterOnce sync.Once
@@@ -1532,25 -1434,18 +1535,25 @@@ type testDeps interface 
        StartTestLog(io.Writer)
        StopTestLog() error
        WriteProfileTo(string, io.Writer, int) error
 +      CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error
 +      RunFuzzWorker(func(corpusEntry) error) error
 +      ReadCorpus(string, []reflect.Type) ([]corpusEntry, error)
 +      CheckCorpus([]interface{}, []reflect.Type) error
 +      ResetCoverage()
 +      SnapshotCoverage()
  }
  
  // MainStart is meant for use by tests generated by 'go test'.
  // It is not meant to be called directly and is not subject to the Go 1 compatibility document.
  // It may change signature from release to release.
 -func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M {
 +func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, fuzzTargets []InternalFuzzTarget, examples []InternalExample) *M {
        Init()
        return &M{
 -              deps:       deps,
 -              tests:      tests,
 -              benchmarks: benchmarks,
 -              examples:   examples,
 +              deps:        deps,
 +              tests:       tests,
 +              benchmarks:  benchmarks,
 +              fuzzTargets: fuzzTargets,
 +              examples:    examples,
        }
  }
  
@@@ -1577,15 -1472,9 +1580,15 @@@ func (m *M) Run() (code int) 
                m.exitCode = 2
                return
        }
 +      if *matchFuzz != "" && *fuzzCacheDir == "" {
 +              fmt.Fprintln(os.Stderr, "testing: -test.fuzzcachedir must be set if -test.fuzz is set")
 +              flag.Usage()
 +              m.exitCode = 2
 +              return
 +      }
  
        if len(*matchList) != 0 {
 -              listTests(m.deps.MatchString, m.tests, m.benchmarks, m.examples)
 +              listTests(m.deps.MatchString, m.tests, m.benchmarks, m.fuzzTargets, m.examples)
                m.exitCode = 0
                return
        }
  
        m.before()
        defer m.after()
 -      deadline := m.startAlarm()
 -      haveExamples = len(m.examples) > 0
 -      testRan, testOk := runTests(m.deps.MatchString, m.tests, deadline)
 -      exampleRan, exampleOk := runExamples(m.deps.MatchString, m.examples)
 -      m.stopAlarm()
 -      if !testRan && !exampleRan && *matchBenchmarks == "" {
 -              fmt.Fprintln(os.Stderr, "testing: warning: no tests to run")
 +
 +      // Run tests, examples, and benchmarks unless this is a fuzz worker process.
 +      // Workers start after this is done by their parent process, and they should
 +      // not repeat this work.
 +      if !*isFuzzWorker {
 +              deadline := m.startAlarm()
 +              haveExamples = len(m.examples) > 0
 +              testRan, testOk := runTests(m.deps.MatchString, m.tests, deadline)
 +              fuzzTargetsRan, fuzzTargetsOk := runFuzzTargets(m.deps, m.fuzzTargets, deadline)
 +              exampleRan, exampleOk := runExamples(m.deps.MatchString, m.examples)
 +              m.stopAlarm()
 +              if !testRan && !exampleRan && !fuzzTargetsRan && *matchBenchmarks == "" && *matchFuzz == "" {
 +                      fmt.Fprintln(os.Stderr, "testing: warning: no tests to run")
 +              }
 +              if !testOk || !exampleOk || !fuzzTargetsOk || !runBenchmarks(m.deps.ImportPath(), m.deps.MatchString, m.benchmarks) || race.Errors() > 0 {
 +                      fmt.Println("FAIL")
 +                      m.exitCode = 1
 +                      return
 +              }
        }
 -      if !testOk || !exampleOk || !runBenchmarks(m.deps.ImportPath(), m.deps.MatchString, m.benchmarks) || race.Errors() > 0 {
 +
 +      fuzzingOk := runFuzzing(m.deps, m.fuzzTargets)
 +      if !fuzzingOk {
                fmt.Println("FAIL")
 -              m.exitCode = 1
 +              if *isFuzzWorker {
 +                      m.exitCode = fuzzWorkerExitCode
 +              } else {
 +                      m.exitCode = 1
 +              }
                return
        }
  
 -      fmt.Println("PASS")
        m.exitCode = 0
 +      if !*isFuzzWorker {
 +              fmt.Println("PASS")
 +      }
        return
  }
  
@@@ -1669,7 -1538,7 +1672,7 @@@ func (t *T) report() 
        }
  }
  
 -func listTests(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) {
 +func listTests(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, fuzzTargets []InternalFuzzTarget, examples []InternalExample) {
        if _, err := matchString(*matchList, "non-empty"); err != nil {
                fmt.Fprintf(os.Stderr, "testing: invalid regexp in -test.list (%q): %s\n", *matchList, err)
                os.Exit(1)
                        fmt.Println(bench.Name)
                }
        }
 +      for _, fuzzTarget := range fuzzTargets {
 +              if ok, _ := matchString(*matchList, fuzzTarget.Name); ok {
 +                      fmt.Println(fuzzTarget.Name)
 +              }
 +      }
        for _, example := range examples {
                if ok, _ := matchString(*matchList, example.Name); ok {
                        fmt.Println(example.Name)