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

make test more precise

上级 44d60bd9
...@@ -110,6 +110,7 @@ func TestMultipleInit(t *testing.T) { ...@@ -110,6 +110,7 @@ func TestMultipleInit(t *testing.T) {
func TestBlockUntilInitialized(t *testing.T) { func TestBlockUntilInitialized(t *testing.T) {
s := pserver.NewService() s := pserver.NewService()
ch := make(chan struct{}, 3)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
...@@ -119,6 +120,7 @@ func TestBlockUntilInitialized(t *testing.T) { ...@@ -119,6 +120,7 @@ func TestBlockUntilInitialized(t *testing.T) {
t.FailNow() t.FailNow()
} }
wg.Done() wg.Done()
ch <- struct{}{}
}() }()
wg.Add(1) wg.Add(1)
...@@ -129,6 +131,7 @@ func TestBlockUntilInitialized(t *testing.T) { ...@@ -129,6 +131,7 @@ func TestBlockUntilInitialized(t *testing.T) {
t.FailNow() t.FailNow()
} }
wg.Done() wg.Done()
ch <- struct{}{}
}() }()
wg.Add(1) wg.Add(1)
...@@ -139,6 +142,7 @@ func TestBlockUntilInitialized(t *testing.T) { ...@@ -139,6 +142,7 @@ func TestBlockUntilInitialized(t *testing.T) {
t.FailNow() t.FailNow()
} }
wg.Done() wg.Done()
ch <- struct{}{}
}() }()
var dummy int var dummy int
...@@ -147,6 +151,13 @@ func TestBlockUntilInitialized(t *testing.T) { ...@@ -147,6 +151,13 @@ func TestBlockUntilInitialized(t *testing.T) {
t.FailNow() t.FailNow()
} }
select {
case <-ch:
// some function returned before initialization is completed.
t.FailNow()
default:
}
err = s.FinishInitParams(0, &dummy) err = s.FinishInitParams(0, &dummy)
if err != nil { if err != nil {
t.FailNow() t.FailNow()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册