]> Cypherpunks repositories - gostls13.git/commitdiff
mime/multipart: add Writer data race test
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 5 Aug 2014 18:45:24 +0000 (11:45 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 5 Aug 2014 18:45:24 +0000 (11:45 -0700)
Camlistore uses this pattern to do streaming writes, as do
others I imagine, and it was broken by the lazy boundary
change.

LGTM=dvyukov, ruiu
R=ruiu, dvyukov
CC=golang-codereviews, mathieu.lonjaret
https://golang.org/cl/116690043

src/pkg/mime/multipart/writer_test.go

index 52d68bcb68c580415affd3d59c1906d80330985a..2412985b9bb371c8834fd856ade0cd4731581582 100644 (file)
@@ -111,3 +111,15 @@ func TestWriterSetBoundary(t *testing.T) {
                t.Errorf("expected my-separator in output. got: %q", got)
        }
 }
+
+func TestWriterBoundaryGoroutines(t *testing.T) {
+       // Verify there's no data race accessing any lazy boundary if it's used by
+       // different goroutines. This was previously broken by
+       // https://codereview.appspot.com/95760043/ and reverted in
+       // https://codereview.appspot.com/117600043/
+       w := NewWriter(ioutil.Discard)
+       go func() {
+               w.CreateFormField("foo")
+       }()
+       w.Boundary()
+}