Blame SOURCES/remove_waitgroup_misuse_tests.patch

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