From 90f20be3f7e30f06d37ff678876edd025d468430 Mon Sep 17 00:00:00 2001 From: "Daisy Zhou (Centific Technologies Inc)" Date: Mon, 19 May 2025 10:22:21 +0800 Subject: [PATCH 1/3] add test count after tests run --- .../Stress/Framework/ReliabilityFramework.cs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs index 3403e33e5091d8..1c7558ed474234 100644 --- a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs +++ b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs @@ -334,6 +334,22 @@ public void RecordTestRunCount() _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Tests run count:\n{sb}"); } + public void RecordTestRunCountSingle(string refOrID) + { + StringBuilder sb = new(); + lock (_testRunCounterLock) + { + foreach(var item in _testRunCounter) + { + if(item.Key == refOrID) + { + _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Run tests \"{item.Key}\" {item.Value} times."); + } + } + } + + } + public void HandleOom(Exception e, string message) { _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Exception while running tests: {0}", e)); @@ -981,7 +997,15 @@ private void StartTest(ReliabilityTest test) _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.TestStarter, String.Format("RF.StartTest, RTs({0}) - Instances of this test: {1} - New Test:{2}, {3} threads", _testsRunningCount, test.RunningCount, test.RefOrID, Process.GetCurrentProcess().Threads.Count)); + lock(_testRunCounterLock) + { + string testRefOrID = test.RefOrID; + _testRunCounter[testRefOrID] = _testRunCounter.GetValueOrDefault(testRefOrID, 0) + 1; + } + newThread.Start(test); + RecordTestRunCountSingle(test.RefOrID); + } catch (OutOfMemoryException e) { @@ -1221,12 +1245,6 @@ private void StartTestWorker(object test) } break; } - - lock (_testRunCounterLock) - { - string testRefOrID = daTest.RefOrID; - _testRunCounter[testRefOrID] = _testRunCounter.GetValueOrDefault(testRefOrID, 0) + 1; - } } catch (Exception e) { From b25612e3f56cc99c6ceb04093f8b645e0532413c Mon Sep 17 00:00:00 2001 From: "Daisy Zhou (Centific Technologies Inc)" Date: Tue, 20 May 2025 17:23:59 +0800 Subject: [PATCH 2/3] PR feedback --- .../GC/Stress/Framework/ReliabilityFramework.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs index 1c7558ed474234..ebf2f003058510 100644 --- a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs +++ b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs @@ -325,7 +325,7 @@ public void RecordTestRunCount() { StringBuilder sb = new(); lock (_testRunCounterLock) - { + { foreach(var item in _testRunCounter) { sb.AppendLine($"{item.Key}: {item.Value}"); @@ -334,18 +334,14 @@ public void RecordTestRunCount() _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Tests run count:\n{sb}"); } - public void RecordTestRunCountSingle(string refOrID) + public void RecordTestRunCountForPerTest(string refOrID) { - StringBuilder sb = new(); lock (_testRunCounterLock) { - foreach(var item in _testRunCounter) + if (_testRunCounter.TryGetValue(refOrID, out var value)) { - if(item.Key == refOrID) - { - _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Run tests \"{item.Key}\" {item.Value} times."); - } - } + _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Run tests \"{refOrID}\" {value} times."); + } } } @@ -1004,7 +1000,7 @@ private void StartTest(ReliabilityTest test) } newThread.Start(test); - RecordTestRunCountSingle(test.RefOrID); + RecordTestRunCountForPerTest(test.RefOrID); } catch (OutOfMemoryException e) From 3935b87087ad601fcea0846abea85896ae14d1ef Mon Sep 17 00:00:00 2001 From: "Daisy Zhou (Centific Technologies Inc)" Date: Tue, 20 May 2025 17:49:49 +0800 Subject: [PATCH 3/3] Delete the redundant Spaces --- src/tests/GC/Stress/Framework/ReliabilityFramework.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs index ebf2f003058510..ded71461fb5d3c 100644 --- a/src/tests/GC/Stress/Framework/ReliabilityFramework.cs +++ b/src/tests/GC/Stress/Framework/ReliabilityFramework.cs @@ -325,7 +325,7 @@ public void RecordTestRunCount() { StringBuilder sb = new(); lock (_testRunCounterLock) - { + { foreach(var item in _testRunCounter) { sb.AppendLine($"{item.Key}: {item.Value}");