Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable libraries testing #900

Merged
merged 25 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions eng/pipelines/runtimelab/runtimelab-post-build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ parameters:

steps:
- ${{ if ne(parameters.archType, 'arm64') }}:

- ${{ if eq(parameters.buildConfig, 'Release') }}:
- script: $(Build.SourcesDirectory)/build$(scriptExt) libs.tests -c Release -test
displayName: Build and run libraries tests

# Build coreclr native test output
- ${{ if eq(parameters.osGroup, 'windows') }}:
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) nativeaot $(buildConfigUpper) ${{ parameters.archType }} /p:NativeAotMultimodule=true /p:SmokeTestsOnly=${{ parameters.smokeTestsOnly }}
Expand Down
81 changes: 81 additions & 0 deletions eng/testing/default.rd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<Directives>
<Application>
<!-- xunit will reflect on these to process certain InlineDataAttributes -->
<Assembly Name="System.Linq">
<Type Name="System.Linq.Enumerable">
<Method Name="Cast">
<GenericArgument Name="System.Char, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Char, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Boolean, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Boolean, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.SByte, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.SByte, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Int16, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Int16, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.UInt16, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.UInt16, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.UInt32, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.UInt32, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Int64, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Int64, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.UInt64, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.UInt64, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Single, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Single, System.Private.CoreLib" />
</Method>
<Method Name="Cast">
<GenericArgument Name="System.Double, System.Private.CoreLib" />
</Method>
<Method Name="ToArray">
<GenericArgument Name="System.Double, System.Private.CoreLib" />
</Method>
</Type>
</Assembly>
</Application>
</Directives>
21 changes: 20 additions & 1 deletion eng/testing/tests.singlefile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,33 @@
<RunScriptCommand Condition="'$(TargetOS)' != 'windows'">chmod +rwx $(AssemblyName) &amp;&amp; ./$(AssemblyName)</RunScriptCommand>
</PropertyGroup>

<PropertyGroup>
<PropertyGroup Condition="'$(ClrNativeAot)' != 'true'">
<PublishSingleFile>true</PublishSingleFile>
<UseAppHost>true</UseAppHost>
<SelfContained>true</SelfContained>
<SingleFileHostSourcePath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(TargetOS).$(TargetArchitecture).$(Configuration)', 'corehost'))/singlefilehost</SingleFileHostSourcePath>
<SingleFileHostSourcePath Condition="'$(TargetOS)' == 'windows'">$(SingleFileHostSourcePath).exe</SingleFileHostSourcePath>
</PropertyGroup>

<PropertyGroup Condition="'$(ClrNativeAot)' == 'true'">
<IlcPath>$(TestNativeAotCompilerRootPath)</IlcPath>
<PlatformTarget>$(TargetArchitecture)</PlatformTarget>
<SelfContained>true</SelfContained>
<NoWarn>$(NoWarn);IL9700;IL9701;IL1005</NoWarn>
</PropertyGroup>

<Import Project="$(IlcPath)\build\Microsoft.DotNet.ILCompiler.targets" Condition="'$(ClrNativeAot)' == 'true'" />

<ItemGroup Condition="'$(ClrNativeAot)' == 'true'">
<RdXmlFile Include="$(MSBuildThisFileDirectory)default.rd.xml" />

<!-- Tests are doing private reflection. -->
<IlcArg Include="--nometadatablocking" />

<!-- xunit calls MakeGenericType to check if something is IEquatable -->
<IlcArg Include="--feature:System.Reflection.IsTypeConstructionEagerlyValidated=false" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(CommonTestPath)SingleFileTestRunner\SingleFileTestRunner.cs"
Link="Common\SingleFileTestRunner\SingleFileTestRunner.cs" />
Expand Down
8 changes: 7 additions & 1 deletion eng/testing/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<RunScriptHost Condition="'$(TargetOS)' != 'windows'">$(RunScriptHostDir)dotnet</RunScriptHost>
</PropertyGroup>

<PropertyGroup>
<TestSingleFile Condition="'$(ClrNativeAot)' == 'true'">true</TestSingleFile>
</PropertyGroup>

