import (
"bytes"
"errors"
+ "flag"
"math"
"math/rand"
"reflect"
"unsafe"
)
+var doFuzzTests = flag.Bool("gob.fuzz", false, "run the fuzz tests, which are large and very slow")
+
// Guarantee encoding format by comparing some encodings to hand-written values
type EncodeT struct {
x uint64
// This does some "fuzz testing" by attempting to decode a sequence of random bytes.
func TestFuzz(t *testing.T) {
- if testing.Short() {
+ if !*doFuzzTests {
+ t.Logf("disabled; run with -gob.fuzz to enable")
return
}
}
func TestFuzzRegressions(t *testing.T) {
+ if !*doFuzzTests {
+ t.Logf("disabled; run with -gob.fuzz to enable")
+ return
+ }
+
// An instance triggering a type name of length ~102 GB.
testFuzz(t, 1328492090837718000, 100, new(float32))
// An instance triggering a type name of 1.6 GB.
- // Commented out because it takes 5m to run.
- //testFuzz(t, 1330522872628565000, 100, new(int))
+ // Note: can take several minutes to run.
+ testFuzz(t, 1330522872628565000, 100, new(int))
}
func testFuzz(t *testing.T, seed int64, n int, input ...interface{}) {