Skip to content

Commit 07b6e33

Browse files
authored
Add new Pipeline for Running Libs Tests with TestReadyToRun (#91229)
1 parent 40c550a commit 07b6e33

File tree

13 files changed

+199
-6
lines changed

13 files changed

+199
-6
lines changed

eng/pipelines/common/platform-matrix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ parameters:
2525
jobs:
2626

2727
# Linux arm
28+
2829
- ${{ if or(containsValue(parameters.platforms, 'linux_arm'), in(parameters.platformGroup, 'all', 'gcstress')) }}:
2930
- template: xplat-setup.yml
3031
parameters:
@@ -45,6 +46,7 @@ jobs:
4546
${{ insert }}: ${{ parameters.jobParameters }}
4647

4748
# Linux armv6
49+
4850
- ${{ if containsValue(parameters.platforms, 'linux_armv6') }}:
4951
- template: xplat-setup.yml
5052
parameters:

eng/pipelines/coreclr/crossgen2.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ extends:
6060
displayNameArgs: R2R_CG2
6161
liveLibrariesBuildConfig: Release
6262

63+
- template: /eng/pipelines/common/platform-matrix.yml
64+
parameters:
65+
jobTemplate: /eng/pipelines/common/global-build-job.yml
66+
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
67+
buildConfig: Release
68+
platforms:
69+
- linux_x64
70+
- osx_x64
71+
- windows_x64
72+
jobParameters:
73+
testGroup: innerloop
74+
buildArgs: -s clr+libs+libs.tests
75+
-c $(_BuildConfig)
76+
/p:TestReadyToRun=true
77+
/p:ArchiveTests=true
78+
nameSuffix: TestReadyToRun_Libraries
79+
timeoutInMinutes: 360
80+
postBuildSteps:
81+
- template: /eng/pipelines/libraries/helix.yml
82+
parameters:
83+
creator: dotnet-bot
84+
testRunNamePrefixSuffix: TestReadyToRun_$(_BuildConfig)
85+
6386
# Run pri0 tests with hot/cold splitting enabled (only supported on x64 at the moment)
6487
# TODO: test on arm64 once supported
6588
- template: /eng/pipelines/common/platform-matrix.yml

eng/testing/tests.singlefile.targets

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<DefineConstants>$(DefineConstants);SINGLE_FILE_TEST_RUNNER</DefineConstants>
7171
</PropertyGroup>
7272

73+
<PropertyGroup Condition="'$(TestReadyToRun)' == 'true'">
74+
<DefineConstants>$(DefineConstants);TEST_READY_TO_RUN_COMPILED</DefineConstants>
75+
</PropertyGroup>
76+
7377
<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestNativeAot)' == 'true'" />
7478

7579
<ItemGroup Condition="'$(TestNativeAot)' == 'true'">
@@ -106,6 +110,114 @@
106110
</ItemGroup>
107111
</Target>
108112

