Remove flaky asserts in Marshal.R/WInt16 tests. (dotnet/corefx#38464)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Tue, 11 Jun 2019 20:56:09 +0000 (13:56 -0700)
committerStephen Toub <stoub@microsoft.com>
Tue, 11 Jun 2019 20:56:09 +0000 (13:56 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/e02b99b0997ec496873c844b72fccf03b1cca8d5

src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs

index 13b9491..4d364e1 100644 (file)
@@ -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));
         }