Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhson Khan <ahkha@microsoft.com>2018-02-05 09:18:25 +0300
committerGitHub <noreply@github.com>2018-02-05 09:18:25 +0300
commit4fd86200e3bf38d8d90bac669b00173980c31e25 (patch)
treedd32d4a7345811b35f86b400b244b2ab0d010236 /src/System.Memory/tests/Base64
parente9be24d1913af98a671734267c212597fecfea70 (diff)
Reduce test run time to help avoid timeouts in CI for outerloop tests (#26751)
* Add XunitShowProgress to help debug the hang in S.M outerloop tests * Reduce TwoGiBOverflowInt32TestData and use AllocationHelper in Base64 test. * Improve the runtime of Large Clear test and remove XunitShowProgress
Diffstat (limited to 'src/System.Memory/tests/Base64')
-rw-r--r--src/System.Memory/tests/Base64/Base64EncoderUnitTests.cs41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/System.Memory/tests/Base64/Base64EncoderUnitTests.cs b/src/System.Memory/tests/Base64/Base64EncoderUnitTests.cs
index c3f5335106..dac8530996 100644
--- a/src/System.Memory/tests/Base64/Base64EncoderUnitTests.cs
+++ b/src/System.Memory/tests/Base64/Base64EncoderUnitTests.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.SpanTests;
using System.Text;
using Xunit;
@@ -75,20 +76,44 @@ namespace System.Buffers.Text.Tests
[OuterLoop]
public void EncodeTooLargeSpan()
{
+
+ if (IntPtr.Size < 8)
+ return;
+
+ bool allocatedFirst = false;
+ bool allocatedSecond = false;
+ IntPtr memBlockFirst = IntPtr.Zero;
+ IntPtr memBlockSecond = IntPtr.Zero;
+
// int.MaxValue - (int.MaxValue % 4) => 2147483644, largest multiple of 4 less than int.MaxValue
// CLR default limit of 2 gigabytes (GB).
+ // 1610612734, larger than MaximumEncodeLength, requires output buffer of size 2147483648 (which is > int.MaxValue)
+ const int sourceCount = (int.MaxValue >> 2) * 3 + 1;
+ const int encodedCount = 2000000000;
+
try
{
- // 1610612734, larger than MaximumEncodeLength, requires output buffer of size 2147483648 (which is > int.MaxValue)
- Span<byte> source = new byte[(int.MaxValue >> 2) * 3 + 1];
- Span<byte> encodedBytes = new byte[2000000000];
- Assert.Equal(OperationStatus.DestinationTooSmall, Base64.EncodeToUtf8(source, encodedBytes, out int consumed, out int encodedBytesCount));
- Assert.Equal((encodedBytes.Length >> 2) * 3, consumed); // encoding 1500000000 bytes fits into buffer of 2000000000 bytes
- Assert.Equal(encodedBytes.Length, encodedBytesCount);
+ allocatedFirst = AllocationHelper.TryAllocNative((IntPtr)sourceCount, out memBlockFirst);
+ allocatedSecond = AllocationHelper.TryAllocNative((IntPtr)encodedCount, out memBlockSecond);
+ if (allocatedFirst && allocatedSecond)
+ {
+ unsafe
+ {
+ var source = new Span<byte>(memBlockFirst.ToPointer(), sourceCount);
+ var encodedBytes = new Span<byte>(memBlockSecond.ToPointer(), encodedCount);
+
+ Assert.Equal(OperationStatus.DestinationTooSmall, Base64.EncodeToUtf8(source, encodedBytes, out int consumed, out int encodedBytesCount));
+ Assert.Equal((encodedBytes.Length >> 2) * 3, consumed); // encoding 1500000000 bytes fits into buffer of 2000000000 bytes
+ Assert.Equal(encodedBytes.Length, encodedBytesCount);
+ }
+ }
}
- catch (OutOfMemoryException)
+ finally
{
- // do nothing
+ if (allocatedFirst)
+ AllocationHelper.ReleaseNative(ref memBlockFirst);
+ if (allocatedSecond)
+ AllocationHelper.ReleaseNative(ref memBlockSecond);
}
}