<PropertyGroup>
<ArchiveTestsAfterTargets>PrepareForRun</ArchiveTestsAfterTargets>

Expand Down Expand Up @@ -103,10 +107,12 @@
</PropertyGroup>

<!-- Invoke the run script with the test host as the runtime path. -->
<!-- We set HELIX_WORKITEM_PAYLOAD to an empty string to prevent the runner script from exiting with code 0 if there's failures -->
<Exec Command="$(RunTestsCommand)"
ContinueOnError="true"
IgnoreExitCode="true"
IgnoreStandardErrorWarningFormat="true">
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="HELIX_WORKITEM_PAYLOAD=;">
<Output PropertyName="TestRunExitCode" TaskParameter="ExitCode" />
</Exec>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,13 @@ The .NET Foundation licenses this file to you under the MIT license.

<MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeBinary)))" />

<Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(TargetOS)' != 'windows' and '$(NativeLib)' != 'Static'" />
<!-- https://github.com/dotnet/runtimelab/issues/956 - we IgnoreStandardErrorWarningFormat on macOS because there's a lot of warnings -->
<PropertyGroup>
<_IgnoreLinkerWarnings>false</_IgnoreLinkerWarnings>
<_IgnoreLinkerWarnings Condition="'$(TargetOS)' == 'OSX'">true</_IgnoreLinkerWarnings>
</PropertyGroup>

<Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(TargetOS)' != 'windows' and '$(NativeLib)' != 'Static'" IgnoreStandardErrorWarningFormat="$(_IgnoreLinkerWarnings)" />
<Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(TargetOS)' != 'windows' and '$(NativeLib)' == 'Static'" />

<WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(CustomLinkerArg)" Overwrite="true" Encoding="utf-8" Condition="'$(TargetOS)' == 'windows' and '$(NativeLib)' != 'Static'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public static bool IsDrawingSupported

public static bool IsInvokingStaticConstructorsSupported => !IsNativeAot;

public static bool IsMetadataUpdateSupported => !IsNativeAot;

// System.Security.Cryptography.Xml.XmlDsigXsltTransform.GetOutput() relies on XslCompiledTransform which relies
// heavily on Reflection.Emit
public static bool IsXmlDsigXsltTransformSupported => !PlatformDetection.IsInAppContainer;
Expand Down Expand Up @@ -269,7 +271,7 @@ private static Version GetICUVersion()
int version = 0;
try
{
Type interopGlobalization = Type.GetType("Interop+Globalization");
Type interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Interop type exist both in the current assembly and in CoreLib. Apparently we're supposed to try in both. The reflection stack is not structured to fix this in straighforward way. I just really don't care.

if (interopGlobalization != null)
{
MethodInfo methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static);
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
<ASPNETCoreAppPackageRuntimePath>$(ArtifactsBinDir)pkg\aspnetcoreapp\lib</ASPNETCoreAppPackageRuntimePath>

<TestHostRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'testhost', '$(BuildSettings)'))</TestHostRootPath>
<TestNativeAotCompilerRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'testaotc', '$(BuildSettings)'))</TestNativeAotCompilerRootPath>
<NETCoreAppTestSharedFrameworkPath>$([MSBuild]::NormalizeDirectory('$(TestHostRootPath)', 'shared', '$(MicrosoftNetCoreAppFrameworkName)', '$(ProductVersion)'))</NETCoreAppTestSharedFrameworkPath>
<NETCoreAppTestSharedFrameworkPath Condition="'$(ClrNativeAot)' == 'true'">$([MSBuild]::NormalizeDirectory('$(TestNativeAotCompilerRootPath)', 'framework'))</NETCoreAppTestSharedFrameworkPath>

<MicrosoftNetCoreAppRefPackDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'microsoft.netcore.app.ref'))</MicrosoftNetCoreAppRefPackDir>
<MicrosoftNetCoreAppRefPackRefDir>$([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRefPackDir)', 'ref', '$(NetCoreAppCurrent)'))</MicrosoftNetCoreAppRefPackRefDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<TestRuntime>true</TestRuntime>
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(TargetOS)' == 'Browser'">true</DebuggerSupport>
</PropertyGroup>
<ItemGroup>
<RdXmlFile Include="default.rd.xml" />
</ItemGroup>
<ItemGroup>
<!-- Common Collections tests -->
<Compile Include="$(CommonTestPath)System\Collections\CollectionAsserts.cs"
Expand Down
154 changes: 154 additions & 0 deletions src/libraries/System.Collections/tests/default.rd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<Directives>
<Application>
<Assembly Name="System.Collections.Tests">
<Type Name="System.Collections.Tests.BitArray_GetSetTests">
<Method Name="CopyTo_Size_Invalid" Dynamic="Required All">
<GenericArgument Name="System.Boolean, System.Private.CoreLib" />
</Method>
<Method Name="CopyTo_Size_Invalid" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="CopyTo_Size_Invalid" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>

<Method Name="CopyTo" Dynamic="Required All">
<GenericArgument Name="System.Boolean, System.Private.CoreLib" />
</Method>
<Method Name="CopyTo" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="CopyTo" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
</Type>

<Type Name="System.Collections.Generic.Tests.EqualityComparerTests">
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int16Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.SByteEnum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Collections.Tests.NonEquatableValueType, System.Collections.Tests" />
</Method>

<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int16Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.SByteEnum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
<Method Name="EqualsTest" Dynamic="Required All">
<GenericArgument Name="System.Collections.Tests.NonEquatableValueType, System.Collections.Tests" />
</Method>

<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Int16Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.SByteEnum, System.Collections.Tests" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableEquals" Dynamic="Required All">
<GenericArgument Name="System.Collections.Tests.NonEquatableValueType, System.Collections.Tests" />
</Method>

<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Int16Enum, System.Collections.Tests" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.SByteEnum, System.Collections.Tests" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
<Method Name="GetHashCodeTest" Dynamic="Required All">
<GenericArgument Name="System.Collections.Tests.NonEquatableValueType, System.Collections.Tests" />
</Method>

<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Byte, System.Private.CoreLib" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Int32, System.Private.CoreLib" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Int16Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.SByteEnum, System.Collections.Tests" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
<Method Name="NullableGetHashCode" Dynamic="Required All">
<GenericArgument Name="System.Collections.Tests.NonEquatableValueType, System.Collections.Tests" />
</Method>
</Type>

<Type Name="System.Collections.Generic.Tests.ComparerTests">
<Method Name="MostComparisons" Dynamic="Required All">
<GenericArgument Name="System.UInt64Enum, System.Collections.Tests" />
</Method>
<Method Name="MostComparisons" Dynamic="Required All">
<GenericArgument Name="System.Int32Enum, System.Collections.Tests" />
</Method>
<Method Name="MostComparisons" Dynamic="Required All">
<GenericArgument Name="System.UInt32Enum, System.Collections.Tests" />
</Method>
<Method Name="MostComparisons" Dynamic="Required All">
<GenericArgument Name="System.Int64Enum, System.Collections.Tests" />
</Method>
</Type>
</Assembly>
</Application>
</Directives>
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public void PathWithReservedDeviceNameAsPath_ReturnsFalse(string component)
Assert.False(Exists(component));
}

[ActiveIssue("https://github.com/dotnet/runtimelab/issues/901" /* NativeAot */)]
[Theory,
MemberData(nameof(UncPathsWithoutShareName))]
public void UncPathWithoutShareNameAsPath_ReturnsFalse(string component)
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.IO.FileSystem/tests/File/Exists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public void PathWithReservedDeviceNameAsPath_ReturnsFalse(string component)
Assert.False(Exists(component));
}

[ActiveIssue("https://github.com/dotnet/runtimelab/issues/901" /* NativeAot */)]
[Theory,
MemberData(nameof(UncPathsWithoutShareName))]
public void UncPathWithoutShareNameAsPath_ReturnsFalse(string component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<RdXmlFile Include="default.rd.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)System\EnumTypes.cs"
Link="Common\System\EnumTypes.cs" />
Expand Down
Loading