-
Notifications
You must be signed in to change notification settings - Fork 5.3k
use O_TRUNC when file locking is disabled, avoid ftruncate syscall #55456
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
614a333
add test project with file locking disabled via config file
adamsitnik d461f14
use O_TRUNC when file locking is disabled, avoid ftruncate syscall
adamsitnik af8ffdd
Apply suggestions from code review
adamsitnik 8baac45
apply code review suggestions
adamsitnik f6ec1f9
reduce the number of tests in DisabledFileLocking from 6270 to 1429
adamsitnik 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 hidden or 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 hidden or 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
16 changes: 16 additions & 0 deletions
16
...ies/System.IO.FileSystem/tests/DisabledFileLockingTests/DisabledFileLockingSwitchTests.cs
This file contains hidden or 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,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Xunit; | ||
|
|
||
| namespace System.IO.Tests | ||
| { | ||
| public class DisabledFileLockingSwitchTests | ||
| { | ||
| [Fact] | ||
| public static void ConfigSwitchIsHonored() | ||
| { | ||
| Assert.Equal(OperatingSystem.IsWindows(), PlatformDetection.IsFileLockingEnabled); | ||
| } | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
...stem/tests/DisabledFileLockingTests/System.IO.FileSystem.DisabledFileLocking.Tests.csproj
This file contains hidden or 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,32 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| <IncludeRemoteExecutor>true</IncludeRemoteExecutor> | ||
| <!-- file locking can't be disabled on Windows --> | ||
| <TargetFrameworks>$(NetCoreAppCurrent)-Unix</TargetFrameworks> | ||
|
|
||
| <WasmXHarnessMonoArgs>--working-dir=/test-dir</WasmXHarnessMonoArgs> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="DisabledFileLockingSwitchTests.cs" /> | ||
| <Compile Include="..\FSAssert.cs" /> | ||
| <Compile Include="..\TestData.cs" /> | ||
| <Compile Include="..\FileSystemTest.cs" /> | ||
| <Compile Include="..\FileSystemTest.Unix.cs" /> | ||
| <Compile Include="..\UnseekableFileStream.cs" /> | ||
| <Compile Include="..\FileStream\**\*.cs" /> | ||
| <Compile Include="..\PortedCommon\DllImports.cs" /> | ||
| <Compile Include="..\PortedCommon\IOInputs.cs" /> | ||
| <Compile Include="..\PortedCommon\IOServices.cs" /> | ||
| <Compile Include="$(CommonTestPath)System\IO\PathFeatures.cs" Link="Common\System\IO\PathFeatures.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetsUnix)' == 'true'"> | ||
| <Compile Remove="..\**\*.Windows.cs" /> | ||
| <Compile Remove="..\**\*.Browser.cs" /> | ||
| <Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs" Link="Interop\Unix\Interop.Libraries.cs" /> | ||
| <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Stat.cs" Link="Interop\Unix\System.Native\Interop.Stat.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="$(CommonTestPath)StreamConformanceTests\StreamConformanceTests.csproj" /> | ||
| </ItemGroup> | ||
| </Project> | ||
5 changes: 5 additions & 0 deletions
5
...libraries/System.IO.FileSystem/tests/DisabledFileLockingTests/runtimeconfig.template.json
This file contains hidden or 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,5 @@ | ||
| { | ||
| "configProperties": { | ||
| "System.IO.DisableFileLocking": true | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Can we instead have this run everywhere, and have the test changed to be:
Assert.Equal(OperatingSystem.IsWindows(), PlatformDetection.IsFileLockingEnabled);
?
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.
This project includes all test files that are run for
System.IO.FileSystem.Tests.csproj. If we enable it for Windows, we are basically going to run the same tests with the same config twice on Windows. Why would we want to do that?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.
Why do we want to do it on Unix? The setting controls a minority of functionality. Shouldn't we be more scoped?
Regardless, my point was that your comment asserts this property, which now controls whether multiple tests run, will always be true on Windows. Seems like a good thing to validate with the test you're adding.
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.
My main motivation is to make sure that file IO actually works as expected when the locking is disabled. It's unlikely that we introduce a bug in this code path, but it's still possible.
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.
Sure, but running all 6000+ tests?