Fix GC test failures (#17766)
authorSung Yoon Whang <suwhang@microsoft.com>
Thu, 26 Apr 2018 21:02:59 +0000 (14:02 -0700)
committerEugene Rozenfeld <erozen@microsoft.com>
Thu, 26 Apr 2018 21:02:59 +0000 (14:02 -0700)
* Fix finalizearraysleep and handlecopy gc tests

* revert changes to nstructtun

* forgot to add this fix in

* fix handlecopy

* fix nstructtun

* fix nstructtun

tests/src/GC/API/GCHandle/HandleCopy.cs
tests/src/GC/Features/Finalizer/finalizeother/finalizearraysleep.cs
tests/src/GC/Scenarios/FinalNStruct/nstructtun.cs

index 250ee9c..955f688 100644 (file)
@@ -46,6 +46,7 @@ public class Test
 
         public bool RunTest()
         {
+            DestroyObj();
             GC.Collect();
             GC.WaitForPendingFinalizers();
             GC.Collect();
index 0d35ecd..80a8ed2 100644 (file)
@@ -47,9 +47,14 @@ public class Test {
         GC.Collect();
 
         if (Dummy.count == 10)
+        {
             Console.WriteLine("Test for Finalize() for array of objects passed!");
+            return 100;
+        }
         else 
+        {
             Console.WriteLine("Test for Finalize() for array of objects failed!");
-        return temp.ExitCode;                          
+            return 0;
+        }
     }
 }
index 48885fe..543a022 100644 (file)
@@ -2,7 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-namespace NStruct {
+namespace NStruct
+{
     using System;
     using System.Runtime.CompilerServices;
 
@@ -11,60 +12,60 @@ namespace NStruct {
 
         public class CreateObj
         {
-// disabling unused variable warning
+            // disabling unused variable warning
 #pragma warning disable 0414
             private STRMAP Strmap;
 #pragma warning restore 0414
-
             public CreateObj(int Rep)
             {
-                 for( int i=0; i< Rep; i++ )
-                 {
+                for (int i = 0; i < Rep; i++)
+                {
                     Strmap = new STRMAP();
-                 }
+                }
             }
-         
+
             [MethodImplAttribute(MethodImplOptions.NoInlining)]
-            public void DeleteStrmap()
+            public void DestoryStrmap()
             {
-                Strmap=null;
-            }
+                Strmap = null;
+            }                       
 
             public bool RunTest()
             {
+                DestoryStrmap();
                 GC.Collect();
                 GC.WaitForPendingFinalizers();
                 GC.Collect();
 
-                Console.Out.WriteLine(FinalizeCount.icCreat + " NStruct Objects were deleted and "+ FinalizeCount.icFinal +" finalized.");
+                Console.Out.WriteLine(FinalizeCount.icCreat + " NStruct Objects were deleted and " + FinalizeCount.icFinal + " finalized.");
 
-                return (FinalizeCount.icCreat == FinalizeCount.icFinal );
+                return (FinalizeCount.icCreat == FinalizeCount.icFinal);
             }
 
         }
 
-        public static int Main(String [] Args)
+        public static int Main(String[] Args)
         {
             int iRep = 0;
 
             Console.Out.WriteLine("Test should return with ExitCode 100 ...");
 
-            ifArgs.Length == 1)
+            if (Args.Length == 1)
             {
-                if (!Int32.TryParse( Args[0], out iRep ))
+                if (!Int32.TryParse(Args[0], out iRep))
                 {
-                    iRep =10000;
+                    iRep = 10000;
                 }
             }
             else
             {
-                iRep =10000;
+                iRep = 10000;
             }
-            Console.Out.WriteLine("iRep = "+iRep );
+            Console.Out.WriteLine("iRep = " + iRep);
 
             CreateObj temp = new CreateObj(iRep);
 
-            if(temp.RunTest())
+            if (temp.RunTest())
             {
                 Console.WriteLine("Test Passed");
                 return 100;