[tests] Add stress testing and reduce sgen normal testing time (#4653)
authorLudovic Henry <ludovic@xamarin.com>
Thu, 6 Apr 2017 18:49:04 +0000 (14:49 -0400)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2017 18:49:04 +0000 (14:49 -0400)
* [tests] Keep testing even if a test has failed

* [tests] Add stress testing and reduce sgen normal testing time

mono/mini/TestDriver.cs
mono/tests/Makefile.am
mono/tests/sgen-domain-unload-2.cs
mono/tests/sgen-new-threads-collect.cs
mono/tests/sgen-new-threads-dont-join-stw-2.cs
mono/tests/sgen-new-threads-dont-join-stw.cs
scripts/ci/run-jenkins.sh
scripts/ci/run-test-stress-tests.sh [new file with mode: 0755]

index 639c52539709b1d228f866f5d7b5caae0a24cc8b..b17cb654fa2903fb1327eb7dd2ff4a299eecd179 100644 (file)
@@ -165,64 +165,29 @@ public class TestDriver {
 }
 
 /// Provide tests with the ability to find out how much time they have to run before being timed out.
-public class TestTimeout {
-       const string ENV_TIMEOUT = "TEST_DRIVER_TIMEOUT_SEC";
-       private readonly TimeSpan availableTime;
-       private TimeSpan slack;
-       private DateTime startTime;
-
-       /// <summary>
-       ///   How much time the test runner provided for us or TimeSpan.Zero if there is no bound.
-       /// </summary>
-       public TimeSpan AvailableTime { get { return availableTime; } }
-
-       public DateTime StartTime { get { return startTime; } }
-
-       /// <summary> Extra time to add when deciding if there
-       ///   is still time to run.  Bigger slack means less
-       ///   time left.
-       /// </summary>
-       public TimeSpan Slack {
-               get { return slack; }
-               set { slack = value; }
-       }
+public class TestTimeout
+{
+       private TimeSpan Timeout { get; }
 
-       public TestTimeout () {
-               availableTime = initializeAvailableTime ();
-               slack = defaultSlack ();
-       }
+       private DateTime StartTime { get; }
 
-       /// <summary>
-       ///    Consider the test started.
-       /// </summary>
-       public void Start ()
-       {
-               startTime = DateTime.UtcNow;
-       }
+       public bool HaveTimeLeft { get { return DateTime.UtcNow - StartTime < Timeout; } }
 
-       public bool HaveTimeLeft ()
-       {
-               if (availableTime == TimeSpan.Zero)
-                       return true;
-               var t = DateTime.UtcNow;
-               var finishTime = startTime + availableTime - slack;
-               return (t < finishTime);
-       }
+       public static bool IsStressTest { get { return Environment.GetEnvironmentVariable("MONO_TESTS_STRESS") == "1"; } }
 
-       private TimeSpan defaultSlack ()
+       private TestTimeout (TimeSpan timeout)
        {
-               return TimeSpan.FromSeconds (5);
+               Timeout = timeout;
+               StartTime = DateTime.UtcNow;
        }
 
-       private TimeSpan initializeAvailableTime ()
+       public static TestTimeout Start(TimeSpan timeout)
        {
-               var e = System.Environment.GetEnvironmentVariable(ENV_TIMEOUT);
-               double d;
-               if (Double.TryParse(e, out d)) {
-                       return TimeSpan.FromSeconds(d);
-               } else {
-                       return TimeSpan.Zero;
+               if (timeout.Ticks < 0)
+               {
+                       throw new ArgumentException("timeout");
                }
-       }
 
+               return new TestTimeout(timeout);
+       }
 }
index 1ac4b05e278feacf7f4fc3b732636356c3f3333d..47d456c4c3b176fcfdff329483225ae4e2196089 100644 (file)
@@ -1,37 +1,41 @@
 SUBDIRS = gc-descriptors . testing_gac
 
 check-local:
-       $(MAKE) test-jit
-       $(MAKE) test-generic-sharing
-       $(MAKE) test-type-load
-       $(MAKE) test-multi-netmodule
-       $(MAKE) test-cattr-type-load
-       $(MAKE) test-reflection-load-with-context
-       $(MAKE) test-platform
-       $(MAKE) test-console-output
-       $(MAKE) test-env-options
-       $(MAKE) test-unhandled-exception-2
-if !FULL_AOT_TESTS
-       $(MAKE) test-appdomain-unload
-endif
-       $(MAKE) test-process-stress
-       $(MAKE) test-pedump
-       $(MAKE) rm-empty-logs
-       $(MAKE) runtest-gac-loading
+       ok=:; \
+       $(MAKE) test-jit || ok=false; \
+       $(MAKE) test-generic-sharing || ok=false; \
+       $(MAKE) test-type-load || ok=false; \
+       $(MAKE) test-multi-netmodule || ok=false; \
+       $(MAKE) test-cattr-type-load || ok=false; \
+       $(MAKE) test-reflection-load-with-context || ok=false; \
+       $(MAKE) test-platform || ok=false; \
+       $(MAKE) test-console-output || ok=false; \
+       $(MAKE) test-env-options || ok=false; \
+       $(MAKE) test-unhandled-exception-2 || ok=false; \
+       $(MAKE) test-appdomain-unload || ok=false; \
+       $(MAKE) test-process-stress || ok=false; \
+       $(MAKE) test-pedump || ok=false; \
+       $(MAKE) rm-empty-logs || ok=false; \
+       $(MAKE) runtest-gac-loading || ok=false; \
+       $$ok
 
 check-full:
-       $(MAKE) test-sgen
-       $(MAKE) check-local
+       ok=; \
+       $(MAKE) test-sgen || ok=false; \
+       $(MAKE) check-local || ok=false; \
+       $$ok
 
 check-parallel:
-       $(MAKE) compile-tests
-       $(MAKE) check-full
+       ok=; \
+       $(MAKE) compile-tests; \
+       $(MAKE) check-full || ok=false; \
+       $$ok
 
 check-coreclr:
        $(MAKE) -C $(mono_build_root)/acceptance-tests check-coreclr
 
 check-stress:
-       MONO_TESTS_STRESS=1 $(MAKE) test-sgen
+       $(MAKE) test-stress-sgen
 
 # for backwards compatibility on Wrench
 test-wrench: check-parallel
@@ -1391,10 +1395,22 @@ debug-casts: debug-casts.exe
 EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs     finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-new-threads-dont-join-stw-2.cs sgen-new-threads-collect.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs sgen-bridge-gchandle.cs
 
 test-sgen:
-       $(MAKE) test-sgen-regular
-       $(MAKE) test-sgen-toggleref
-       $(MAKE) test-sgen-bridge
-       $(MAKE) test-sgen-bridge2
+       ok=; \
+       $(MAKE) test-sgen-regular || ok=false; \
+       $(MAKE) test-sgen-toggleref || ok=false; \
+       $(MAKE) test-sgen-bridge || ok=false; \
+       $(MAKE) test-sgen-bridge2 || ok=false; \
+       $(MAKE) test-sgen-bridge3 || ok=false; \
+       $$ok
+
+test-stress-sgen:
+       ok=; \
+       $(MAKE) test-stress-sgen-regular || ok=false; \
+       $(MAKE) test-stress-sgen-toggleref || ok=false; \
+       $(MAKE) test-stress-sgen-bridge || ok=false; \
+       $(MAKE) test-stress-sgen-bridge2 || ok=false; \
+       $(MAKE) test-stress-sgen-bridge3 || ok=false; \
+       $$ok
 
 TESTS_SGEN_REGULAR_SRC =       \
        finalizer-wait.cs       \
@@ -1423,15 +1439,23 @@ TESTSAOT_SGEN_REGULAR=$(TESTS_SGEN_REGULAR:.exe=.exe$(PLATFORM_AOT_SUFFIX))
 endif
 
 test-sgen-regular: $(TESTS_SGEN_REGULAR) $(TESTSAOT_SGEN_REGULAR)
-       $(MAKE) test-sgen-regular-ms
-       $(MAKE) test-sgen-regular-ms-conc
-       $(MAKE) test-sgen-regular-ms-conc-par
-       $(MAKE) test-sgen-regular-ms-conc-split
-       $(MAKE) test-sgen-regular-ms-split
-       $(MAKE) test-sgen-regular-ms-conc-split-95
-       $(MAKE) test-sgen-regular-ms-clear-at-gc
-       $(MAKE) test-sgen-regular-ms-conc-clear-at-gc
-       $(MAKE) test-sgen-regular-ms-conc-split-clear-at-gc
+       ok=; \
+       $(MAKE) test-sgen-regular-ms || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc || ok=false; \
+       $$ok
+
+test-stress-sgen-regular: $(TESTS_SGEN_REGULAR) $(TESTSAOT_SGEN_REGULAR)
+       ok=; \
+       $(MAKE) test-sgen-regular-ms MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc-par MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc-split-95 MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-regular-ms-conc-split-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $$ok
 
 test-sgen-regular-ms: $(TESTS_SGEN_REGULAR) $(TESTSAOT_SGEN_REGULAR) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --runtime-args "--gc=sgen --gc-debug= --gc-params=major=marksweep" --disabled "$(DISABLED_TESTS)" --timeout 900 $(TESTS_SGEN_REGULAR)
@@ -1466,14 +1490,22 @@ TESTSAOT_SGEN_TOGGLEREF=$(TESTS_SGEN_TOGGLEREF:.exe=.exe$(PLATFORM_AOT_SUFFIX))
 endif
 
 test-sgen-toggleref: $(TESTS_SGEN_TOGGLEREF) $(TESTSAOT_SGEN_TOGGLEREF)
-       $(MAKE) test-sgen-toggleref-ms
-       $(MAKE) test-sgen-toggleref-ms-conc
-       $(MAKE) test-sgen-toggleref-ms-conc-split
-       $(MAKE) test-sgen-toggleref-ms-split
-       $(MAKE) test-sgen-toggleref-ms-split-95
-       $(MAKE) test-sgen-toggleref-ms-clear-at-gc
-       $(MAKE) test-sgen-toggleref-ms-conc-clear-at-gc
-       $(MAKE) test-sgen-toggleref-ms-split-clear-at-gc
+       ok=; \
+       $(MAKE) test-sgen-toggleref-ms || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-conc || ok=false; \
+       $$ok
+
+test-stress-sgen-toggleref: $(TESTS_SGEN_TOGGLEREF) $(TESTSAOT_SGEN_TOGGLEREF)
+       ok=; \
+       $(MAKE) test-sgen-toggleref-ms MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-conc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-conc-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-split-95 MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-conc-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-toggleref-ms-split-clear-at-gc MONO_TESTS_STRESS=1 || ok=false; \
+       $$ok
 
 test-sgen-toggleref-ms: $(TESTS_SGEN_TOGGLEREF) $(TESTSAOT_SGEN_TOGGLEREF) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --runtime-args "--gc=sgen --gc-debug= --gc-params=toggleref-test" --disabled "$(DISABLED_TESTS)" --timeout 900 $(TESTS_SGEN_TOGGLEREF)
@@ -1507,14 +1539,22 @@ TESTSAOT_SGEN_BRIDGE=$(TESTS_SGEN_BRIDGE:.exe=.exe$(PLATFORM_AOT_SUFFIX))
 endif
 
 test-sgen-bridge: $(TESTS_SGEN_BRIDGE) $(TESTSAOT_SGEN_BRIDGE)
-       $(MAKE) test-sgen-bridge-ms
-       $(MAKE) test-sgen-bridge-ms-conc
-       $(MAKE) test-sgen-bridge-ms-split
-       $(MAKE) test-sgen-bridge-ms-new-bridge
-       $(MAKE) test-sgen-bridge-ms-conc-new-bridge
-       $(MAKE) test-sgen-bridge-ms-split-new-bridge
-       $(MAKE) test-sgen-bridge-ms-tarjan-bridge
-       $(MAKE) test-sgen-bridge-ms-split-tarjan-bridge
+       ok=; \
+       $(MAKE) test-sgen-bridge-ms || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-conc || ok=false; \
+       $$ok
+
+test-stress-sgen-bridge: $(TESTS_SGEN_BRIDGE) $(TESTSAOT_SGEN_BRIDGE)
+       ok=; \
+       $(MAKE) test-sgen-bridge-ms MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-conc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-conc-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-split-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge-ms-split-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $$ok
 
 test-sgen-bridge-ms: $(TESTS_SGEN_BRIDGE) $(TESTSAOT_SGEN_BRIDGE) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --runtime-args "--gc=sgen --gc-debug=Bridge --gc-params=" --disabled "$(DISABLED_TESTS)" --timeout 900 $(TESTS_SGEN_BRIDGE)
@@ -1547,14 +1587,22 @@ TESTSAOT_SGEN_BRIDGE2=$(TESTS_SGEN_BRIDGE2:.exe=.exe$(PLATFORM_AOT_SUFFIX))
 endif
 
 test-sgen-bridge2: $(TESTS_SGEN_BRIDGE2) $(TESTSAOT_SGEN_BRIDGE2)
-       $(MAKE) test-sgen-bridge2-ms
-       $(MAKE) test-sgen-bridge2-ms-conc
-       $(MAKE) test-sgen-bridge2-ms-split
-       $(MAKE) test-sgen-bridge2-ms-new-bridge
-       $(MAKE) test-sgen-bridge2-ms-conc-new-bridge
-       $(MAKE) test-sgen-bridge2-ms-split-new-bridge
-       $(MAKE) test-sgen-bridge2-ms-tarjan-bridge
-       $(MAKE) test-sgen-bridge2-ms-split-tarjan-bridge
+       ok=; \
+       $(MAKE) test-sgen-bridge2-ms || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-conc || ok=false; \
+       $$ok
+
+test-stress-sgen-bridge2: $(TESTS_SGEN_BRIDGE2) $(TESTSAOT_SGEN_BRIDGE2)
+       ok=; \
+       $(MAKE) test-sgen-bridge2-ms MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-conc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-conc-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-split-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge2-ms-split-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $$ok
 
 test-sgen-bridge2-ms: $(TESTS_SGEN_BRIDGE2) $(TESTSAOT_SGEN_BRIDGE2) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --runtime-args "--gc=sgen --gc-debug=bridge=2Bridge --gc-params=" --disabled "$(DISABLED_TESTS)" --timeout 900 $(TESTS_SGEN_BRIDGE2)
@@ -1587,14 +1635,22 @@ TESTSAOT_SGEN_BRIDGE3=$(TESTS_SGEN_BRIDGE3:.exe=.exe$(PLATFORM_AOT_SUFFIX))
 endif
 
 test-sgen-bridge3: $(TESTS_SGEN_BRIDGE3) $(TESTSAOT_SGEN_BRIDGE3)
-       $(MAKE) test-sgen-bridge3-ms
-       $(MAKE) test-sgen-bridge3-ms-conc
-       $(MAKE) test-sgen-bridge3-ms-split
-       $(MAKE) test-sgen-bridge3-ms-new-bridge
-       $(MAKE) test-sgen-bridge3-ms-conc-new-bridge
-       $(MAKE) test-sgen-bridge3-ms-split-new-bridge
-       $(MAKE) test-sgen-bridge3-ms-tarjan-bridge
-       $(MAKE) test-sgen-bridge3-ms-split-tarjan-bridge
+       ok=; \
+       $(MAKE) test-sgen-bridge3-ms || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-conc || ok=false; \
+       $$ok
+
+test-stress-sgen-bridge3: $(TESTS_SGEN_BRIDGE3) $(TESTSAOT_SGEN_BRIDGE3)
+       ok=; \
+       $(MAKE) test-sgen-bridge3-ms MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-conc MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-split MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-conc-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-split-new-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $(MAKE) test-sgen-bridge3-ms-split-tarjan-bridge MONO_TESTS_STRESS=1 || ok=false; \
+       $$ok
 
 test-sgen-bridge3-ms: $(TESTS_SGEN_BRIDGE3) $(TESTSAOT_SGEN_BRIDGE3) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --runtime-args "--gc=sgen --gc-debug=bridge=3Bridge --gc-params=major=marksweep" --disabled "$(DISABLED_TESTS)" --timeout 900 $(TESTS_SGEN_BRIDGE3)
@@ -1934,10 +1990,12 @@ TESTSAOT_UNHANDLED_EXCEPTION_255=$(TESTS_UNHANDLED_EXCEPTION_255:.exe=.exe$(PLAT
 endif
 
 test-unhandled-exception-2: $(TESTS_UNHANDLED_EXCEPTION_1) $(TESTS_UNHANDLED_EXCEPTION_255) $(TESTSAOT_UNHANDLED_EXCEPTION_1) $(TESTSAOT_UNHANDLED_EXCEPTION_255)
-       $(MAKE) test-unhandled-exception-2-1-with-managed-handler
-       $(MAKE) test-unhandled-exception-2-1-without-managed-handler
-       $(MAKE) test-unhandled-exception-2-255-with-managed-handler
-       $(MAKE) test-unhandled-exception-2-255-without-managed-handler
+       ok=; \
+       $(MAKE) test-unhandled-exception-2-1-with-managed-handler || ok=false; \
+       $(MAKE) test-unhandled-exception-2-1-without-managed-handler || ok=false; \
+       $(MAKE) test-unhandled-exception-2-255-with-managed-handler || ok=false; \
+       $(MAKE) test-unhandled-exception-2-255-without-managed-handler || ok=false; \
+       $$ok
 
 test-unhandled-exception-2-1-with-managed-handler: $(TESTS_UNHANDLED_EXCEPTION_1) $(TESTSAOT_UNHANDLED_EXCEPTION_1) test-runner.exe
        $(TOOLS_RUNTIME) $(TEST_RUNNER) -j a --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --expected-exit-code 1 $(TESTS_UNHANDLED_EXCEPTION_1)
@@ -1950,6 +2008,9 @@ test-unhandled-exception-2-255-without-managed-handler: $(TESTS_UNHANDLED_EXCEPT
 
 EXTRA_DIST += appdomain-loader.cs appdomain-tester.cs
 
+if FULL_AOT_TESTS
+test-appdomain-unload:
+else
 appdomain-loader.exe: appdomain-tester.exe
 
 test-appdomain-unload: appdomain-loader.exe appdomain-tester.exe
@@ -1957,6 +2018,7 @@ test-appdomain-unload: appdomain-loader.exe appdomain-tester.exe
        $(RUNTIME) appdomain-loader.exe > appdomain-loader.exe.2.stdout || exit 1;
        MONO_DEBUG_ASSEMBLY_UNLOAD=1 $(RUNTIME) -O=gshared appdomain-loader.exe > appdomain-loader.exe.3.stdout || exit 1;
        MONO_DEBUG_ASSEMBLY_UNLOAD=1 $(RUNTIME) appdomain-loader.exe > appdomain-loader.exe.4.stdout || exit 1;
+endif
 
 EXTRA_DIST += console-output.cs console-output.exe.stderr.expected console-output.exe.stdout.expected
 test-console-output: console-output.exe
index f1f6c2f932069f57ae67e85f017d8f47b9f50fc6..a27b22af907fb0f889bfa604e4071d4af262c203 100644 (file)
@@ -23,30 +23,23 @@ class Driver {
        }
 
        static void Main () {
-               var testTimeout = new TestTimeout ();
-               testTimeout.Start ();
                for (int i = 0; i < Math.Max (1, Environment.ProcessorCount / 2); ++i) {
                // for (int i = 0; i < 4; ++i) {
                        var t = new Thread (BackgroundNoise);
                        t.IsBackground = true;
                        t.Start ();
                }
-               
-               const int TOTAL_ITERATIONS = 100;
-               for (int i = 0; i < TOTAL_ITERATIONS; ++i) {
-                       var ad = AppDomain.CreateDomain ("domain_" + i);
+
+               int iterations = 0;
+
+               for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 1)); timeout.HaveTimeLeft;) {
+                       var ad = AppDomain.CreateDomain ("domain_" + iterations);
                        ad.DoCallBack (new CrossAppDomainDelegate (AllocStuff));
                        AppDomain.Unload (ad);
 
                        Console.Write (".");
-                       if (i > 0 && i % 20 == 0) 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, i+1, TOTAL_ITERATIONS);
-                       }
+                       if ((++iterations) % 20 == 0) Console.WriteLine ();
                }
-               Console.WriteLine ("\ndone");
+               Console.WriteLine ($"\ndone {iterations} iterations");
        }
 }
