Skip to content

Commit

Permalink
Fix System.Numerics.Vectors tests on iOS and other FullAOT targets (#…
Browse files Browse the repository at this point in the history
…60335)

* Fix System.Numerics.Vectors tests on iOS and other FullAOT targets

Instead of using dynamic we can use explicit type checks which don't require runtime code generation.
Also fixed running just a subset of xunit tests on Apple targets in tests.mobile.targets.

* Disable tests that fail on x86 due to a Mono runtime asserts

See #60347
  • Loading branch information
akoeplinger authored Oct 13, 2021
1 parent 5b1ebf7 commit 51c16ae
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 30 deletions.
6 changes: 6 additions & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
<AdditionalXHarnessArguments Condition="'$(XUnitClassName)' != ''">$(AdditionalXHarnessArguments) --arg=-c=$(XUnitClassName)</AdditionalXHarnessArguments>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator'">
<!-- Pass the -m or -c flag along to the app bundle, note that due to the double hyphen this needs to be the last argument -->
<AdditionalXHarnessArguments Condition="'$(XUnitMethodName)' != ''">$(AdditionalXHarnessArguments) -- -m=$(XUnitMethodName)</AdditionalXHarnessArguments>
<AdditionalXHarnessArguments Condition="'$(XUnitClassName)' != ''">$(AdditionalXHarnessArguments) -- -c=$(XUnitClassName)</AdditionalXHarnessArguments>
</PropertyGroup>

