From fcd62ffe2de385dc7bec21416a4a6edaa9c5ba90 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Wed, 3 Jul 2019 06:53:20 -0700 Subject: [PATCH] Enabling GetGCMemoryInfo test (dotnet/corefx#39131) * enable the test * additional output to narrow the location of a failure, if happens * run 1000 times * revert the "run 1000 times" change Commit migrated from https://github.com/dotnet/corefx/commit/9d2435f051c59cd30cbfad0fec2f0ab54fc80538 --- .../tests/System/GCTests.netcoreapp.cs | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/GCTests.netcoreapp.cs b/src/libraries/System.Runtime/tests/System/GCTests.netcoreapp.cs index cfb773a..961d27a 100644 --- a/src/libraries/System.Runtime/tests/System/GCTests.netcoreapp.cs +++ b/src/libraries/System.Runtime/tests/System/GCTests.netcoreapp.cs @@ -26,7 +26,6 @@ namespace System.Tests Assert.True((end - start) < 5 * size, $"Allocated too much: start: {start} end: {end} size: {size}"); } - [ActiveIssue(37378)] [Fact] public static void GetGCMemoryInfo() { @@ -58,11 +57,33 @@ namespace System.Tests GCMemoryInfo memoryInfo2 = GC.GetGCMemoryInfo(); - Assert.Equal(memoryInfo2.HighMemoryLoadThresholdBytes, memoryInfo1.HighMemoryLoadThresholdBytes); - Assert.InRange(memoryInfo2.MemoryLoadBytes, memoryInfo1.MemoryLoadBytes, long.MaxValue); - Assert.Equal(memoryInfo2.TotalAvailableMemoryBytes, memoryInfo1.TotalAvailableMemoryBytes); - Assert.InRange(memoryInfo2.HeapSizeBytes, memoryInfo1.HeapSizeBytes + 1, long.MaxValue); - Assert.InRange(memoryInfo2.FragmentedBytes, memoryInfo1.FragmentedBytes + 1, long.MaxValue); + string scenario = null; + try + { + scenario = nameof(memoryInfo2.HighMemoryLoadThresholdBytes); + Assert.Equal(memoryInfo2.HighMemoryLoadThresholdBytes, memoryInfo1.HighMemoryLoadThresholdBytes); + + scenario = nameof(memoryInfo2.MemoryLoadBytes); + Assert.InRange(memoryInfo2.MemoryLoadBytes, memoryInfo1.MemoryLoadBytes, long.MaxValue); + + scenario = nameof(memoryInfo2.TotalAvailableMemoryBytes); + Assert.Equal(memoryInfo2.TotalAvailableMemoryBytes, memoryInfo1.TotalAvailableMemoryBytes); + + scenario = nameof(memoryInfo2.HeapSizeBytes); + Assert.InRange(memoryInfo2.HeapSizeBytes, memoryInfo1.HeapSizeBytes + 1, long.MaxValue); + + scenario = nameof(memoryInfo2.FragmentedBytes); + Assert.InRange(memoryInfo2.FragmentedBytes, memoryInfo1.FragmentedBytes + 1, long.MaxValue); + + scenario = null; + } + finally + { + if (scenario != null) + { + System.Console.WriteLine("FAILED: " + scenario); + } + } }).Dispose(); } -- 2.7.4