Skip to content

Commit cb2cacd

Browse files
committed
[tests] Duplicate Microsoft.Diagnostics.NETCore.Client dependent tests for Linux arm
1 parent 9b58954 commit cb2cacd

36 files changed

+1610
-135
lines changed

src/tests/Directory.Build.props

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,5 @@
195195
<TestFramework>GeneratedRunner</TestFramework>
196196
</PropertyGroup>
197197

198-
<PropertyGroup>
199-
<!-- On Linux arm coreclr, the updated tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj project
200-
does not yet work for several eventpipe runtime tests. We segment those tests with the following property and symbol -->
201-
<UseUpdatedNETCoreClient Condition="!('$(TargetOS)' == 'Linux' And '$(TargetArchitecture)' == 'arm' And '$(RuntimeFlavor)' == 'coreclr')">true</UseUpdatedNETCoreClient>
202-
<DefineConstants Condition="'$(UseUpdatedNETCoreClient)' == 'true'">$(DefineConstants);UPDATED_NETCORE_CLIENT</DefineConstants>
203-
</PropertyGroup>
204-
205198
<Import Project="$(RepositoryEngineeringDir)testing\tests.props" Condition="'$(IsTestsCommonProject)' != 'true'" />
206199
</Project>

src/tests/JIT/Directed/debugging/debuginfo/tester.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
using System.Linq;
99
using System.Reflection;
1010
using System.Runtime.CompilerServices;
11-
#if UPDATED_NETCORE_CLIENT
1211
using Microsoft.Diagnostics.NETCore.Client;
13-
#else
14-
using Microsoft.Diagnostics.Tools.RuntimeClient;
15-
#endif
1612
using Microsoft.Diagnostics.Tracing;
1713
using Microsoft.Diagnostics.Tracing.Parsers;
1814
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
@@ -27,7 +23,6 @@ public static unsafe int Main()
2723
var keywords =
2824
ClrTraceEventParser.Keywords.Jit | ClrTraceEventParser.Keywords.JittedMethodILToNativeMap;
2925

30-
#if UPDATED_NETCORE_CLIENT
3126
var dotnetRuntimeProvider = new List<EventPipeProvider>
3227
{
3328
new EventPipeProvider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (long)keywords)
@@ -40,21 +35,6 @@ public static unsafe int Main()
4035
dotnetRuntimeProvider,
4136
1024,
4237
ValidateMappings);
43-
#else
44-
var dotnetRuntimeProvider = new List<Provider>
45-
{
46-
new Provider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (ulong)keywords)
47-
};
48-
49-
var config = new SessionConfiguration(1024, EventPipeSerializationFormat.NetTrace, dotnetRuntimeProvider);
50-
51-
return
52-
IpcTraceTest.RunAndValidateEventCounts(
53-
new Dictionary<string, ExpectedEventCount>(),
54-
JitMethods,
55-
config,
56-
ValidateMappings);
57-
#endif
5838
}
5939

6040
private static void JitMethods()

