From 9a9119af9d97d24ebbaf80c2b52fd3a8a531cf98 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 23 Feb 2016 10:57:48 -0500 Subject: [PATCH] fix flaky test TestErrorHandler Before this change, this test would fail after about 50 runs. After this change, I was able to run it 200 times without failure. --- cmux_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmux_test.go b/cmux_test.go index cada54e..3f0588d 100644 --- a/cmux_test.go +++ b/cmux_test.go @@ -227,12 +227,11 @@ func TestErrorHandler(t *testing.T) { defer cleanup() var num int - if err := c.Call("TestRPCRcvr.Test", rpcVal, &num); err == nil { - // The connection is simply closed. - t.Errorf("unexpected rpc success after %d errors", atomic.LoadUint32(&errCount)) - } - if atomic.LoadUint32(&errCount) == 0 { - t.Errorf("expected at least 1 error(s), got none") + for atomic.LoadUint32(&errCount) == 0 { + if err := c.Call("TestRPCRcvr.Test", rpcVal, &num); err == nil { + // The connection is simply closed. + t.Errorf("unexpected rpc success after %d errors", atomic.LoadUint32(&errCount)) + } } }