-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/6.0] Don't create multiple large files at the same time (#63032
) * Move NoInt32OverflowInTheBufferingLogic to OuterLoop and address pending feedback (#60606) * Don't create multiple large files at the same time (#62519) * move existing large file tests into a separate type (no code changes) * don't run the large file tests in parallel * use FileOptions.DeleteOnClose to ensure that each test removes it's own file use single large file to test File.ReadAllBytes and ile.ReadAllBytesAsync for both limits * Fix DisableParallelization build issue * Apply suggestions from code review Co-authored-by: Adam Sitnik <[email protected]> * Update src/libraries/System.IO.FileSystem/tests/LargeFileTests.cs Co-authored-by: Adam Sitnik <[email protected]> * Notepad with uppercase (#62487) Co-authored-by: Adam Sitnik <[email protected]> Co-authored-by: Dan Moseley <[email protected]>
- Loading branch information
1 parent
67b110e
commit 3b71fd8
Showing
8 changed files
with
110 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/libraries/System.IO.FileSystem/tests/LargeFileTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO.Tests; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace System.IO.FileSystem.Tests | ||
{ | ||
[OuterLoop] | ||
[ActiveIssue("https://github.com/dotnet/runtime/issues/45954", TestPlatforms.Browser)] | ||
[Collection(nameof(NoParallelTests))] // don't create multiple large files at the same time | ||
public class LargeFileTests : FileSystemTest | ||
{ | ||
[Fact] | ||
public async Task ReadAllBytesOverLimit() | ||
{ | ||
using FileStream fs = new (GetTestFilePath(), FileMode.Create, FileAccess.Write, FileShare.Read, 4096, FileOptions.DeleteOnClose); | ||
|
||
foreach (long lengthOverLimit in new long[] { int.MaxValue + 1L }) | ||
{ | ||
fs.SetLength(lengthOverLimit); | ||
|
||
Assert.Throws<IOException>(() => File.ReadAllBytes(fs.Name)); | ||
await Assert.ThrowsAsync<IOException>(async () => await File.ReadAllBytesAsync(fs.Name)); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void NoInt32OverflowInTheBufferingLogic() | ||
{ | ||
const long position1 = 10; | ||
const long position2 = (1L << 32) + position1; | ||
|
||
string filePath = GetTestFilePath(); | ||
byte[] data1 = new byte[] { 1, 2, 3, 4, 5 }; | ||
byte[] data2 = new byte[] { 6, 7, 8, 9, 10 }; | ||
byte[] buffer = new byte[5]; | ||
|
||
using (FileStream stream = File.Create(filePath)) | ||
{ | ||
stream.Seek(position1, SeekOrigin.Begin); | ||
stream.Write(data1); | ||
|
||
stream.Seek(position2, SeekOrigin.Begin); | ||
stream.Write(data2); | ||
} | ||
|
||
using (FileStream stream = new (filePath, FileMode.Open, FileAccess.Read, FileShare.None, 4096, FileOptions.DeleteOnClose)) | ||
{ | ||
stream.Seek(position1, SeekOrigin.Begin); | ||
Assert.Equal(buffer.Length, stream.Read(buffer)); | ||
Assert.Equal(data1, buffer); | ||
|
||
stream.Seek(position2, SeekOrigin.Begin); | ||
Assert.Equal(buffer.Length, stream.Read(buffer)); | ||
Assert.Equal(data2, buffer); | ||
} | ||
} | ||
} | ||
|
||
[CollectionDefinition(nameof(NoParallelTests), DisableParallelization = true)] | ||
public partial class NoParallelTests { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters