-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for notification profilers (#57429)
Add CI tests for notification profilers, and fix a couple things to make life with multiple profilers easier * Reduced default timeout for profiler detach - we used to try at 300ms, 600ms, 5s, 10s, and then 10 minutes. The check is just a read of an int, so there's no reason to wait 10 minutes * Got rid of a couple asserts that were wrong since switching from the dedicated profiler attach thread to the diagnostics server implementation * ProfControlBlock::GetProfilerInfo would only work for active profilers, not attaching profilers, which could cause subtle bugs
- Loading branch information
Showing
30 changed files
with
355 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
|
||
namespace Profiler.Tests | ||
{ | ||
class MultiplyLoaded | ||
{ | ||
static readonly Guid MultipleProfilerGuid = new Guid("BFA8EF13-E144-49B9-B95C-FC1C150C7651"); | ||
static readonly string ProfilerPath = ProfilerTestRunner.GetProfilerPath(); | ||
|
||
[DllImport("Profiler")] | ||
private static extern void PassCallbackToProfiler(ProfilerCallback callback); | ||
|
||
public static int RunTest(String[] args) | ||
{ | ||
ManualResetEvent _profilerDone = new ManualResetEvent(false); | ||
PassCallbackToProfiler(() => _profilerDone.Set()); | ||
|
||
ProfilerControlHelpers.AttachProfilerToSelf(MultipleProfilerGuid, ProfilerPath); | ||
|
||
try | ||
{ | ||
Console.WriteLine("Throwing exception"); | ||
throw new Exception("Test exception!"); | ||
} | ||
catch | ||
{ | ||
// intentionally swallow the exception | ||
Console.WriteLine("Exception caught"); | ||
} | ||
|
||
Console.WriteLine("Waiting for profilers to all detach"); | ||
if (!_profilerDone.WaitOne(TimeSpan.FromMinutes(5))) | ||
{ | ||
Console.WriteLine("Profiler did not set the callback, test will fail."); | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
public static int Main(string[] args) | ||
{ | ||
if (args.Length > 0 && args[0].Equals("RunTest", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return RunTest(args); | ||
} | ||
|
||
return ProfilerTestRunner.Run(profileePath: System.Reflection.Assembly.GetExecutingAssembly().Location, | ||
testName: "MultiplyLoaded", | ||
profilerClsid: MultipleProfilerGuid, | ||
loadAsNotification: true, | ||
notificationCopies: 2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> | ||
<OutputType>exe</OutputType> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
<ProjectReference Include="../common/profiler_common.csproj" /> | ||
<ProjectReference Include="$(MSBuildThisFileDirectory)/../native/CMakeLists.txt" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.