Skip to content

Commit

Permalink
Improve tests/profiler/multiple/multiple.cs (#101607)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jkotas authored Apr 26, 2024
1 parent 2c99786 commit 0f562e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/tests/profiler/common/ProfilerTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -195,22 +195,24 @@ private static void FailFastWithMessage(string error)
/// </summary>
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;
}
}

public void WriteLine(string format, params object[] args)
{
if (string.Format(format,args).Contains(SuccessPhrase))
{
HasPassingOutput = true;
_hasPassingOutput = true;
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/tests/profiler/multiple/multiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand All @@ -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);
Expand Down

0 comments on commit 0f562e9

Please sign in to comment.