From: Bruce Forstall Date: Fri, 12 Jan 2018 00:22:55 +0000 (-0800) Subject: Fix GC.KeepAlive test case X-Git-Tag: accepted/tizen/base/20180629.140029~158^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d087b29b9f68db08e6606a50d8ce2e80fe156dbf;p=platform%2Fupstream%2Fcoreclr.git Fix GC.KeepAlive test case In the test, as written, a GC could sneak in between the GC.KeepAlive() call and the subsequent line that checks whether the finalizer has run, especially in GC stress modes. Simply move the GC.KeepAlive() call down. --- diff --git a/tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs b/tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs index ed90465..c8aa542 100644 --- a/tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs +++ b/tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs @@ -44,13 +44,13 @@ public class GCKeepAlive GC.WaitForPendingFinalizers(); GC.Collect(); - GC.KeepAlive(tc); if (TestClass.m_TestInt != 1) { TestLibrary.TestFramework.LogError("001.1", "Calling KeepAlive can not prevent an object to be GCed"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] TestClass.m_TestInt = " + TestClass.m_TestInt); retVal = false; } + GC.KeepAlive(tc); } catch (Exception e) {