-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/6.0] Don't create multiple large files at the same time #63032
Merged
danmoseley
merged 6 commits into
dotnet:release/6.0
from
jozkee:6.0/NoInt32Overflow_OuterLoop
Dec 31, 2021
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
04af7ae
Move NoInt32OverflowInTheBufferingLogic to OuterLoop and address pend…
jozkee 8d0a914
Don't create multiple large files at the same time (#62519)
adamsitnik d02bc6f
Fix DisableParallelization build issue
jozkee d525882
Apply suggestions from code review
jozkee 2bc8aa5
Update src/libraries/System.IO.FileSystem/tests/LargeFileTests.cs
jozkee 11e9f38
Notepad with uppercase (#62487)
danmoseley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't actually need this since we already have the same one here which you can include instead: https://github.com/dotnet/runtime/blob/release/6.0/src/libraries/Common/tests/System/Xml/DisableParallelization.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah looks like it is already that way in main, you'll need to include the file in the .csproj so it works:
runtime/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
Line 218 in 1c09d36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File
src\libraries\Common\tests\TestUtilities\System\DisableParallelization.cs
doesn't exists in release/6.0.I added the class here because that's how we were doing it prior to #62132.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was in a different path in release/6.0 (see the linked file in my first comment), but this is just a cosmetic issue so fine if we keep what you have :)