[tests] Add stress testing and reduce sgen normal testing time (#4653)
[mono.git] / mono / tests / sgen-new-threads-dont-join-stw.cs
index 966fff5d5b7e0b78ed964690f85846fe68e28f05..12750c6608962d495a1dfa9eba08d4caeca0e1b5 100644 (file)
@@ -44,11 +44,9 @@ class T {
     }
 
     static void Main (string[] args) {
-        var testTimeout = new TestTimeout ();
-        testTimeout.Start ();
+        int iterations = 0;
 
-        const int TOTAL_ITERATIONS = 2;
-        for (int j = 0; j < TOTAL_ITERATIONS; j++)
+        for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 1)); timeout.HaveTimeLeft;)
         {
             count = 0;
 
@@ -96,13 +94,9 @@ class T {
             }
 
             Console.WriteLine ();
-            if (!testTimeout.HaveTimeLeft ()) {
-                    var finishTime = DateTime.UtcNow;
-                    var ranFor = finishTime - testTimeout.StartTime;
-                    Console.WriteLine ("Will run out of time soon.  ran for {0}, finished {1}/{2} iterations", ranFor, j+1, TOTAL_ITERATIONS);
-            }
+            iterations += 1;
         }
 
-       Console.WriteLine ("done");
+        Console.WriteLine ($"done {iterations} iterations");
     }
 }