summaryrefslogtreecommitdiff
path: root/src/pkg/sync/waitgroup_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/sync/waitgroup_test.go')
-rw-r--r--src/pkg/sync/waitgroup_test.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/pkg/sync/waitgroup_test.go b/src/pkg/sync/waitgroup_test.go
deleted file mode 100644
index fe35732e7..000000000
--- a/src/pkg/sync/waitgroup_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package sync_test
-
-import (
- . "sync"
- "testing"
-)
-
-func testWaitGroup(t *testing.T, wg1 *WaitGroup, wg2 *WaitGroup) {
- n := 16
- wg1.Add(n)
- wg2.Add(n)
- exited := make(chan bool, n)
- for i := 0; i != n; i++ {
- go func(i int) {
- wg1.Done()
- wg2.Wait()
- exited <- true
- }(i)
- }
- wg1.Wait()
- for i := 0; i != n; i++ {
- select {
- case <-exited:
- t.Fatal("WaitGroup released group too soon")
- default:
- }
- wg2.Done()
- }
- for i := 0; i != n; i++ {
- <-exited // Will block if barrier fails to unlock someone.
- }
-}
-
-func TestWaitGroup(t *testing.T) {
- wg1 := &WaitGroup{}
- wg2 := &WaitGroup{}
-
- // Run the same test a few times to ensure barrier is in a proper state.
- for i := 0; i != 8; i++ {
- testWaitGroup(t, wg1, wg2)
- }
-}
-
-func TestWaitGroupMisuse(t *testing.T) {
- defer func() {
- err := recover()
- if err != "sync: negative WaitGroup count" {
- t.Fatalf("Unexpected panic: %#v", err)
- }
- }()
- wg := &WaitGroup{}
- wg.Add(1)
- wg.Done()
- wg.Done()
- t.Fatal("Should panic")
-}