[sgen] Add oom testing suite
[mono.git] / mono / mini / TestHelpers.cs
index 01ed13532a10f65d0289c64e66cee1b94d5214da..26f8d1276d5988c753e34f8afb3da0f7e03cc142 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Threading;
+using System.Reflection;
 
 namespace MonoTests.Helpers {
 
@@ -25,5 +26,25 @@ namespace MonoTests.Helpers {
                        thr.Join ();
                }
        }
+
+       public static class OOMHelpers {
+               public static void RunTest (string test)
+               {
+                       Assembly asm = Assembly.Load (test);
+
+                       try {
+                               // Support both (void) and (string[]) signatures
+                               if (asm.EntryPoint.GetParameters ().Length == 1)
+                                       asm.EntryPoint.Invoke (null, new string[] { null });
+                               else
+                                       asm.EntryPoint.Invoke (null, null);
+                       } catch (TargetInvocationException e) {
+                               if (e.InnerException is OutOfMemoryException)
+                                       Console.WriteLine ("Catched oom");
+                               else
+                                       throw;
+                       }
+               }
+       }
 }