From 134e636ead57bac5a2ab2c4f1af517bc4bd8d7cf Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 26 Apr 2024 07:04:24 -0700 Subject: [PATCH] Improve tests/profiler/multiple/multiple.cs - Add volatile for a field accessed by multiple threads without synchronization - Improve logging - Delete test supression against closed issue - Revert timeout increase that tried to work around a hang that was fixed since then --- src/tests/profiler/common/ProfilerTestRunner.cs | 14 ++++++++------ src/tests/profiler/multiple/multiple.cs | 7 +------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/tests/profiler/common/ProfilerTestRunner.cs b/src/tests/profiler/common/ProfilerTestRunner.cs index d78a1221b4221..2dfc2530c59d6 100644 --- a/src/tests/profiler/common/ProfilerTestRunner.cs +++ b/src/tests/profiler/common/ProfilerTestRunner.cs @@ -135,9 +135,9 @@ public static int Run(string profileePath, if (!verifier.HasPassingOutput) { - FailFastWithMessage("Profiler tests are expected to contain the text \'" + verifier.SuccessPhrase + "\' in the console output " + - "of the profilee app to indicate a passing test. Usually it is printed from the Shutdown() method of the profiler implementation. This " + - "text was not found in the output above."); + FailFastWithMessage($"Profiler tests are expected to contain the text '{verifier.SuccessPhrase}' in the console output " + + $"of the profilee app to indicate a passing test. Usually it is printed from the Shutdown() method of the profiler implementation. This " + + $"text was not found in the output above. Profilee returned exit code {process.ExitCode}."); } if (process.ExitCode != 100) @@ -195,14 +195,16 @@ private static void FailFastWithMessage(string error) /// class ProfileeOutputVerifier { + private volatile bool _hasPassingOutput; + public string SuccessPhrase = "PROFILER TEST PASSES"; - public bool HasPassingOutput { get; private set; } + public bool HasPassingOutput => _hasPassingOutput; public void WriteLine(string message) { if (message != null && message.Contains(SuccessPhrase)) { - HasPassingOutput = true; + _hasPassingOutput = true; } } @@ -210,7 +212,7 @@ public void WriteLine(string format, params object[] args) { if (string.Format(format,args).Contains(SuccessPhrase)) { - HasPassingOutput = true; + _hasPassingOutput = true; } } } diff --git a/src/tests/profiler/multiple/multiple.cs b/src/tests/profiler/multiple/multiple.cs index 0d686ae0691a9..a0952687021bf 100644 --- a/src/tests/profiler/multiple/multiple.cs +++ b/src/tests/profiler/multiple/multiple.cs @@ -35,7 +35,7 @@ public static int RunTest(String[] args) } Console.WriteLine("Waiting for profilers to all detach"); - if (!_profilerDone.WaitOne(TimeSpan.FromMinutes(10))) + if (!_profilerDone.WaitOne(TimeSpan.FromMinutes(5))) { throw new Exception("Test timed out waiting for the profilers to set the callback, test will fail."); } @@ -45,11 +45,6 @@ public static int RunTest(String[] args) public static int Main(string[] args) { - // failing on MacOs 12 https://github.com/dotnet/runtime/issues/64765 - if (OperatingSystem.IsMacOS()) - { - return 100; - } if (args.Length > 0 && args[0].Equals("RunTest", StringComparison.OrdinalIgnoreCase)) { return RunTest(args);