[tests] Add timeout limits to some longer sgen tests
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 10 Apr 2017 12:50:39 +0000 (15:50 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Wed, 12 Apr 2017 00:51:50 +0000 (03:51 +0300)
mono/tests/sgen-cementing-stress.cs
mono/tests/sgen-domain-unload.cs

index 33c0bfa5bef4326432e2c9598e656956670df4ea..b6c94260d8dc8e96c7ed95de8940faf12c62dae4 100644 (file)
@@ -17,6 +17,8 @@ class PinList
        next = n;
     }
 
+    static int list_size = 0;
+
     static PinList MakeList (int length)
     {
        PinList l = null;
@@ -42,7 +44,7 @@ class PinList
        {
            for (int j = 0; j < 10; ++j)
            {
-               MakeList (1 << 19);
+               MakeList (list_size >> 5);
                AssignReferences (list, objs);
            }
            return null;
@@ -64,10 +66,19 @@ class PinList
 
     public static void Main ()
     {
-       PinList list = MakeList (1 << 24);
-       Console.WriteLine ("long list constructed");
-       Benchmark (list, 10);
-       GC.Collect (1);
-       Benchmark (list, 100);
+       list_size = 1 << 15;
+       TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));
+
+       for (int it1 = 1; it1 <= 10; it1++, list_size <<= 1) {
+               PinList list = MakeList (list_size);
+               Console.WriteLine ("long list constructed {0}", it1);
+               for (int it2 = 0; it2 < 5; it2++) {
+                       Benchmark (list, 10 * it1);
+                       GC.Collect (1);
+
+                       if (!timeout.HaveTimeLeft)
+                               return;
+               }
+       }
     }
 }
index 670f218b3fb9ef73cd58ee1fbe190205d39bc4b2..b2bfc5e153ea43ec73e6064f6f0e5aef032e6ad8 100644 (file)
@@ -45,8 +45,9 @@ class Driver {
        }
 
        static void CrossDomainTest (string name, CrossAppDomainDelegate dele) {
+               TestTimeout timeout = TestTimeout.Start (TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));
                Console.WriteLine ("----Testing {0}----", name);
-               for (int i = 0; i < 20; ++i) {
+               for (int i = 0; timeout.HaveTimeLeft; ++i) {
                        var ad = AppDomain.CreateDomain (string.Format ("domain-{0}-{1}", name, i));
                        ad.DoCallBack (dele);
                        AppDomain.Unload (ad);
@@ -56,4 +57,4 @@ class Driver {
        static void Main () {
                CrossDomainTest ("simple-heap-with-los", Driver.SimpleHeapWithLOS);
        }
-}
\ No newline at end of file
+}