From ea18f2eeb6bd609be321d997a3c21ded52801fa7 Mon Sep 17 00:00:00 2001 From: Helin Wang Date: Fri, 19 May 2017 15:15:46 -0400 Subject: [PATCH] make test more precise --- paddle/go/pserver/service_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/paddle/go/pserver/service_test.go b/paddle/go/pserver/service_test.go index 23b2d17dc..6aa7f47c7 100644 --- a/paddle/go/pserver/service_test.go +++ b/paddle/go/pserver/service_test.go @@ -110,6 +110,7 @@ func TestMultipleInit(t *testing.T) { func TestBlockUntilInitialized(t *testing.T) { s := pserver.NewService() + ch := make(chan struct{}, 3) var wg sync.WaitGroup wg.Add(1) go func() { @@ -119,6 +120,7 @@ func TestBlockUntilInitialized(t *testing.T) { t.FailNow() } wg.Done() + ch <- struct{}{} }() wg.Add(1) @@ -129,6 +131,7 @@ func TestBlockUntilInitialized(t *testing.T) { t.FailNow() } wg.Done() + ch <- struct{}{} }() wg.Add(1) @@ -139,6 +142,7 @@ func TestBlockUntilInitialized(t *testing.T) { t.FailNow() } wg.Done() + ch <- struct{}{} }() var dummy int @@ -147,6 +151,13 @@ func TestBlockUntilInitialized(t *testing.T) { t.FailNow() } + select { + case <-ch: + // some function returned before initialization is completed. + t.FailNow() + default: + } + err = s.FinishInitParams(0, &dummy) if err != nil { t.FailNow() -- GitLab