提交 ea18f2ee 编写于 作者: H Helin Wang

make test more precise

上级 44d60bd9
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册