aboutsummaryrefslogtreecommitdiff
path: root/src/internal/fuzz/encoding_test.go
AgeCommit message (Collapse)Author
2026-03-30all: fix some minor issues in the commentscuishuang
Change-Id: If6c304efac7a46a9718cdc63ded3d98a26a3a831 Reviewed-on: https://go-review.googlesource.com/c/go/+/760700 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Neal Patel <nealpatel@google.com> Reviewed-by: Fred Sauer <fredsa@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2025-10-17all: remove unnecessary loop variable copies in testsTobias Klauser
Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07internal/fuzz: remove useless codeguoguangwu
Change-Id: I4534a116ef421379b2356bbe80760adae8cdd95f GitHub-Last-Rev: a3fab3f1fa84111f3f3af7cf9f98e964f2423c73 GitHub-Pull-Request: golang/go#65892 Reviewed-on: https://go-review.googlesource.com/c/go/+/566315 Run-TryBot: Tim King <taking@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-05-20internal/fuzz: trim carriage return from version lineDan Kortschak
On windows hosts, when code is checked out using git with the default setting of autocrlf=true, carriage returns are appended to source lines which then prevent the version check from being successful. This removes carriage returns to allow version matching. Fixes #52268 Change-Id: I9acc4e907c93a20305f8742cc01687a122a88645 Reviewed-on: https://go-review.googlesource.com/c/go/+/402074 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dan Kortschak <dan@kortschak.io> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-03-08internal/fuzz: fix encoding for out-of-range ints and runesBryan C. Mills
Also switch float64 NaN encoding to use hexadecimal, and accept hexadecimal encoding for all other integer types too. (That gives us the flexibility to change the encodings in either direction in the future without breaking earlier Go versions.) Out-of-range runes encoded using "%q" were previously replaced with the Unicode replacement charecter, losing their values. Out-of-range ints and uints on 32-bit platforms were previously rejected. Now they are wrapped instead: an “interesting” case with a large int or uint found on a 64-bit platform likely remains interesting on a 32-bit platform, even if the specific values differ. To verify the above changes, I have made TestMarshalUnmarshal accept (and check for) arbitrary differences between input and output, and added tests cases that include values in valid but non-canonical encodings. I have also added round-trip fuzz tests in the opposite direction for most of the types affected by this change, verifying that a marshaled value unmarshals to the same bitwise value. Updates #51258 Updates #51526 Fixes #51528 Change-Id: I7727a9d0582d81be0d954529545678a4374e88ed Reviewed-on: https://go-review.googlesource.com/c/go/+/390424 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-07internal/fuzz: fix TestUnmarshalMarshal on MIPSRoland Shoemaker
Previous value used in the float32 roundtrip used float32(math.NaN())-1 which caused the quiet/signal bit to flip, which seemed to break the test on MIPS platforms. Instead switch to using float32(math.NaN())+1, which preserves the bit and makes the test happy. Possibly related to #37455 Fixes #51258 Change-Id: Ia85c649e89a5d02027c0ec197f0ff318aa819c19 Reviewed-on: https://go-review.googlesource.com/c/go/+/390214 Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-04internal/fuzz: handle Inf/NaN float valuesRoland Shoemaker
Fixes #51258 Change-Id: I3c8b785ac912d66e1a6e2179625e6903032b8330 Reviewed-on: https://go-review.googlesource.com/c/go/+/388354 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-09-10[dev.fuzz] internal/fuzz: write a newline to the end of a corpus fileKatie Hockman
If someone manually adds/alters a corpus file to add extra spacing or remove the final newline, the file can still be decoded. However, this change ensures that the fuzzing engine correctly writes the final newline. Fixes golang/go#48130 Change-Id: Ib5556d4a6e4e0bfd9bc2edab357b7c25bedfd176 Reviewed-on: https://go-review.googlesource.com/c/go/+/349055 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-07-19[dev.fuzz] internal/fuzz: add more benchmarks for workersJay Conrod
* Benchmark{Marshal,Unmarshal}CorpusFile - measures time it takes to serialize and deserialize byte slices of various lengths. * BenchmarkWorkerPing - spins up a worker and measures time it takes to ping it N times as a rough measure of RPC latency. * BenchmarkWorkerFuzz - spins up a worker and measures time it takes to mutate an input and call a trivial fuzz function N times. Also a few small fixes to make this easier. Change-Id: Id7f2dc6c6c05005cf286f30e6cc92a54bf44fbf7 Reviewed-on: https://go-review.googlesource.com/c/go/+/333670 Trust: Jay Conrod <jayconrod@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2021-04-12[dev.fuzz] internal/fuzz: allow float types to be integer literalsKatie Hockman
Previously, something like `float64(0)` would fail to decode since the 0 value is considered an integer literal, and the float64 parsing code required a float literal. Be more flexible here since an integer can always be converted to a float. Change-Id: Id1c53ef2e8a9748a4f71176b00b453a329af4ade Reviewed-on: https://go-review.googlesource.com/c/go/+/309032 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-22[dev.fuzz] internal/fuzz: updating version incodingKatie Hockman
Based on feedback from rsc@, update the version encoding to more clearly indicate that this is about fuzzing with Go. Change-Id: Id95dec8283608779b157bf662e7147f9a9c8dba8 Reviewed-on: https://go-review.googlesource.com/c/go/+/295110 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-17[dev.fuzz] internal/fuzz: support corpus file encoding/decodingKatie Hockman
Change-Id: Id245ce5f154557f1744210e7d7f061d08901c746 Reviewed-on: https://go-review.googlesource.com/c/go/+/290951 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>