summaryrefslogtreecommitdiff
path: root/libgo/go/sync/cond_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/sync/cond_test.go')
-rw-r--r--libgo/go/sync/cond_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/libgo/go/sync/cond_test.go b/libgo/go/sync/cond_test.go
index 846f98bf39d..cefacb184e1 100644
--- a/libgo/go/sync/cond_test.go
+++ b/libgo/go/sync/cond_test.go
@@ -46,6 +46,33 @@ func TestCondSignal(t *testing.T) {
c.Signal()
}
+func TestCondSignalGenerations(t *testing.T) {
+ var m Mutex
+ c := NewCond(&m)
+ n := 100
+ running := make(chan bool, n)
+ awake := make(chan int, n)
+ for i := 0; i < n; i++ {
+ go func(i int) {
+ m.Lock()
+ running <- true
+ c.Wait()
+ awake <- i
+ m.Unlock()
+ }(i)
+ if i > 0 {
+ a := <-awake
+ if a != i-1 {
+ t.Fatalf("wrong goroutine woke up: want %d, got %d", i-1, a)
+ }
+ }
+ <-running
+ m.Lock()
+ c.Signal()
+ m.Unlock()
+ }
+}
+
func TestCondBroadcast(t *testing.T) {
var m Mutex
c := NewCond(&m)