Improve tests.
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 12 Nov 2010 19:08:41 +0000 (17:08 -0200)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 12 Nov 2010 19:14:24 +0000 (17:14 -0200)
* gc-oom-handling.cs: Modify this test to test major
fragmentation too.

* gc-oom-handling2.cs: Add tests for some heavy reflection
allocators.

mono/tests/gc-oom-handling.cs
mono/tests/gc-oom-handling2.cs

index dc7c7f95c7679f33d45dd4f6587ba5f68d0f60d2..3d22294f7d0778cbfdaff9f13b0977e951d96a9a 100644 (file)
@@ -4,19 +4,23 @@ using System.Collections.Generic;
 class Driver {
        static int Main () {
                Console.WriteLine ("start");
-               var l = new List<object> ();
+               var l = new object[40000];
                try {
                        for (int i = 0; i < 40000; ++i) {
                                var foo = new byte[2000];
-                               //Console.WriteLine ("done {0}",i);
-                               if (foo == null)
-                                       Console.WriteLine ("WTF");
-                               l.Add (foo);
+                               l[i] = foo;
                        }
                        Console.WriteLine ("done");
-                       return -1;
+                       return 1;
                } catch (Exception e) {
-                       l.Clear ();
+                       /*Create massive fragmentation - hopefully*/
+                       for (int i = 0; i < 40000; i += 2)
+                               l[i] = null;
+                       /*Fist major schedule the given block range for evacuation*/
+                       GC.Collect ();
+                       /*Second major triggers evacuation*/
+                       GC.Collect ();
+                       Array.Clear (l, 0, 40000);
                        l = null;
                        Console.WriteLine ("OOM done");
                }
index 0a38190e820523215f9128101f20b9cba09cfcb3..e048113fb050d0740cd2cea4af611bb1a4a5f8e6 100644 (file)
@@ -1,7 +1,10 @@
 using System;
 using System.Collections.Generic;
+using System.Reflection;
+
 
 class Driver {
+       /*Test that GC handles interning failure correctly*/
        static void DumpStuff () {
                Console.WriteLine ("CWL under OOM - should not print {0}", 99);
                Console.WriteLine ("CWL under OOM - should not print {0}{1}", 22, 44.4);
@@ -9,6 +12,8 @@ class Driver {
 
        static int Main () {
                Console.WriteLine ("start");
+               Assembly corlib = typeof (object).Assembly;
+               Module module = corlib.GetModules ()[0];
                var r = new Random (123456);
                var l = new List<object> ();
                try {
@@ -17,11 +22,23 @@ class Driver {
                                l.Add (foo);
                        }
                        Console.WriteLine ("done");
-                       return -1;
+                       return 1;
                } catch (Exception) {
                        try {
                                DumpStuff ();
+                               return 2;
+                       } catch (Exception) {}
+
+                       try {
+                               module.GetTypes ();
+                               return 3;
+                       } catch (Exception) {}
+
+                       try {
+                               corlib.GetTypes ();
+                               return 4;
                        } catch (Exception) {}
+       
 
                        l.Clear ();
                        l = null;