113+
<!--
114+
For TestReadyToRun, we need the whole framework to be R2R-compiled besides
115+
the actual test assembly. However, this is a very lengthy process and it's
116+
unnecessary in this case because we already have an R2R-compiled framework.
117+
So, we have to tell the build that we already have these binaries so that it
118+
doesn't build them again for each test.
119+
-->
120+
<Target Name="ExcludeExistingR2RBinaries"
121+
Condition="'$(TestReadyToRun)' == 'true'"
122+
BeforeTargets="_PrepareForReadyToRunCompilation">
123+
<PropertyGroup>
124+
<ArtifactsNetCoreAppBundlePath>$(ArtifactsObjDir)Microsoft.NETCore.App.Bundle/</ArtifactsNetCoreAppBundlePath>
125+
<ArtifactsNetCoreAppBundlePath>$(ArtifactsNetCoreAppBundlePath)$(Configuration)/$(NetCoreAppCurrent)/$(OutputRID)/output/</ArtifactsNetCoreAppBundlePath>
126+
<ArtifactsNetCoreAppBundlePath>$(ArtifactsNetCoreAppBundlePath)shared/$(MicrosoftNetCoreAppFrameworkName)/$(PackageVersion)/</ArtifactsNetCoreAppBundlePath>
127+
</PropertyGroup>
128+
129+
<ItemGroup>
130+
<_BundleAssembliesToCopy Include="$(ArtifactsNetCoreAppBundlePath)*.dll" />
131+
<ResolvedFileToPublish Remove="@(_BundleAssembliesToCopy)" MatchOnMetadata="Filename" />
132+
</ItemGroup>
133+
</Target>
134+
135+
<!--
136+
For TestReadyToRun, each crossgen'd assembly needs to reference the whole
137+
framework. For this, it looks at the contents of the same list that contains
138+
all the assemblies we're going to R2R-compile. However, since we removed those
139+
belonging to the framework we have ready to use in the previous target, then
140+
the references list generated in _PrepareForReadyToRunCompilation is incomplete.
141+
So, we add those missing assemblies only to the references list in this target.
142+
-->
143+
<Target Name="AddExistingR2RBinariesReferencesForCrossgen2"
144+
Condition="'$(TestReadyToRun)' == 'true'"
145+
AfterTargets="_PrepareForReadyToRunCompilation">
146+
<ItemGroup>
147+
<_ReadyToRunAssembliesToReference Include="@(_BundleAssembliesToCopy)" />
148+
</ItemGroup>
149+
</Target>
150+
151+
<!--
152+
For TestReadyToRun, debugging binaries bloat the test sizes way too much and
153+
makes the Helix machines run out of disk. Since we don't need them for the
154+
TestReadyToRun test runs, we remove them from the list that is later on copied
155+
to the final location.
156+
-->
157+
<Target Name="RemoveDbgBinsFromTestR2ROutput"
158+
Condition="'$(TestReadyToRun)' == 'true'"
159+
BeforeTargets="_CopyFilesMarkedCopyLocal">
160+
<ItemGroup>
161+
<ReferenceCopyLocalPaths
162+
Remove="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dbg'))" />
163+
</ItemGroup>
164+
</Target>
165+
166+
<!--
167+
Very similarly to the previous target, we need to get rid of the debugging
168+
binaries from the publishing directory as well.
169+
-->
170+
<Target Name="RemoveDbgBinsFromTestR2RPublish"
171+
Condition="'$(TestReadyToRun)' == 'true'"
172+
BeforeTargets="_CopyResolvedFilesToPublishPreserveNewest">
173+
<ItemGroup>
174+
<_ResolvedFileToPublishPreserveNewest
175+
Remove="@(_ResolvedFileToPublishPreserveNewest->WithMetadataValue('Extension', '.dbg'))" />
176+
</ItemGroup>
177+
</Target>
178+
179+
<!--
180+
As explained in Target 'ExcludeExistingR2RBinaries' up above, for TestReadyToRun
181+
we need the fully R2R-compiled framework, but we already have it elsewhere. So,
182+
once the test's specific stuff is constructed, we copy the R2R-compiled framework
183+
to the test's self-contained directory so the test can use it when called.
184+
-->
185+
<Target Name="CopyExistingR2RBinaries"
186+
Condition="'$(TestReadyToRun)' == 'true'"
187+
AfterTargets="_CopyResolvedFilesToPublishAlways">
188+
189+
<Copy SourceFiles="@(_BundleAssembliesToCopy)"
190+
DestinationFolder="$(PublishDir)"
191+
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
192+
Retries="$(CopyRetryCount)"
193+
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
194+
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
195+
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)" />
196+
197+
</Target>
198+
199+
<!--
200+
There are a few tests that need a 'live-ref-pack', which is missing from the
201+
publish directory in TestReadyToRun builds. This target copies it there.
202+
-->
203+
<Target Name="CopyLiveRefPackIfPresent"
204+
Condition="'$(TestReadyToRun)' == 'true'"
205+
AfterTargets="CopyExistingR2RBinaries">
206+
207+
<ItemGroup>
208+
<OutDirLiveRefPackFiles Include="$(OutDir)live-ref-pack/*" />
209+
</ItemGroup>
210+
211+
<Copy SourceFiles="@(OutDirLiveRefPackFiles)"
212+
DestinationFolder="$(PublishDir)live-ref-pack"
213+
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
214+
Retries="$(CopyRetryCount)"
215+
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
216+
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
217+
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)" />
218+
219+
</Target>
220+
109221
<Target Name="__UpdateExcludedAssembliesFromSingleFile"
110222
Inputs="ExcludeFromSingleFile"
111223
Outputs="ResolvedFileToPublish"