src/tests/JIT/Directed/debugging/debuginfo/tester.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ProjectReference Include="tests_r.ilproj" Aliases="tests_r" />
1313
<ProjectReference Include="attribute.csproj" />
1414
<ProjectReference Include="../../../../tracing/eventpipe/common/common.csproj" />
15-
<ProjectReference Condition="'$(UseUpdatedNETCoreClient)' == 'true'" Include="../../../../tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" />
15+
<ProjectReference Include="../../../../tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" />
1616
<Compile Include="$(MSBuildProjectName).cs" />
1717
</ItemGroup>
1818
</Project>
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
extern alias tests_d;
2+
extern alias tests_r;
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Diagnostics.Tracing;
8+
using System.Linq;
9+
using System.Reflection;
10+
using System.Runtime.CompilerServices;
11+
using Microsoft.Diagnostics.Tools.RuntimeClient;
12+
using Microsoft.Diagnostics.Tracing;
13+
using Microsoft.Diagnostics.Tracing.Parsers;
14+
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
15+
using Tracing.Tests.Common;
16+
using DebugInfoMethodsD = tests_d::DebugInfoMethods;
17+
using DebugInfoMethodsR = tests_r::DebugInfoMethods;
18+
19+
public unsafe class DebugInfoTest
20+
{
21+
public static unsafe int Main()
22+
{
23+
var keywords =
24+
ClrTraceEventParser.Keywords.Jit | ClrTraceEventParser.Keywords.JittedMethodILToNativeMap;
25+
26+
var dotnetRuntimeProvider = new List<Provider>
27+
{
28+
new Provider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (ulong)keywords)
29+
};
30+
31+
var config = new SessionConfiguration(1024, EventPipeSerializationFormat.NetTrace, dotnetRuntimeProvider);
32+
33+
return
34+
IpcTraceTest.RunAndValidateEventCounts(
35+
new Dictionary<string, ExpectedEventCount>(),
36+
JitMethods,
37+
config,
38+
ValidateMappings);
39+
}
40+
41+
private static void JitMethods()
42+
{
43+
ProcessType(typeof(DebugInfoMethodsD));
44+
ProcessType(typeof(DebugInfoMethodsR));
45+
}
46+
47+
private static void ProcessType(Type t)
48+
{
49+
foreach (MethodInfo mi in t.GetMethods())
50+
{
51+
if (mi.GetCustomAttribute<ExpectedILMappings>() != null)
52+
{
53+
RuntimeHelpers.PrepareMethod(mi.MethodHandle);
54+
}
55+
}
56+
}
57+
58+
private static Func<int> ValidateMappings(EventPipeEventSource source)
59+
{
60+
List<(long MethodID, OptimizationTier Tier, (int ILOffset, int NativeOffset)[] Mappings)> methodsWithMappings = new();
61+
Dictionary<long, OptimizationTier> methodTier = new();
62+
63+
source.Clr.MethodLoad += e => methodTier[e.MethodID] = e.OptimizationTier;
64+
source.Clr.MethodLoadVerbose += e => methodTier[e.MethodID] = e.OptimizationTier;
65+
source.Clr.MethodILToNativeMap += e =>
66+
{
67+
if (e.MethodID == 0)
68+
return;
69+
70+
var mappings = new (int, int)[e.CountOfMapEntries];
71+
for (int i = 0; i < mappings.Length; i++)
72+
mappings[i] = (e.ILOffset(i), e.NativeOffset(i));
73+
74+
if (!methodTier.TryGetValue(e.MethodID, out OptimizationTier tier))
75+
tier = OptimizationTier.Unknown;
76+
77+
methodsWithMappings.Add((e.MethodID, tier, mappings));
78+
};
79+
80+
return () =>
81+
{
82+
int result = 100;
83+
foreach ((long methodID, OptimizationTier tier, (int ILOffset, int NativeOffset)[] mappings) in methodsWithMappings)
84+
{
85+
MethodBase meth = s_getMethodBaseByHandle(null, (IntPtr)(void*)methodID);
86+
ExpectedILMappings attrib = meth.GetCustomAttribute<ExpectedILMappings>();
87+
if (attrib == null)
88+
{
89+
continue;
90+
}
91+
92+
string name = $"[{meth.DeclaringType.Assembly.GetName().Name}]{meth.DeclaringType.FullName}.{meth.Name}";
93+
94+
// If DebuggableAttribute is saying that the assembly must be debuggable, then verify debug mappings.
95+
// Otherwise verify release mappings.
96+
// This may seem a little strange since we do not use the tier at all -- however, we expect debug
97+
// to never tier and in release, we expect the release mappings to be the "least common denominator",
98+
// i.e. tier0 and tier1 mappings should both be a superset.
99+
// Note that tier0 and MinOptJitted differs in mappings generated exactly due to DebuggableAttribute.
100+
DebuggableAttribute debuggableAttrib = meth.DeclaringType.Assembly.GetCustomAttribute<DebuggableAttribute>();
101+
bool debuggableMappings = debuggableAttrib != null && debuggableAttrib.IsJITOptimizerDisabled;
102+
103+
Console.WriteLine("{0}: Validate mappings for {1} codegen (tier: {2})", name, debuggableMappings ? "debuggable" : "optimized", tier);
104+
105+
int[] expected = debuggableMappings ? attrib.Debug : attrib.Opts;
106+
if (expected == null)
107+
{
108+
continue;
109+
}
110+
111+
if (!ValidateSingle(expected, mappings))
112+
{
113+
Console.WriteLine(" Validation failed: expected mappings at IL offsets {0}", string.Join(", ", expected.Select(il => $"{il:x3}")));
114+
Console.WriteLine(" Actual (IL <-> native):");
115+
foreach ((int ilOffset, int nativeOffset) in mappings)
116+
{
117+
string ilOffsetName = Enum.IsDefined((SpecialILOffset)ilOffset) ? ((SpecialILOffset)ilOffset).ToString() : $"{ilOffset:x3}";
118+
Console.WriteLine(" {0:x3} <-> {1:x3}", ilOffsetName, nativeOffset);
119+
}
120+
121+
result = -1;
122+
}
123+
}
124+
125+
return result;
126+
};
127+
}
128+
129+
// Validate that all IL offsets we expected had mappings generated for them.
130+
private static bool ValidateSingle(int[] expected, (int ILOffset, int NativeOffset)[] mappings)
131+
{
132+
return expected.All(il => mappings.Any(t => t.ILOffset == il));
133+
}
134+
135+
private enum SpecialILOffset
136+
{
137+
NoMapping = -1,
138+
Prolog = -2,
139+
Epilog = -3,
140+
}
141+
142+
static DebugInfoTest()
143+
{
144+
Type runtimeMethodHandleInternalType = typeof(RuntimeMethodHandle).Assembly.GetType("System.RuntimeMethodHandleInternal");
145+
Type runtimeTypeType = typeof(RuntimeMethodHandle).Assembly.GetType("System.RuntimeType");
146+
MethodInfo getMethodBaseMethod = runtimeTypeType.GetMethod("GetMethodBase", BindingFlags.NonPublic | BindingFlags.Static, new[] { runtimeTypeType, runtimeMethodHandleInternalType });
147+
s_getMethodBaseByHandle = (delegate*<object, IntPtr, MethodBase>)getMethodBaseMethod.MethodHandle .GetFunctionPointer();
148+
}
149+
150+
// Needed to go from MethodID -> MethodBase
151+
private static readonly delegate*<object, IntPtr, MethodBase> s_getMethodBaseByHandle;
152+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<DebugType>PdbOnly</DebugType>
5+
<Optimize>True</Optimize>
6+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
7+
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
8+
<GCStressIncompatible>true</GCStressIncompatible>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="tests_d.ilproj" Aliases="tests_d" />
12+
<ProjectReference Include="tests_r.ilproj" Aliases="tests_r" />
13+
<ProjectReference Include="attribute.csproj" />
14+
<ProjectReference Include="../../../../tracing/eventpipe/common_legacy/common_legacy.csproj" />
15+
<Compile Include="$(MSBuildProjectName).cs" />
16+
</ItemGroup>
17+
</Project>

