Blame SOURCES/remove_waitgroup_misuse_tests.patch

216b28
diff --git a/src/sync/waitgroup_test.go b/src/sync/waitgroup_test.go
216b28
index c569e0faa2eb..4ded218d2d8d 100644
216b28
--- a/src/sync/waitgroup_test.go
216b28
+++ b/src/sync/waitgroup_test.go
216b28
@@ -5,8 +5,6 @@
216b28
 package sync_test
216b28
 
216b28
 import (
216b28
-	"internal/race"
216b28
-	"runtime"
216b28
 	. "sync"
216b28
 	"sync/atomic"
216b28
 	"testing"
216b28
@@ -48,12 +46,6 @@ func TestWaitGroup(t *testing.T) {
216b28
 	}
216b28
 }
216b28
 
216b28
-func knownRacy(t *testing.T) {
216b28
-	if race.Enabled {
216b28
-		t.Skip("skipping known-racy test under the race detector")
216b28
-	}
216b28
-}
216b28
-
216b28
 func TestWaitGroupMisuse(t *testing.T) {
216b28
 	defer func() {
216b28
 		err := recover()
216b28
@@ -68,124 +60,6 @@ func TestWaitGroupMisuse(t *testing.T) {
216b28
 	t.Fatal("Should panic")
216b28
 }
216b28
 
216b28
-// pollUntilEqual blocks until v, loaded atomically, is
216b28
-// equal to the target.
216b28
-func pollUntilEqual(v *uint32, target uint32) {
216b28
-	for {
216b28
-		for i := 0; i < 1e3; i++ {
216b28
-			if atomic.LoadUint32(v) == target {
216b28
-				return
216b28
-			}
216b28
-		}
216b28
-		// yield to avoid deadlock with the garbage collector
216b28
-		// see issue #20072
216b28
-		runtime.Gosched()
216b28
-	}
216b28
-}
216b28
-
216b28
-func TestWaitGroupMisuse2(t *testing.T) {
216b28
-	knownRacy(t)
216b28
-	if runtime.NumCPU() <= 4 {
216b28
-		t.Skip("NumCPU<=4, skipping: this test requires parallelism")
216b28
-	}
216b28
-	defer func() {
216b28
-		err := recover()
216b28
-		if err != "sync: negative WaitGroup counter" &&
216b28
-			err != "sync: WaitGroup misuse: Add called concurrently with Wait" &&
216b28
-			err != "sync: WaitGroup is reused before previous Wait has returned" {
216b28
-			t.Fatalf("Unexpected panic: %#v", err)
216b28
-		}
216b28
-	}()
216b28
-	defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
216b28
-	done := make(chan interface{}, 2)
216b28
-	// The detection is opportunistic, so we want it to panic
216b28
-	// at least in one run out of a million.
216b28
-	for i := 0; i < 1e6; i++ {
216b28
-		var wg WaitGroup
216b28
-		var here uint32
216b28
-		wg.Add(1)
216b28
-		go func() {
216b28
-			defer func() {
216b28
-				done <- recover()
216b28
-			}()
216b28
-			atomic.AddUint32(&here, 1)
216b28
-			pollUntilEqual(&here, 3)
216b28
-			wg.Wait()
216b28
-		}()
216b28
-		go func() {
216b28
-			defer func() {
216b28
-				done <- recover()
216b28
-			}()
216b28
-			atomic.AddUint32(&here, 1)
216b28
-			pollUntilEqual(&here, 3)
216b28
-			wg.Add(1) // This is the bad guy.
216b28
-			wg.Done()
216b28
-		}()
216b28
-		atomic.AddUint32(&here, 1)
216b28
-		pollUntilEqual(&here, 3)
216b28
-		wg.Done()
216b28
-		for j := 0; j < 2; j++ {
216b28
-			if err := <-done; err != nil {
216b28
-				panic(err)
216b28
-			}
216b28
-		}
216b28
-	}
216b28
-	t.Fatal("Should panic")
216b28
-}
216b28
-
216b28
-func TestWaitGroupMisuse3(t *testing.T) {
216b28
-	knownRacy(t)
216b28
-	if runtime.NumCPU() <= 1 {
216b28
-		t.Skip("NumCPU==1, skipping: this test requires parallelism")
216b28
-	}
216b28
-	defer func() {
216b28
-		err := recover()
216b28
-		if err != "sync: negative WaitGroup counter" &&
216b28
-			err != "sync: WaitGroup misuse: Add called concurrently with Wait" &&
216b28
-			err != "sync: WaitGroup is reused before previous Wait has returned" {
216b28
-			t.Fatalf("Unexpected panic: %#v", err)
216b28
-		}
216b28
-	}()
216b28
-	defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
216b28
-	done := make(chan interface{}, 3)
216b28
-	// The detection is opportunistically, so we want it to panic
216b28
-	// at least in one run out of a million.
216b28
-	for i := 0; i < 1e6; i++ {
216b28
-		var wg WaitGroup
216b28
-		wg.Add(1)
216b28
-		go func() {
216b28
-			defer func() {
216b28
-				done <- recover()
216b28
-			}()
216b28
-			wg.Done()
216b28
-		}()
216b28
-		go func() {
216b28
-			defer func() {
216b28
-				done <- recover()
216b28
-			}()
216b28
-			wg.Wait()
216b28
-			// Start reusing the wg before waiting for the Wait below to return.
216b28
-			wg.Add(1)
216b28
-			go func() {
216b28
-				wg.Done()
216b28
-			}()
216b28
-			wg.Wait()
216b28
-		}()
216b28
-		go func() {
216b28
-			defer func() {
216b28
-				done <- recover()
216b28
-			}()
216b28
-			wg.Wait()
216b28
-		}()
216b28
-		for j := 0; j < 3; j++ {
216b28
-			if err := <-done; err != nil {
216b28
-				panic(err)
216b28
-			}
216b28
-		}
216b28
-	}
216b28
-	t.Fatal("Should panic")
216b28
-}
216b28
-
216b28
 func TestWaitGroupRace(t *testing.T) {
216b28
 	// Run this test for about 1ms.
216b28
 	for i := 0; i < 1000; i++ {