<UsingTask Condition="'$(RunAOTCompilation)' == 'true'" TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<Import Condition="'$(RunAOTCompilation)' == 'true'" Project="$(MonoAOTCompilerDir)MonoAOTCompiler.props" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public static partial class PlatformDetection
public static bool IsNotArm64Process => !IsArm64Process;
public static bool IsArmOrArm64Process => IsArmProcess || IsArm64Process;
public static bool IsNotArmNorArm64Process => !IsArmOrArm64Process;
public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
public static bool IsNotX86Process => !IsX86Process;
public static bool IsArgIteratorSupported => IsMonoRuntime || (IsWindows && IsNotArmProcess);
public static bool IsArgIteratorNotSupported => !IsArgIteratorSupported;
public static bool Is32BitProcess => IntPtr.Size == 4;
Expand Down
40 changes: 40 additions & 0 deletions src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,10 @@ private void TestToString<T>(string format, IFormatProvider provider) where T :
[Fact]
public void AdditionInt64() { TestAddition<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AdditionSingle() { TestAddition<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AdditionDouble() { TestAddition<double>(); }
private void TestAddition<T>() where T : struct
{
Expand Down Expand Up @@ -1023,8 +1025,10 @@ private void TestAdditionOverflow<T>() where T : struct
[Fact]
public void SubtractionInt64() { TestSubtraction<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void SubtractionSingle() { TestSubtraction<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void SubtractionDouble() { TestSubtraction<double>(); }
private void TestSubtraction<T>() where T : struct
{
Expand Down Expand Up @@ -1088,8 +1092,10 @@ private void TestSubtractionOverflow<T>() where T : struct
[Fact]
public void MultiplicationInt64() { TestMultiplication<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationSingle() { TestMultiplication<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationDouble() { TestMultiplication<double>(); }
private void TestMultiplication<T>() where T : struct
{
Expand Down Expand Up @@ -1122,8 +1128,10 @@ private void TestMultiplication<T>() where T : struct
[Fact]
public void MultiplicationWithScalarInt64() { TestMultiplicationWithScalar<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationWithScalarSingle() { TestMultiplicationWithScalar<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationWithScalarDouble() { TestMultiplicationWithScalar<double>(); }
private void TestMultiplicationWithScalar<T>() where T : struct
{
Expand Down Expand Up @@ -1164,8 +1172,10 @@ private void TestMultiplicationWithScalar<T>() where T : struct
[Fact]
public void DivisionInt64() { TestDivision<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DivisionSingle() { TestDivision<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DivisionDouble() { TestDivision<double>(); }
private void TestDivision<T>() where T : struct
{
Expand Down Expand Up @@ -1224,8 +1234,10 @@ private void TestDivisionByZeroException<T>() where T : struct
[Fact]
public void UnaryMinusInt64() { TestUnaryMinus<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void UnaryMinusSingle() { TestUnaryMinus<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void UnaryMinusDouble() { TestUnaryMinus<double>(); }
private void TestUnaryMinus<T>() where T : struct
{
Expand Down Expand Up @@ -1424,8 +1436,10 @@ private void TestBitwiseAndNot<T>() where T : struct
[Fact]
public void VectorGreaterThanInt64() { TestVectorGreaterThan<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void VectorGreaterThanSingle() { TestVectorGreaterThan<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void VectorGreaterThanDouble() { TestVectorGreaterThan<double>(); }
private void TestVectorGreaterThan<T>() where T : struct
{
Expand Down Expand Up @@ -1461,8 +1475,10 @@ private void TestVectorGreaterThan<T>() where T : struct
[Fact]
public void GreaterThanOrEqualInt64() { TestVectorGreaterThanOrEqual<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void GreaterThanOrEqualSingle() { TestVectorGreaterThanOrEqual<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void GreaterThanOrEqualDouble() { TestVectorGreaterThanOrEqual<double>(); }
private void TestVectorGreaterThanOrEqual<T>() where T : struct
{
Expand Down Expand Up @@ -1714,8 +1730,10 @@ private void TestVectorGreaterThanOrEqualAll<T>() where T : struct
[Fact]
public void LessThanInt64() { TestVectorLessThan<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanSingle() { TestVectorLessThan<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanDouble() { TestVectorLessThan<double>(); }
private void TestVectorLessThan<T>() where T : struct
{
Expand Down Expand Up @@ -1751,8 +1769,10 @@ private void TestVectorLessThan<T>() where T : struct
[Fact]
public void LessThanOrEqualInt64() { TestVectorLessThanOrEqual<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanOrEqualSingle() { TestVectorLessThanOrEqual<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanOrEqualDouble() { TestVectorLessThanOrEqual<double>(); }
private void TestVectorLessThanOrEqual<T>() where T : struct
{
Expand Down Expand Up @@ -1788,8 +1808,10 @@ private void TestVectorLessThanOrEqual<T>() where T : struct
[Fact]
public void LessThanAnyInt64() { TestVectorLessThanAny<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanAnySingle() { TestVectorLessThanAny<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void LessThanAnyDouble() { TestVectorLessThanAny<double>(); }
private void TestVectorLessThanAny<T>() where T : struct
{
Expand Down Expand Up @@ -2114,8 +2136,10 @@ private void TestVectorEqualsAll<T>() where T : struct
[Fact]
public void ConditionalSelectInt64() { TestConditionalSelect<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void ConditionalSelectSingle() { TestConditionalSelect<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void ConditionalSelectDouble() { TestConditionalSelect<double>(); }
private void TestConditionalSelect<T>() where T : struct
{
Expand Down Expand Up @@ -2166,8 +2190,10 @@ private void TestConditionalSelect<T>() where T : struct
[Fact]
public void DotProductInt64() { TestDotProduct<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DotProductSingle() { TestDotProduct<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DotProductDouble() { TestDotProduct<double>(); }
private void TestDotProduct<T>() where T : struct
{
Expand Down Expand Up @@ -2202,8 +2228,10 @@ private void TestDotProduct<T>() where T : struct
[Fact]
public void MaxInt64() { TestMax<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MaxSingle() { TestMax<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MaxDouble() { TestMax<double>(); }
private void TestMax<T>() where T : struct
{
Expand Down Expand Up @@ -2238,8 +2266,10 @@ private void TestMax<T>() where T : struct
[Fact]
public void MinInt64() { TestMin<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MinSingle() { TestMin<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MinDouble() { TestMin<double>(); }
private void TestMin<T>() where T : struct
{
Expand Down Expand Up @@ -2274,8 +2304,10 @@ private void TestMin<T>() where T : struct
[Fact]
public void SquareRootInt64() { TestSquareRoot<long>(-1); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void SquareRootSingle() { TestSquareRoot<float>(6); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void SquareRootDouble() { TestSquareRoot<double>(15); }
private void TestSquareRoot<T>(int precision = -1) where T : struct, IEquatable<T>
{
Expand Down Expand Up @@ -2368,8 +2400,10 @@ public void FloorDouble()
[Fact]
public void AbsInt64() { TestAbs<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AbsSingle() { TestAbs<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AbsDouble() { TestAbs<double>(); }
private void TestAbs<T>() where T : struct
{
Expand Down Expand Up @@ -2406,8 +2440,10 @@ private void TestAbs<T>() where T : struct
[Fact]
public void MultiplicationReflectionInt64() { TestMultiplicationReflection<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationReflectionSingle() { TestMultiplicationReflection<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void MultiplicationReflectionDouble() { TestMultiplicationReflection<double>(); }
private void TestMultiplicationReflection<T>() where T : struct
{
Expand Down Expand Up @@ -2443,8 +2479,10 @@ private void TestMultiplicationReflection<T>() where T : struct
[Fact]
public void AdditionReflectionInt64() { TestAdditionReflection<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AdditionReflectionSingle() { TestAdditionReflection<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void AdditionReflectionDouble() { TestAdditionReflection<double>(); }
private void TestAdditionReflection<T>() where T : struct
{
Expand Down Expand Up @@ -2480,8 +2518,10 @@ private void TestAdditionReflection<T>() where T : struct
[Fact]
public void DivisionReflectionInt64() { TestDivisionReflection<long>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DivisionReflectionSingle() { TestDivisionReflection<float>(); }
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
public void DivisionReflectionDouble() { TestDivisionReflection<double>(); }
private void TestDivisionReflection<T>() where T : struct
{
Expand Down
Loading

0 comments on commit 51c16ae

Please sign in to comment.