Golang模糊测试:语料库条目中的类型不匹配

huangapple go评论76阅读模式
英文:

Golang Fuzzing: Mismatched types in corpus entry

问题

在使用Go 1.18引入的本地模糊测试功能时,我在重构我的测试后遇到了以下错误:

--- FAIL: FuzzTrie_InsertAndRead (0.03s)
    trie_test.go:340: "testdata/fuzz/FuzzTrie_InsertAndRead/84ed65595ad05a58e293dbf423c1a816b697e2763a29d7c37aa476d6eef6fd60":
    corpus entry中的类型不匹配: [[]uint8 []uint8],期望是[uint64 []uint8]

我猜测这是由于我将测试参数从byte切片更改为uint64byte切片导致的,但是我该如何摆脱这个corpus数据?它位于哪里?

英文:

When using the native fuzzing feature introduced in Go 1.18, after refactoring my tests, I now encounter the following error:

--- FAIL: FuzzTrie_InsertAndRead (0.03s)
    trie_test.go:340: "testdata/fuzz/FuzzTrie_InsertAndRead/84ed65595ad05a58e293dbf423c1a816b697e2763a29d7c37aa476d6eef6fd60":
    mismatched types in corpus entry: [[]uint8 []uint8], want [uint64 []uint8]

I assume this is due to the change of my test parameters from byte slices to a uint64 and a byte slice, but how can I get rid of this corpus data? Where is it located?

答案1

得分: 2

使用原生的Go模糊测试运行测试时,生成的测试数据将存储在相对于正在运行的测试的以下路径中:testdata/fuzz/<FuzzTestName>

如果模糊测试的名称发生更改,则先前的测试数据将不再使用。而如果使用的类型发生更改,则包含的语料库数据将不再是相关类型,并且可以通过完全删除文件夹来丢弃它。

英文:

When running tests using native Go fuzzing, test data is generated and stored in the following path, relative to the tests that are being run: testdata/fuzz/&lt;FuzzTestName&gt;.

If a fuzz test changes name, the previous test data is therefore effectively unused, while if the types it uses are changed, the corpus data it contains is no longer of the relevant type, and can be discarded by removing the folder entirely.

huangapple
  • 本文由 发表于 2021年12月27日 20:22:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/70495459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定