diff options
author | Sergey Andreenko <seandree@microsoft.com> | 2018-04-17 23:25:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 23:25:44 -0700 |
commit | 1656af67eeda33d750975a57e129de2be73c37a3 (patch) | |
tree | 8398bfd3bc209404e16e8af4c209ab2c01a2a2ca | |
parent | 8e7aa00273cec8ddcf73a675f82c80a82e4c7ed8 (diff) | |
download | coreclr-1656af67eeda33d750975a57e129de2be73c37a3.tar.gz coreclr-1656af67eeda33d750975a57e129de2be73c37a3.tar.bz2 coreclr-1656af67eeda33d750975a57e129de2be73c37a3.zip |
Fix GC tests. (#17594) (#17613)
* Fix dlbigleak
* cleanup dlstack
* Fix doublinknoleak
* Fix doublinkstay
* Fix dlcollect
* Fix doublinkgen
* Fix dlbigleakthd
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlbigleak.cs | 24 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlbigleakthd.cs | 28 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlcollect.cs | 23 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlstack.cs | 6 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs | 16 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/doublinknoleak.cs | 24 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/doublinkstay.cs | 23 |
7 files changed, 102 insertions, 42 deletions
diff --git a/tests/src/GC/Scenarios/DoublinkList/dlbigleak.cs b/tests/src/GC/Scenarios/DoublinkList/dlbigleak.cs index c72c8c089c..eee0b74118 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlbigleak.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlbigleak.cs @@ -12,6 +12,7 @@ namespace DoubLink { using System; + using System.Runtime.CompilerServices; public class DLBigLeak { @@ -65,13 +66,7 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { - Mv_Doub = new DoubLink[iRep]; - for(int i=0; i<10; i++) - { - SetLink(iRep, iObj); - MakeLeak(iRep); - GC.Collect(); - } + CreateDLinkListsWithLeak(iRep, iObj, 10); GC.Collect(); GC.WaitForPendingFinalizers(); @@ -85,6 +80,21 @@ namespace DoubLink { } + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) + { + Mv_Doub = new DoubLink[iRep]; + for (int i = 0; i < iters; i++) + { + SetLink(iRep, iObj); + MakeLeak(iRep); + GC.Collect(); + } + } + + public void SetLink(int iRep, int iObj) { diff --git a/tests/src/GC/Scenarios/DoublinkList/dlbigleakthd.cs b/tests/src/GC/Scenarios/DoublinkList/dlbigleakthd.cs index f1a322a2bf..e38351b77c 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlbigleakthd.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlbigleakthd.cs @@ -13,6 +13,7 @@ namespace DoubLink { using System.Threading; using System; using System.IO; + using System.Runtime.CompilerServices; public class DLBigLeakThd { @@ -85,6 +86,23 @@ namespace DoubLink { public bool runTest(int iRep, int iObj, int iThd) { + CreateDLinkListsWithLeak(iRep, iObj, iThd, 20); + + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + int goal = iRep*15*iThd*iObj+20*iRep*iObj; + Console.WriteLine("{0}/{1} DLinkNodes finalized", DLinkNode.FinalCount, goal); + return (DLinkNode.FinalCount==goal); + } + + + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iThd, int iters) + { this.iRep = iRep; this.iObj = iObj; Mv_Doub = new DoubLink[iRep]; @@ -94,7 +112,7 @@ namespace DoubLink { Mv_Thread[i] = new Thread(new ThreadStart(this.ThreadStart)); Mv_Thread[i].Start( ); } - for(int i=0; i<20; i++) + for (int i = 0; i < iters; i++) { SetLink(iRep, iObj); MakeLeak(iRep); @@ -103,15 +121,7 @@ namespace DoubLink { { Mv_Thread[i].Join(); } - Mv_Doub = null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - int goal = iRep*15*iThd*iObj+20*iRep*iObj; - Console.WriteLine("{0}/{1} DLinkNodes finalized", DLinkNode.FinalCount, goal); - return (DLinkNode.FinalCount==goal); } diff --git a/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs b/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs index f7aa10dccb..98d803e1c8 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs @@ -93,15 +93,9 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { + CreateDLinkListsWithLeak(iRep, iObj, 10); - Mv_Collect = new List<DoubLink>(iRep); bool success = false; - for(int i=0; i <10; i++) - { - SetLink(iRep, iObj); - Mv_Collect.RemoveRange(0, Mv_Collect.Count); - GC.Collect(); - } if (DrainFinalizerQueue(iRep, iObj)) { @@ -113,6 +107,21 @@ namespace DoubLink { } + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) + { + Mv_Collect = new List<DoubLink>(iRep); + for(int i = 0; i < iters; i++) + { + SetLink(iRep, iObj); + Mv_Collect.RemoveRange(0, Mv_Collect.Count); + GC.Collect(); + } + } + + public void SetLink(int iRep, int iObj) { Mv_Doub = new DoubLink[iRep]; diff --git a/tests/src/GC/Scenarios/DoublinkList/dlstack.cs b/tests/src/GC/Scenarios/DoublinkList/dlstack.cs index 585c6a2670..c5c31eb9ce 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlstack.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlstack.cs @@ -94,7 +94,7 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { - CreateDLinkListsWithLeak(iRep, iObj); + CreateDLinkListsWithLeak(iRep, iObj, 10); bool success = false; if (DrainFinalizerQueue(iRep, iObj)) @@ -111,9 +111,9 @@ namespace DoubLink { [MethodImpl(MethodImplOptions.NoInlining)] // Do not inline the method that creates GC objects, because it could // extend their live intervals until the end of the parent method. - public void CreateDLinkListsWithLeak(int iRep, int iObj) + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) { - for(int i=0; i <10; i++) + for(int i = 0; i < iters; i++) { SetLink(iRep, iObj); MakeLeak(iRep); diff --git a/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs b/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs index 0f1016c3d0..0962cb39a2 100644 --- a/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs +++ b/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs @@ -91,8 +91,8 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { - SetLink(iRep, iObj); - Mv_Doub = null; + CreateDLinkListsWithLeak(iRep, iObj); + bool success = false; if (DrainFinalizerQueue(iRep, iObj)) @@ -107,6 +107,18 @@ namespace DoubLink { } + + + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj) + { + SetLink(iRep, iObj); + Mv_Doub = null; + } + + public void SetLink(int iRep, int iObj) { for(int i=0; i<iRep; i++) diff --git a/tests/src/GC/Scenarios/DoublinkList/doublinknoleak.cs b/tests/src/GC/Scenarios/DoublinkList/doublinknoleak.cs index 1910b0667f..1b7f63adbf 100644 --- a/tests/src/GC/Scenarios/DoublinkList/doublinknoleak.cs +++ b/tests/src/GC/Scenarios/DoublinkList/doublinknoleak.cs @@ -11,6 +11,7 @@ namespace DoubLink { using System; using System.Collections.Generic; + using System.Runtime.CompilerServices; public class DoubLinkNoLeak { @@ -62,13 +63,7 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { - for(int i=0; i<10; i++) - { - SetLink(iRep, iObj); - } - - Mv_Doub = null; - Mv_Save = null; + CreateDLinkListsWithLeak(iRep, iObj, 10); GC.Collect(); GC.WaitForPendingFinalizers(); @@ -80,6 +75,21 @@ namespace DoubLink { } + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) + { + for(int i = 0; i < iters; i++) + { + SetLink(iRep, iObj); + } + + Mv_Doub = null; + Mv_Save = null; + } + + public void SetLink(int iRep, int iObj) { Mv_Doub = new DoubLink[iRep]; diff --git a/tests/src/GC/Scenarios/DoublinkList/doublinkstay.cs b/tests/src/GC/Scenarios/DoublinkList/doublinkstay.cs index ab0ea49b40..7103e0a199 100644 --- a/tests/src/GC/Scenarios/DoublinkList/doublinkstay.cs +++ b/tests/src/GC/Scenarios/DoublinkList/doublinkstay.cs @@ -13,6 +13,7 @@ namespace DoubLink { using System; + using System.Runtime.CompilerServices; public class DoubLinkStay { @@ -63,13 +64,7 @@ namespace DoubLink { public bool runTest(int iRep, int iObj) { - Mv_Doub = new DoubLink[iRep]; - for(int i=0; i<20; i++) - { - SetLink(iRep, iObj); - MakeLeak(iRep); - } - + CreateDLinkListsWithLeak(iRep, iObj, 20); GC.Collect(); GC.WaitForPendingFinalizers(); @@ -83,6 +78,20 @@ namespace DoubLink { } + + [MethodImpl(MethodImplOptions.NoInlining)] + // Do not inline the method that creates GC objects, because it could + // extend their live intervals until the end of the parent method. + public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) + { + Mv_Doub = new DoubLink[iRep]; + for(int i = 0; i < iters; i++) + { + SetLink(iRep, iObj); + MakeLeak(iRep); + } + } + public void SetLink(int iRep, int iObj) { |