diff --git a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs index 478b6895049a66..3403e33e5091d8 100644 --- a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs +++ b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs @@ -119,6 +119,8 @@ public class ReliabilityFramework private int _reportedFailCnt = 0; private RFLogging _logger = new RFLogging(); private DateTime _lastLogTime = DateTime.Now; + private Dictionary _testRunCounter = new(); + private object _testRunCounterLock = new(); // static members private static int s_seed = (int)System.DateTime.Now.Ticks; @@ -161,6 +163,11 @@ public static int Main(string[] args) ReliabilityFramework rf = new ReliabilityFramework(); rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, "Started"); + + Console.CancelKeyPress += (object _, ConsoleCancelEventArgs _) => { + rf.RecordTestRunCount(); + }; + var configVars = GC.GetConfigurationVariables(); foreach (var kvp in configVars) { @@ -305,7 +312,7 @@ public static int Main(string[] args) } NoExitPoll(); - + rf.RecordTestRunCount(); rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, String.Format("Shutdown w/ ret val of {0}", retVal)); @@ -314,6 +321,19 @@ public static int Main(string[] args) return (retVal); } + public void RecordTestRunCount() + { + StringBuilder sb = new(); + lock (_testRunCounterLock) + { + foreach(var item in _testRunCounter) + { + sb.AppendLine($"{item.Key}: {item.Value}"); + } + } + _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Tests run count:\n{sb}"); + } + public void HandleOom(Exception e, string message) { _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Exception while running tests: {0}", e)); @@ -621,6 +641,11 @@ private void TestStarter() DateTime lastStart = DateTime.Now; // keeps track of when we last started a test TimeSpan minTimeToStartTest = new TimeSpan(0, 5, 0); // after 5 minutes if we haven't started a test we're having problems... int cpuAdjust = 0, memAdjust = 0; // if we discover that we're not starting new tests quick enough we adjust the CPU/Mem percentages + + foreach (var test in _curTestSet.Tests) + { + _testRunCounter[test.RefOrID] = 0; + } // so we start new tests sooner (so they start BEFORE we drop below our minimum CPU) //Console.WriteLine("RF - TestStarter found {0} tests to run", totalTestsToRun); @@ -1196,6 +1221,12 @@ private void StartTestWorker(object test) } break; } + + lock (_testRunCounterLock) + { + string testRefOrID = daTest.RefOrID; + _testRunCounter[testRefOrID] = _testRunCounter.GetValueOrDefault(testRefOrID, 0) + 1; + } } catch (Exception e) {