src/installer/pkg/sfx/bundle/Microsoft.NETCore.App.Bundle.bundleproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
<ItemGroup>
2727
<BundleComponentReference Include="../Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj" />
28-
<BundleComponentReference Include="../installers/dotnet-hostfxr.proj" />
29-
<BundleComponentReference Include="../installers/dotnet-host.proj" />
28+
<BundleComponentReference Include="../installers/dotnet-hostfxr.proj" Condition="'$(TestReadyToRun)' != 'true'" />
29+
<BundleComponentReference Include="../installers/dotnet-host.proj" Condition="'$(TestReadyToRun)' != 'true'" />
3030
</ItemGroup>
3131

3232
<Target Name="PublishToDisk">

src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ public static int Main(string[] args)
3030
// The current RemoteExecutor implementation is not compatible with the SingleFileTestRunner.
3131
Environment.SetEnvironmentVariable("DOTNET_REMOTEEXECUTOR_SUPPORTED", "0");
3232

33+
// To detect ReadyToRun testing mode, we set a constant in
34+
// eng/testing/tests.singlefile.targets, which we use in the following
35+
// preprocessor directive. In the case that it is defined, we set an
36+
// environment variable that we consume later to implement
37+
// PlatformDetection.IsReadyToRunCompiled. This last value is used for the
38+
// [ActiveIssue] annotations designed to exclude tests from running.
39+
40+
#if TEST_READY_TO_RUN_COMPILED
41+
Environment.SetEnvironmentVariable("TEST_READY_TO_RUN_MODE" ,"1");
42+
#endif
43+
3344
var diagnosticSink = new ConsoleDiagnosticMessageSink();
3445
var testsFinished = new TaskCompletionSource();
3546
var testSink = new TestMessageSink();

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly()
211211
public static bool HasHostExecutable => HasAssemblyFiles; // single-file don't have a host
212212
public static bool IsSingleFile => !HasAssemblyFiles;
213213

214+
public static bool IsReadyToRunCompiled => Environment.GetEnvironmentVariable("TEST_READY_TO_RUN_MODE") == "1";
215+
214216
private static volatile Tuple<bool> s_lazyNonZeroLowerBoundArraySupported;
215217
public static bool IsNonZeroLowerBoundArraySupported
216218
{

src/libraries/Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
<EnableCoverageSupport Condition="'$(ContinuousIntegrationBuild)' != 'true'">true</EnableCoverageSupport>
8686
</PropertyGroup>
8787

88+
<PropertyGroup Condition="'$(TestReadyToRun)' == 'true'">
89+
<UseLocalAppHostPack>true</UseLocalAppHostPack>
90+
</PropertyGroup>
91+
8892
<!-- To enable the interpreter for mono desktop, we need to pass an env switch -->
8993
<PropertyGroup>
9094
<MonoEnvOptions Condition="'$(MonoEnvOptions)' == '' and '$(TargetsMobile)' != 'true' and '$(MonoForceInterpreter)' == 'true'">--interpreter</MonoEnvOptions>

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/EnumTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ public void GetValues_EnumTypeNotEnum_ThrowsArgumentException(Type enumType)
15991599
private class ClassWithEnumConstraint<T> where T : Enum { }
16001600

16011601
[Fact]
1602+
[ActiveIssue("https://github.com/dotnet/runtime/issues/94189", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
16021603
public void EnumConstraint_ThrowsArgumentException()
16031604
{
16041605
Type genericArgumentWithEnumConstraint = typeof(ClassWithEnumConstraint<>).GetGenericArguments()[0];

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/JitInfoTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void JitInfoIsNotPopulated()
100100

101101
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
102102
[SkipOnMono("Mono does not track thread specific JIT information")]
103+
[ActiveIssue("https://github.com/dotnet/runtime/issues/94189", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
103104
public void JitInfoCurrentThreadIsPopulated()
104105
{
105106
TimeSpan t1_beforeCompilationTime = TimeSpan.Zero;

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Type/TypeTests.Get.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static IEnumerable<object[]> GetInterface_TestData()
5555

5656
[Theory]
5757
[MemberData(nameof(GetInterface_TestData))]
58+
[ActiveIssue("https://github.com/dotnet/runtime/issues/94189", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
5859
public void GetInterface_Invoke_ReturnsExpected(Type type, string name, bool ignoreCase, Type expected)
5960
{
6061
if (!ignoreCase)

0 commit comments

Comments
 (0)