src/tests/issues.targets

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,4 +3855,55 @@
38553855
<Issue>missing assembly</Issue>
38563856
</ExcludeList>
38573857
</ItemGroup>
3858+
3859+
<ItemGroup Condition="'$(TargetOS)' == 'Linux' And '$(TargetArchitecture)' == 'arm' And '$(RuntimeFlavor)' == 'coreclr'" >
3860+
<ExcludeList Include = "$(XunitTestBinBase)/JIT/Directed/debugging/debuginfo/tester.cs;$(XunitTestBinBase)/JIT/Directed/debugging/debuginfo/tester.csproj">
3861+
<Issue>needs triage</Issue>
3862+
</ExcludeList>
3863+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/bigevent/**">
3864+
<Issue>needs triage</Issue>
3865+
</ExcludeList>
3866+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/buffersize/**">
3867+
<Issue>needs triage</Issue>
3868+
</ExcludeList>
3869+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/bigevent/**">
3870+
<Issue>needs triage</Issue>
3871+
</ExcludeList>
3872+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/eventsourceerror/**">
3873+
<Issue>needs triage</Issue>
3874+
</ExcludeList>
3875+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/gcdump/**">
3876+
<Issue>needs triage</Issue>
3877+
</ExcludeList>
3878+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/providervalidation/**">
3879+
<Issue>needs triage</Issue>
3880+
</ExcludeList>
3881+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/rundownvalidation/**">
3882+
<Issue>needs triage</Issue>
3883+
</ExcludeList>
3884+
</ItemGroup>
3885+
3886+
<ItemGroup Condition="!('$(TargetOS)' == 'Linux' And '$(TargetArchitecture)' == 'arm' And '$(RuntimeFlavor)' == 'coreclr')" >
3887+
<ExcludeList Include = "$(XunitTestBinBase)/JIT/Directed/debugging/debuginfo/tester_legacy*">
3888+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3889+
</ExcludeList>
3890+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/buffersize_legacy/**">
3891+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3892+
</ExcludeList>
3893+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/bigevent_legacy/**">
3894+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3895+
</ExcludeList>
3896+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/eventsourceerror_legacy/**">
3897+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3898+
</ExcludeList>
3899+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/gcdump_legacy/**">
3900+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3901+
</ExcludeList>
3902+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/providervalidation_legacy/**">
3903+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3904+
</ExcludeList>
3905+
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventpipe/rundownvalidation_legacy/**">
3906+
<Issue>Legacy to remove when main tests pass on Linux arm coreclr</Issue>
3907+
</ExcludeList>
3908+
</ItemGroup>
38583909
</Project>

src/tests/tracing/eventpipe/bigevent/bigevent.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
using Microsoft.Diagnostics.Tracing;
1212
using Tracing.Tests.Common;
1313
using Microsoft.Diagnostics.Tracing.Parsers.Clr;
14-
#if (UPDATED_NETCORE_CLIENT == true)
15-
using Microsoft.Diagnostics.NETCore.Client;
16-
#else
17-
using Microsoft.Diagnostics.Tools.RuntimeClient;
18-
#endif
14+
using Microsoft.Diagnostics.NETCore.Client;
1915

2016
namespace Tracing.Tests.BigEventsValidation
2117
{
@@ -49,22 +45,12 @@ public static int Main(string[] args)
4945
{
5046
// This test tries to send a big event (>100KB) and checks that the app does not crash
5147
// See https://github.com/dotnet/runtime/issues/50515 for the regression issue
52-
#if (UPDATED_NETCORE_CLIENT == true)
5348
var providers = new List<EventPipeProvider>()
5449
{
5550
new EventPipeProvider("BigEventSource", EventLevel.Verbose)
5651
};
5752

5853
return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _Verify);
59-
#else
60-
var providers = new List<Provider>()
61-
{
62-
new Provider("BigEventSource")
63-
};
64-
65-
var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);
66-
return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _Verify);
67-
#endif
6854
}
6955

7056
private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>()

src/tests/tracing/eventpipe/bigevent/bigevent.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
<ItemGroup>
1212
<Compile Include="$(MSBuildProjectName).cs" />
1313
<ProjectReference Include="../common/common.csproj" />
14-
<ProjectReference Condition="'$(UseUpdatedNETCoreClient)' == 'true'" Include="../common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" />
14+
<ProjectReference Include="../common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" />
1515
</ItemGroup>
1616
</Project>

0 commit comments

Comments
 (0)