From: Dmitriy Vyukov Date: Tue, 9 Oct 2012 05:55:57 +0000 (+0400) Subject: encoding/gob: add test case for issue 4214. X-Git-Tag: go1.1rc2~2184 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aa97c88ecb8463f9c7675cc812d7e52a381a9913;p=gostls13.git encoding/gob: add test case for issue 4214. See http://code.google.com/p/go/issues/detail?id=4214 R=golang-dev, r CC=golang-dev https://golang.org/cl/6619068 --- diff --git a/src/pkg/encoding/gob/type_test.go b/src/pkg/encoding/gob/type_test.go index e55fba98d5..e230d22d43 100644 --- a/src/pkg/encoding/gob/type_test.go +++ b/src/pkg/encoding/gob/type_test.go @@ -5,6 +5,7 @@ package gob import ( + "bytes" "reflect" "testing" ) @@ -192,3 +193,30 @@ func TestRegistrationNaming(t *testing.T) { } } } + +func TestStressParallel(t *testing.T) { + type T2 struct{ A int } + c := make(chan bool) + const N = 10 + for i := 0; i < N; i++ { + go func() { + p := new(T2) + Register(p) + b := new(bytes.Buffer) + enc := NewEncoder(b) + err := enc.Encode(p) + if err != nil { + t.Error("encoder fail:", err) + } + dec := NewDecoder(b) + err = dec.Decode(p) + if err != nil { + t.Error("decoder fail:", err) + } + c <- true + }() + } + for i := 0; i < N; i++ { + <-c + } +}