Skip to content

proposal: testing: add (*testing.F).AddNamed() for naming seed corpus entries #70070

@mateusz834

Description

@mateusz834

Proposal Details

Currently the corpus entries ("sub-tests") added by (*testing.F).Add() are named like: FuzzMyFuzz/seed#0. In my case i am populating the fuzz corpus with file contents from the testdata directory, because of the default naming there is no easy way to quickly map seed corpus to a file (for -run, to run only one test from the corpus), to do so i need to t.Log the file contents in the f.Fuzz and figure out which file contains that data, this is annoying, especially that while adding a corpus entry the file name is known.

I propose to add following function to the testing package to solve this issue:

// AddNamed will add the arguments to the seed corpus for the fuzz test with a specified name.
// This will be a no-op if called after or within the fuzz target, and args must match the
// arguments for the fuzz target.
func (f *F) AddNamed(name string, args ...any)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions