From de35b686808c8cf4cc14209f52ae0369f495396f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 11 Jun 2019 13:56:09 -0700 Subject: [PATCH] Remove flaky asserts in Marshal.R/WInt16 tests. (dotnet/corefx#38464) Commit migrated from https://github.com/dotnet/corefx/commit/e02b99b0997ec496873c844b72fccf03b1cca8d5 --- .../InteropServices/Marshal/ReadWrite/Int16Tests.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs index 13b9491..4d364e1 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs @@ -85,7 +85,6 @@ namespace System.Runtime.InteropServices.Tests Assert.Equal("ABC", ((StructWithReferenceTypes)structure).stringValue); Assert.Equal(new short[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 100 }, ((StructWithReferenceTypes)structure).byValueArray); Assert.Equal(200, Marshal.ReadInt16(structure, pointerOffset)); - Assert.NotEqual(0, Marshal.ReadInt16(structure, stringOffset)); Assert.Equal(100, Marshal.ReadInt16(structure, arrayOffset + sizeof(short) * 9)); } @@ -120,20 +119,6 @@ namespace System.Runtime.InteropServices.Tests }; Assert.Equal(100, Marshal.ReadInt16(structure, pointerOffset)); - - // The ReadInt16() for object types does an explicit marshal which requires - // an allocation on each read. It can occur that the allocation is aligned - // on a 16-bit boundary which would yield a value of 0. To mitigate the chance, - // marshal several times, choosing 20 as an arbitrary value. If this test - // fails, we should reconsider whether it is worth the flakiness. - int readShorts = 0; - for (int i = 0; i < 20; ++i) - { - readShorts += Marshal.ReadInt16(structure, stringOffset); - } - - Assert.NotEqual(0, readShorts); - Assert.Equal(3, Marshal.ReadInt16(structure, arrayOffset + sizeof(short) * 2)); } -- 2.7.4