From 559617d9fa08dae5f9a3f939f58fb1d164f3174d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 19 Jun 2014 20:04:33 +0200 Subject: [PATCH] [corlib] Fixed test that failed intermittently There is a race condition in the test, the #2 Assert() can be reached before e1 is assigned if the thread that handles e1 gets preempted by the scheduler (this is more likely on single-core systems). Adding a sleep before checking the values fixes this for now. Commit licensed under MIT/X11. --- mcs/class/corlib/Test/System/LazyTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mcs/class/corlib/Test/System/LazyTest.cs b/mcs/class/corlib/Test/System/LazyTest.cs index 01885f9767cb..0f24930fe84c 100644 --- a/mcs/class/corlib/Test/System/LazyTest.cs +++ b/mcs/class/corlib/Test/System/LazyTest.cs @@ -306,6 +306,8 @@ public void ConcurrentInitialization () e3 = ex; } + Thread.Sleep (1000); + Assert.AreSame (e1, e2, "#2"); Assert.AreSame (e1, e3, "#3"); }