From bf5c5a9b36b11f2c47e9f543d5a776a5a7e2f09f Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Thu, 5 Aug 2021 10:12:51 -0400 Subject: [PATCH 1/3] [libraries][Android] Skip OffsetOfTests on Android x86 --- .../InteropServices/Marshal/OffsetOfTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs index 00fc49e78c552..8760099650102 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs @@ -32,9 +32,14 @@ public void OffsetOf_ClassWithSequentialLayout_ReturnsExpected() Assert.Equal(new IntPtr(4), Marshal.OffsetOf(typeof(MyPoint), nameof(MyPoint.y))); } - [Fact] + [ConditionalFact] public void OffsetOf_ExplicitLayout_ReturnsExpected() { + if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.x86) + { + throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 56, Actual: 52"); + } + Type t = typeof(ExplicitLayoutTest); Assert.Equal(56, Marshal.SizeOf(t)); Assert.Equal(new IntPtr(0), Marshal.OffsetOf(t, nameof(ExplicitLayoutTest.m_short1))); @@ -104,9 +109,14 @@ public void OffsetOf_ValidField_ReturnsExpected() } } - [Fact] + [ConditionalFact] public void OffsetOf_Decimal_ReturnsExpected() { + if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.x86) + { + throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 88, Actual: 72"); + } + Type t = typeof(FieldAlignmentTest_Decimal); if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm)) From 0d9707cec049f119f7fa74aa68882b3ff82d47af Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Thu, 5 Aug 2021 10:23:22 -0400 Subject: [PATCH 2/3] Fix typo and import --- .../System/Runtime/InteropServices/Marshal/OffsetOfTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs index 8760099650102..2be9a98539471 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.Reflection; using System.Reflection.Emit; +using Microsoft.DotNet.XUnitExtensions; using Xunit; namespace System.Runtime.InteropServices.Tests @@ -35,7 +36,7 @@ public void OffsetOf_ClassWithSequentialLayout_ReturnsExpected() [ConditionalFact] public void OffsetOf_ExplicitLayout_ReturnsExpected() { - if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.x86) + if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.X86) { throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 56, Actual: 52"); } @@ -112,7 +113,7 @@ public void OffsetOf_ValidField_ReturnsExpected() [ConditionalFact] public void OffsetOf_Decimal_ReturnsExpected() { - if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.x86) + if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.X86) { throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 88, Actual: 72"); } From abc1c2ad6ce3617fe696c4d69efe528456fd9755 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Thu, 5 Aug 2021 12:55:07 -0400 Subject: [PATCH 3/3] Check for x86 and retain ActiveIssue --- .../InteropServices/Marshal/OffsetOfTests.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs index 2be9a98539471..3781d521678c8 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/OffsetOfTests.cs @@ -33,14 +33,10 @@ public void OffsetOf_ClassWithSequentialLayout_ReturnsExpected() Assert.Equal(new IntPtr(4), Marshal.OffsetOf(typeof(MyPoint), nameof(MyPoint.y))); } - [ConditionalFact] + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/49872", typeof(PlatformDetection), nameof(PlatformDetection.IsAndroid), nameof(PlatformDetection.Is32BitProcess))] public void OffsetOf_ExplicitLayout_ReturnsExpected() { - if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.X86) - { - throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 56, Actual: 52"); - } - Type t = typeof(ExplicitLayoutTest); Assert.Equal(56, Marshal.SizeOf(t)); Assert.Equal(new IntPtr(0), Marshal.OffsetOf(t, nameof(ExplicitLayoutTest.m_short1))); @@ -110,14 +106,10 @@ public void OffsetOf_ValidField_ReturnsExpected() } } - [ConditionalFact] + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/49872", typeof(PlatformDetection), nameof(PlatformDetection.IsAndroid), nameof(PlatformDetection.Is32BitProcess))] public void OffsetOf_Decimal_ReturnsExpected() { - if (OperatingSystem.IsAndroid() && RuntimeInformation.ProcessArchitecture == Architecture.X86) - { - throw new SkipTestException("https://github.com/dotnet/runtime/issues/49872 Test fails on Android x86 with -- Expected: 88, Actual: 72"); - } - Type t = typeof(FieldAlignmentTest_Decimal); if (OperatingSystem.IsWindows() || (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.Wasm))