Skip to content

Commit 51c16ae

Browse files
authored
Fix System.Numerics.Vectors tests on iOS and other FullAOT targets (#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
1 parent 5b1ebf7 commit 51c16ae

File tree

4 files changed

+225
-30
lines changed

4 files changed

+225
-30
lines changed

eng/testing/tests.mobile.targets

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
<AdditionalXHarnessArguments Condition="'$(XUnitClassName)' != ''">$(AdditionalXHarnessArguments) --arg=-c=$(XUnitClassName)</AdditionalXHarnessArguments>
4343
</PropertyGroup>
4444

45+
<PropertyGroup Condition="'$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator'">
46+
<!-- 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 -->
47+
<AdditionalXHarnessArguments Condition="'$(XUnitMethodName)' != ''">$(AdditionalXHarnessArguments) -- -m=$(XUnitMethodName)</AdditionalXHarnessArguments>
48+
<AdditionalXHarnessArguments Condition="'$(XUnitClassName)' != ''">$(AdditionalXHarnessArguments) -- -c=$(XUnitClassName)</AdditionalXHarnessArguments>
49+
</PropertyGroup>
50+
4551
<UsingTask Condition="'$(RunAOTCompilation)' == 'true'" TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
4652
<Import Condition="'$(RunAOTCompilation)' == 'true'" Project="$(MonoAOTCompilerDir)MonoAOTCompiler.props" />
4753

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

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public static partial class PlatformDetection
4848
public static bool IsNotArm64Process => !IsArm64Process;
4949
public static bool IsArmOrArm64Process => IsArmProcess || IsArm64Process;
5050
public static bool IsNotArmNorArm64Process => !IsArmOrArm64Process;
51+
public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
52+
public static bool IsNotX86Process => !IsX86Process;
5153
public static bool IsArgIteratorSupported => IsMonoRuntime || (IsWindows && IsNotArmProcess);
5254
public static bool IsArgIteratorNotSupported => !IsArgIteratorSupported;
5355
public static bool Is32BitProcess => IntPtr.Size == 4;

src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs

+40
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,10 @@ private void TestToString<T>(string format, IFormatProvider provider) where T :
958958
[Fact]
959959
public void AdditionInt64() { TestAddition<long>(); }
960960
[Fact]
961+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
961962
public void AdditionSingle() { TestAddition<float>(); }
962963
[Fact]
964+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
963965
public void AdditionDouble() { TestAddition<double>(); }
964966
private void TestAddition<T>() where T : struct
965967
{
@@ -1023,8 +1025,10 @@ private void TestAdditionOverflow<T>() where T : struct
10231025
[Fact]
10241026
public void SubtractionInt64() { TestSubtraction<long>(); }
10251027
[Fact]
1028+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
10261029
public void SubtractionSingle() { TestSubtraction<float>(); }
10271030
[Fact]
1031+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
10281032
public void SubtractionDouble() { TestSubtraction<double>(); }
10291033
private void TestSubtraction<T>() where T : struct
10301034
{
@@ -1088,8 +1092,10 @@ private void TestSubtractionOverflow<T>() where T : struct
10881092
[Fact]
10891093
public void MultiplicationInt64() { TestMultiplication<long>(); }
10901094
[Fact]
1095+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
10911096
public void MultiplicationSingle() { TestMultiplication<float>(); }
10921097
[Fact]
1098+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
10931099
public void MultiplicationDouble() { TestMultiplication<double>(); }
10941100
private void TestMultiplication<T>() where T : struct
10951101
{
@@ -1122,8 +1128,10 @@ private void TestMultiplication<T>() where T : struct
11221128
[Fact]
11231129
public void MultiplicationWithScalarInt64() { TestMultiplicationWithScalar<long>(); }
11241130
[Fact]
1131+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
11251132
public void MultiplicationWithScalarSingle() { TestMultiplicationWithScalar<float>(); }
11261133
[Fact]
1134+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
11271135
public void MultiplicationWithScalarDouble() { TestMultiplicationWithScalar<double>(); }
11281136
private void TestMultiplicationWithScalar<T>() where T : struct
11291137
{
@@ -1164,8 +1172,10 @@ private void TestMultiplicationWithScalar<T>() where T : struct
11641172
[Fact]
11651173
public void DivisionInt64() { TestDivision<long>(); }
11661174
[Fact]
1175+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
11671176
public void DivisionSingle() { TestDivision<float>(); }
11681177
[Fact]
1178+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
11691179
public void DivisionDouble() { TestDivision<double>(); }
11701180
private void TestDivision<T>() where T : struct
11711181
{
@@ -1224,8 +1234,10 @@ private void TestDivisionByZeroException<T>() where T : struct
12241234
[Fact]
12251235
public void UnaryMinusInt64() { TestUnaryMinus<long>(); }
12261236
[Fact]
1237+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
12271238
public void UnaryMinusSingle() { TestUnaryMinus<float>(); }
12281239
[Fact]
1240+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
12291241
public void UnaryMinusDouble() { TestUnaryMinus<double>(); }
12301242
private void TestUnaryMinus<T>() where T : struct
12311243
{
@@ -1424,8 +1436,10 @@ private void TestBitwiseAndNot<T>() where T : struct
14241436
[Fact]
14251437
public void VectorGreaterThanInt64() { TestVectorGreaterThan<long>(); }
14261438
[Fact]
1439+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
14271440
public void VectorGreaterThanSingle() { TestVectorGreaterThan<float>(); }
14281441
[Fact]
1442+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
14291443
public void VectorGreaterThanDouble() { TestVectorGreaterThan<double>(); }
14301444
private void TestVectorGreaterThan<T>() where T : struct
14311445
{
@@ -1461,8 +1475,10 @@ private void TestVectorGreaterThan<T>() where T : struct
14611475
[Fact]
14621476
public void GreaterThanOrEqualInt64() { TestVectorGreaterThanOrEqual<long>(); }
14631477
[Fact]
1478+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
14641479
public void GreaterThanOrEqualSingle() { TestVectorGreaterThanOrEqual<float>(); }
14651480
[Fact]
1481+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
14661482
public void GreaterThanOrEqualDouble() { TestVectorGreaterThanOrEqual<double>(); }
14671483
private void TestVectorGreaterThanOrEqual<T>() where T : struct
14681484
{
@@ -1714,8 +1730,10 @@ private void TestVectorGreaterThanOrEqualAll<T>() where T : struct
17141730
[Fact]
17151731
public void LessThanInt64() { TestVectorLessThan<long>(); }
17161732
[Fact]
1733+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17171734
public void LessThanSingle() { TestVectorLessThan<float>(); }
17181735
[Fact]
1736+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17191737
public void LessThanDouble() { TestVectorLessThan<double>(); }
17201738
private void TestVectorLessThan<T>() where T : struct
17211739
{
@@ -1751,8 +1769,10 @@ private void TestVectorLessThan<T>() where T : struct
17511769
[Fact]
17521770
public void LessThanOrEqualInt64() { TestVectorLessThanOrEqual<long>(); }
17531771
[Fact]
1772+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17541773
public void LessThanOrEqualSingle() { TestVectorLessThanOrEqual<float>(); }
17551774
[Fact]
1775+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17561776
public void LessThanOrEqualDouble() { TestVectorLessThanOrEqual<double>(); }
17571777
private void TestVectorLessThanOrEqual<T>() where T : struct
17581778
{
@@ -1788,8 +1808,10 @@ private void TestVectorLessThanOrEqual<T>() where T : struct
17881808
[Fact]
17891809
public void LessThanAnyInt64() { TestVectorLessThanAny<long>(); }
17901810
[Fact]
1811+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17911812
public void LessThanAnySingle() { TestVectorLessThanAny<float>(); }
17921813
[Fact]
1814+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
17931815
public void LessThanAnyDouble() { TestVectorLessThanAny<double>(); }
17941816
private void TestVectorLessThanAny<T>() where T : struct
17951817
{
@@ -2114,8 +2136,10 @@ private void TestVectorEqualsAll<T>() where T : struct
21142136
[Fact]
21152137
public void ConditionalSelectInt64() { TestConditionalSelect<long>(); }
21162138
[Fact]
2139+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
21172140
public void ConditionalSelectSingle() { TestConditionalSelect<float>(); }
21182141
[Fact]
2142+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
21192143
public void ConditionalSelectDouble() { TestConditionalSelect<double>(); }
21202144
private void TestConditionalSelect<T>() where T : struct
21212145
{
@@ -2166,8 +2190,10 @@ private void TestConditionalSelect<T>() where T : struct
21662190
[Fact]
21672191
public void DotProductInt64() { TestDotProduct<long>(); }
21682192
[Fact]
2193+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
21692194
public void DotProductSingle() { TestDotProduct<float>(); }
21702195
[Fact]
2196+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
21712197
public void DotProductDouble() { TestDotProduct<double>(); }
21722198
private void TestDotProduct<T>() where T : struct
21732199
{
@@ -2202,8 +2228,10 @@ private void TestDotProduct<T>() where T : struct
22022228
[Fact]
22032229
public void MaxInt64() { TestMax<long>(); }
22042230
[Fact]
2231+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22052232
public void MaxSingle() { TestMax<float>(); }
22062233
[Fact]
2234+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22072235
public void MaxDouble() { TestMax<double>(); }
22082236
private void TestMax<T>() where T : struct
22092237
{
@@ -2238,8 +2266,10 @@ private void TestMax<T>() where T : struct
22382266
[Fact]
22392267
public void MinInt64() { TestMin<long>(); }
22402268
[Fact]
2269+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22412270
public void MinSingle() { TestMin<float>(); }
22422271
[Fact]
2272+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22432273
public void MinDouble() { TestMin<double>(); }
22442274
private void TestMin<T>() where T : struct
22452275
{
@@ -2274,8 +2304,10 @@ private void TestMin<T>() where T : struct
22742304
[Fact]
22752305
public void SquareRootInt64() { TestSquareRoot<long>(-1); }
22762306
[Fact]
2307+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22772308
public void SquareRootSingle() { TestSquareRoot<float>(6); }
22782309
[Fact]
2310+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
22792311
public void SquareRootDouble() { TestSquareRoot<double>(15); }
22802312
private void TestSquareRoot<T>(int precision = -1) where T : struct, IEquatable<T>
22812313
{
@@ -2368,8 +2400,10 @@ public void FloorDouble()
23682400
[Fact]
23692401
public void AbsInt64() { TestAbs<long>(); }
23702402
[Fact]
2403+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
23712404
public void AbsSingle() { TestAbs<float>(); }
23722405
[Fact]
2406+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
23732407
public void AbsDouble() { TestAbs<double>(); }
23742408
private void TestAbs<T>() where T : struct
23752409
{
@@ -2406,8 +2440,10 @@ private void TestAbs<T>() where T : struct
24062440
[Fact]
24072441
public void MultiplicationReflectionInt64() { TestMultiplicationReflection<long>(); }
24082442
[Fact]
2443+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24092444
public void MultiplicationReflectionSingle() { TestMultiplicationReflection<float>(); }
24102445
[Fact]
2446+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24112447
public void MultiplicationReflectionDouble() { TestMultiplicationReflection<double>(); }
24122448
private void TestMultiplicationReflection<T>() where T : struct
24132449
{
@@ -2443,8 +2479,10 @@ private void TestMultiplicationReflection<T>() where T : struct
24432479
[Fact]
24442480
public void AdditionReflectionInt64() { TestAdditionReflection<long>(); }
24452481
[Fact]
2482+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24462483
public void AdditionReflectionSingle() { TestAdditionReflection<float>(); }
24472484
[Fact]
2485+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24482486
public void AdditionReflectionDouble() { TestAdditionReflection<double>(); }
24492487
private void TestAdditionReflection<T>() where T : struct
24502488
{
@@ -2480,8 +2518,10 @@ private void TestAdditionReflection<T>() where T : struct
24802518
[Fact]
24812519
public void DivisionReflectionInt64() { TestDivisionReflection<long>(); }
24822520
[Fact]
2521+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24832522
public void DivisionReflectionSingle() { TestDivisionReflection<float>(); }
24842523
[Fact]
2524+
[ActiveIssue("https://github.com/dotnet/runtime/issues/60347", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsX86Process))]
24852525
public void DivisionReflectionDouble() { TestDivisionReflection<double>(); }
24862526
private void TestDivisionReflection<T>() where T : struct
24872527
{

0 commit comments

Comments
 (0)