index c5d5e4aa26adab5eb928aa7a58f1bdfb5a015c89..ed6e75c7d51f7f0dfe2031337268aae0d3b89da4 100644 (file)
@@ -5,20 +5,16 @@ using System.Threading;
 
 class Driver
 {
-       static DateTime targetTime;
-       static bool finished() {
-               DateTime now = DateTime.UtcNow;
-               return now > targetTime;
-       }
+       static TestTimeout timeout;
 
        public static void Main ()
        {
                int gcCount = 0;
                int joinCount = 0;
-               targetTime = DateTime.UtcNow.AddSeconds(30);
+               TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 1));
 
                Thread gcThread = new Thread (() => {
-                       while (!finished()) {
+                       while (timeout.HaveTimeLeft) {
                                GC.Collect ();
                                gcCount++;
                                Thread.Sleep (1);
@@ -27,8 +23,8 @@ class Driver
 
                gcThread.Start ();
 
-               // Create threads then join them for 30 seconds nonstop while GCs occur once per ms
-               while (!finished()) {
+               // Create threads then join them for 1 seconds (120 for stress tests) nonstop while GCs occur once per ms
+               while (timeout.HaveTimeLeft) {
                        BlockingCollection<Thread> threads = new BlockingCollection<Thread> (new ConcurrentQueue<Thread> (), 128);
 
                        Thread joinThread = new Thread (() => {
@@ -57,7 +53,7 @@ class Driver
                        joinThread.Join ();
 
                        joinCount += makeThreads;
-                       Console.WriteLine("Performed {0} GCs, created {1} threads. Finished? {2}", gcCount, joinCount, finished());
+                       Console.WriteLine("Performed {0} GCs, created {1} threads. Finished? {2}", gcCount, joinCount, !timeout.HaveTimeLeft);
                }
                gcThread.Join ();
        }
index 34dace1c955a22c02f97957ae3c7bf0e2c55683b..a9abf829b703e81348562b4c2bf78190b48ea0d0 100644 (file)
@@ -13,7 +13,7 @@ class Driver
                Thread producer = new Thread (new ThreadStart (() => {
                        DateTime start = DateTime.Now;
 
-                       while (DateTime.Now - start < TimeSpan.FromSeconds (30)) {
+                       for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 1)); timeout.HaveTimeLeft;) {
                                Thread worker = new Thread (new ThreadStart (() => {
                                        HashSet<string> hashset = new HashSet<string> ();
                                        for (int i = 0; i < 50000; ++i) {
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");
     }
 }
index fc913009f2a31a9c8cb2cc22590eabd87c97deb2..6c923e97762a0dd2928a647767bdceb4c1baa3e0 100755 (executable)
@@ -84,7 +84,10 @@ if [[ ${CI_TAGS} == *'acceptance-tests'* ]];
        $(dirname "${BASH_SOURCE[0]}")/run-test-acceptance-tests.sh
 elif [[ ${CI_TAGS} == *'profiler-stress-tests'* ]];
     then
-       $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
+    $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
+elif [[ ${CI_TAGS} == *'stress-tests'* ]];
+    then
+    $(dirname "${BASH_SOURCE[0]}")/run-test-stress-tests.sh
 elif [[ ${CI_TAGS} == *'interpreter'* ]];
     then
     $(dirname "${BASH_SOURCE[0]}")/run-test-interpreter.sh
diff --git a/scripts/ci/run-test-stress-tests.sh b/scripts/ci/run-test-stress-tests.sh
new file mode 100755 (executable)
index 0000000..32d9f84
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash -e
+
+${TESTCMD} --label=check-stress --timeout=12h make -C mono/tests check-stress