Skip to content

testing: "unknown encoding version" error / provide documentation on the fuzz input file format #49299

@kevinburke

Description

@kevinburke

I'm trying to seed inputs to the fuzzer by adding files to testdata/fuzz, per the documentation.

Here is my test file (for package github.com/kevinburke/ssh_config):

package ssh_config

import (
	"bytes"
	"testing"
)

func FuzzDecode(f *testing.F) {
	f.Fuzz(func(t *testing.T, in []byte) {
		_, err := Decode(bytes.NewReader(in))
		if err != nil {
			t.Fatalf("decode %q: %v", string(in), err)
		}
	})
}

Per the documentation, I tried copying existing files in testdata/config1 and testdata/config2 to testdata/fuzz/Decode. This failed because I should have put them in testdata/fuzz/FuzzDecode but that (repetition of the word "fuzz") wasn't obvious to me from the docs.

I then tried running the fuzzer on Go tip (629ffeb) and got:

--- FAIL: FuzzDecode (0.00s)
    fuzz_test.go:9: "testdata/fuzz/FuzzDecode/config1": unmarshal: unknown encoding version: Host localhost 127.0.0.1 # A comment at the end of a host line.
        "testdata/fuzz/FuzzDecode/config2": unmarshal: unknown encoding version: #	$OpenBSD: ssh_config,v 1.30 2016/02/20 23:06:23 sobrado Exp $

I'm not sure how to resolve that. The docs that I saw (the blog post and in src/testing/testing.go) didn't mention anything about a version format for seed files, and the error message does not explain how to resolve the issue.

I also tried searching Google for information if other people had run into the error, and didn't find any.

Updates #49229.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.fuzzIssues related to native fuzzing support

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions