From d087b29b9f68db08e6606a50d8ce2e80fe156dbf Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Thu, 11 Jan 2018 16:22:55 -0800 Subject: [PATCH] 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. --- tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { -- 2.7.4