forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding linker correctness tests to test library annotations for the l…
…inker (dotnet#37618)
- Loading branch information
Showing
12 changed files
with
222 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
parameters: | ||
archType: '' | ||
|
||
steps: | ||
# Execute tests | ||
- script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci -arch ${{ parameters.archType }} $(_osParameter) -s libs.tests -c $(_BuildConfig) /p:TestAssemblies=false /p:TestTrimming=true $(_officialBuildParameter) $(_crossBuildPropertyArg) /bl:$(Build.SourcesDirectory)/artifacts/log/$(buildConfigUpper)/TrimmingTests.binlog | ||
displayName: Run Trimming Tests |
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,39 @@ | ||
# The purpose of this pipeline is to exercise local developer workflow in the consolidated | ||
# runtime repo. In particular, it is supposed to run the root "build" script just like any | ||
# normal developer normally would and monitor regressions w.r.t. this fundamental scenario. | ||
|
||
trigger: | ||
batch: true | ||
branches: | ||
include: | ||
- master | ||
- release/*.* | ||
|
||
pr: | ||
branches: | ||
include: | ||
- master | ||
- release/*.* | ||
|
||
jobs: | ||
# | ||
# Checkout repository | ||
# | ||
- template: /eng/pipelines/common/checkout-job.yml | ||
|
||
# | ||
# Build Release config vertical for Windows, Linux, Linux musl and OSX | ||
# | ||
- template: /eng/pipelines/common/platform-matrix.yml | ||
parameters: | ||
jobTemplate: /eng/pipelines/common/global-build-job.yml | ||
buildConfig: release | ||
platforms: | ||
- Windows_NT_x64 | ||
- OSX_x64 | ||
- Linux_x64 | ||
jobParameters: | ||
testGroup: innerloop | ||
nameSuffix: Runtime_Release | ||
buildArgs: -s clr+libs -c $(_BuildConfig) | ||
extraStepsTemplate: /eng/pipelines/libraries/execute-trimming-tests-steps.yml |
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,10 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
<_TrimmerDefaultAction>link</_TrimmerDefaultAction> | ||
<SelfContained>true</SelfContained> | ||
<EnableTargetingPackDownload>false</EnableTargetingPackDownload> | ||
<PlatformManifestFile /> | ||
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> | ||
</PropertyGroup> | ||
</Project> |
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,24 @@ | ||
<Project> | ||
<Target Name="RestoreProject"> | ||
<MSBuild Projects="$(MSBuildProjectFullPath)" | ||
Properties="Configuration=$(Configuration)" | ||
Targets="Restore" /> | ||
</Target> | ||
|
||
<Target Name="AddFrameworkReference"> | ||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.NETCore.App" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="UpdateRuntimePack" | ||
DependsOnTargets="AddFrameworkReference;ResolveFrameworkReferences"> | ||
<ItemGroup> | ||
<ResolvedRuntimePack Update="@(ResolvedRuntimePack)" PackageDirectory="$(RuntimePackDir)" /> | ||
<ResolvedTargetingPack Update="@(ResolvedTargetingPack)" Path="$(TargetingPackDir)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="PublishTrimmed" DependsOnTargets="RestoreProject;UpdateRuntimePack;Publish" /> | ||
|
||
</Project> |
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>{NetCoreAppCurrent}</TargetFramework> | ||
<RuntimeIdentifier>{RuntimeIdentifier}</RuntimeIdentifier> | ||
<RuntimePackDir>{RuntimePackDir}</RuntimePackDir> | ||
<TargetingPackDir>{TargetingPackDir}</TargetingPackDir> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,97 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<TrimmingTestDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'trimmingTests'))</TrimmingTestDir> | ||
<TrimmingTestProjectsDir>$([MSBuild]::NormalizeDirectory('$(TrimmingTestDir)', 'projects'))</TrimmingTestProjectsDir> | ||
<TestDotNetPath>$([MSBuild]::NormalizePath('$(DotNetRoot)', 'dotnet'))</TestDotNetPath> | ||
<ProjectTemplate>$(MSBuildThisFileDirectory)project.csproj.template</ProjectTemplate> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<TestConsoleAppSourceFiles Include="$(MSBuildProjectDirectory)\*.cs" /> | ||
|
||
<TestSupportFiles Include="$(MSBuildThisFileDirectory)SupportFiles\Directory.Build.*"> | ||
<DestinationFolder>$(TrimmingTestDir)</DestinationFolder> | ||
</TestSupportFiles> | ||
</ItemGroup> | ||
|
||
<Target Name="CreateTestDir" | ||
Inputs="@(TestSupportFiles)" | ||
Outputs="@(TestSupportFiles->'%(DestinationFolder)\%(FileName)%(Extension)')"> | ||
<MakeDir Directories="%(TestSupportFiles.DestinationFolder)" /> | ||
<Copy SourceFiles="@(TestSupportFiles)" DestinationFolder="%(TestSupportFiles.DestinationFolder)" /> | ||
</Target> | ||
|
||
<Target Name="GetTestConsoleApps"> | ||
<ItemGroup> | ||
<TestConsoleAppSourceFiles> | ||
<ProjectDir>$([MSBuild]::NormalizeDirectory('$(TrimmingTestProjectsDir)', '$(MSBuildProjectName)', '%(Filename)', '$(PackageRID)'))</ProjectDir> | ||
<TestRuntimeIdentifier>$(PackageRID)</TestRuntimeIdentifier> | ||
</TestConsoleAppSourceFiles> | ||
<!-- We need to separate Item metadata declaration in two in order to be able to use ProjectDir and TestRuntimeIdentifier bellow --> | ||
<TestConsoleAppSourceFiles> | ||
<ProjectFile>%(ProjectDir)project.csproj</ProjectFile> | ||
<TestCommand>$([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish', 'project'))</TestCommand> | ||
<TestExecutionDirectory>$([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish'))</TestExecutionDirectory> | ||
<RuntimePackDirectory>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'microsoft.netcore.app.runtime.%(TestRuntimeIdentifier)', '$(Configuration)'))</RuntimePackDirectory> | ||
</TestConsoleAppSourceFiles> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<TestConsoleApps Include="@(TestConsoleAppSourceFiles->'%(ProjectFile)')"> | ||
<ProjectCompileItems>%(Identity)</ProjectCompileItems> | ||
</TestConsoleApps> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="GenerateProjects" | ||
DependsOnTargets="GetTestConsoleApps;CreateTestDir" | ||
Inputs="@(TestConsoleAppSourceFiles);$(ProjectTemplate);@(TestSupportFiles)" | ||
Outputs="%(TestConsoleApps.Identity)"> | ||
<PropertyGroup> | ||
<_projectDir>%(TestConsoleApps.ProjectDir)\</_projectDir> | ||
<_projectFile>%(TestConsoleApps.ProjectFile)</_projectFile> | ||
<_projectSourceFile>%(TestConsoleApps.ProjectCompileItems)</_projectSourceFile> | ||
</PropertyGroup> | ||
|
||
<MakeDir Directories="$(_projectDir)" /> | ||
<WriteLinesToFile File="$(_projectFile)" | ||
Lines="$([System.IO.File]::ReadAllText('$(ProjectTemplate)').Replace('{NetCoreAppCurrent}', '$(NetCoreAppCurrent)').Replace('{RuntimePackDir}', '%(TestConsoleApps.RuntimePackDirectory)').Replace('{TargetingPackDir}','$(MicrosoftNetCoreAppRefPackDir)').Replace('{RuntimeIdentifier}','%(TestConsoleApps.TestRuntimeIdentifier)'))" | ||
Overwrite="true" /> | ||
<Copy SourceFiles="$(_projectSourceFile)" | ||
DestinationFolder="$(_projectDir)" /> | ||
<Message Text="Generated $(_projectFile)" /> | ||
</Target> | ||
|
||
<Target Name="PublishTrimmedProjects" | ||
DependsOnTargets="GenerateProjects"> | ||
<PropertyGroup> | ||
<TestRestoreCommand>"$(TestDotNetPath)"</TestRestoreCommand> | ||
<TestRestoreCommand>$(TestRestoreCommand) msbuild /t:PublishTrimmed</TestRestoreCommand> | ||
<TestRestoreCommand>$(TestRestoreCommand) /nr:false</TestRestoreCommand> | ||
<TestRestoreCommand>$(TestRestoreCommand) /warnaserror</TestRestoreCommand> | ||
<TestRestoreCommand>$(TestRestoreCommand) -p:configuration=Release</TestRestoreCommand> | ||
</PropertyGroup> | ||
|
||
<Exec Command="$(TestRestoreCommand)" StandardOutputImportance="Low" WorkingDirectory="%(TestConsoleApps.ProjectDir)" /> | ||
</Target> | ||
|
||
<Target Name="ExecuteApplications" | ||
DependsOnTargets="PublishTrimmedProjects" | ||
Inputs="%(TestConsoleApps.Identity)" | ||
Outputs="_unused" | ||
Condition="'$(ArchiveTests)' != 'true'"> | ||
|
||
<Message Importance="High" Text="[Trimming Tests] Running test: %(TestConsoleApps.ProjectCompileItems)..." /> | ||
<Exec IgnoreExitCode="true" Command="%(TestConsoleApps.TestCommand)" StandardOutputImportance="Low" WorkingDirectory="%(TestConsoleApps.TestExecutionDirectory)"> | ||
<Output TaskParameter="ExitCode" PropertyName="ExecutionExitCode" /> | ||
</Exec> | ||
|
||
<Error Condition="'$(ExecutionExitCode)' != '100'" Text="Error: [Failed Test]: %(TestConsoleApps.ProjectCompileItems) The Command %(TestConsoleApps.TestCommand) return a non-success exit code." /> | ||
</Target> | ||
|
||
<Target Name="Build" DependsOnTargets="ExecuteApplications" /> | ||
|
||
<!-- define test to do nothing, for this project Build does all the testing --> | ||
<Target Name="Test" DependsOnTargets="Build" /> | ||
<Target Name="VSTest" DependsOnTargets="Build" /> | ||
</Project> |
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
16 changes: 16 additions & 0 deletions
16
src/libraries/System.Runtime/tests/TrimmingTests/GenericArraySortHelperTest.cs
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,16 @@ | ||
using System; | ||
using System.Collections; | ||
|
||
class Program | ||
{ | ||
static int Main(string[] args) | ||
{ | ||
var x = new[] { 5, 4, 3, 100, 2, 1 }; | ||
var y = new[] { "a", "b", "c", "h", "d", "e" }; | ||
// This will test that GenericArraySortHelper'2 called by reflection will be kept. | ||
Array.Sort(x, y); | ||
// This will test that GenericArraySortHelper'1 called by reflection will be kept. | ||
Array.Sort(y); | ||
return 100; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/libraries/System.Runtime/tests/TrimmingTests/System.Runtime.TrimmingTests.proj
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,5 @@ | ||
<Project DefaultTargets="Build"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" /> | ||
|
||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" /> | ||
</Project> |
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