We have a bunch of test assemblies that don't make sense on some platforms, e.g. Browser.
Right now we're skipping them via `[SkipOnMono("reason", TestPlatforms.Browser)]` but there's nothing that inherently ties this to Mono other than the current implementation.
The more generic `SkipOnPlatform` attribute can be used instead.
We can also use it in places where we do `[PlatformSpecific(~TestPlatforms....)]` to avoid the double inversion.
* don't verify OS handle position
* track the file offset in memory, don't use expensive syscalls to synchronize it
* there is no need to set the Length since we are now tracking the offset in memory
* Cache GetFileInformationByHandleEx (Length) when FileShare does not allow other processes to modify it
Co-authored-by: Adam Sitnik <[email protected]>
* move all strategy-related types to Strategies subfolder and namespace
* make FileStreamHelpers a partial class, move some cross-platform helper methods there
* rename config switch
* address code review feedback
* add StreamConformanceTests to the solution file so we can read source code from VS
* add FileOffsetIsPreservedWhenFileStreamIsCreatedFromSafeFileHandle tests
* add WriteAsyncStartsWherePreviousReadAsyncHasFinished test
* introduce WindowsFileStreamStrategy
* introduce SyncWindowsFileStreamStrategy
* introduce AsyncWindowsFileStreamStrategy
* only DerivedFileStreamStrategy needs to have a reference to FileStream
remove finalizer from FileStream, keep it only in DerivedFileStreamStrategy and LegacyFileStreamStrategy
* use the new strategies when buffering is not enabled
* introduce BufferedFileStreamStrategy
* use the Legacy strategy by default for now, add tests for the other implementation
* Apply suggestions from code review
Co-authored-by: David Cantú <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
* add ZeroByteRead_PerformsZeroByteReadOnUnderlyingStreamWhenDataNeeded to stream conformance tests
* remove dead code
* change SslStream zero byte read implementation to issue zero-byte read on underlying stream when appropriate
* ensure buffer is always freed when not needed, and assert this
* create StreamConformanceTests assembly and reference from appropriate test projects
Co-authored-by: Geoffrey Kizer <[email protected]>
The current implementation has an inefficiency. When moving a file across volumes, and when
the target file doesn't exist, the "rename" syscall will be called twice (unsuccesfully) instead of once.
By branching on "overwrite" from the beginning, we avoid calling the first "rename" in vain.
Co-authored-by: Konstantin Gukov <[email protected]>
* [browser][tests][outerloop] Standup OuterLoop tests on CI
* System.Collections.NonGeneric.Tests passing
* System.Console.Tests passing
* System.Diagnostics.DiagnosticSource.Tests passing
* System.Globalization.Tests passing
- See active issue https://github.com/dotnet/runtime/issues/45951
* System.IO.FileSystem.Tests passing after deactivating test cannot wait on monitors on this runtime.
* System.IO.FileSystem.Tests passing - See active issue: https://github.com/dotnet/runtime/issues/45954
* Remove fat fingered code.
* Threads not supported on Browser
* Browser does not support monitor
* Browser does not support monitor
* Browser does not support wait on monitors
* Browser does not support wait on monitors
* Add ActiveIssue for DataFlow tests TestNullTarget_CompletionNoCaching
* Add ActiveIssue for DataFlow tests
* Add ActiveIssue for DataFlow tests
* Add threading support conditional
* Change all Cannot wait on monitors on this runtime Browser platform checks to
[ConditionalXXXX(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
As was suggested in comments
* Address review comment for monitors not supported
* Address review comments
* Add threading supported condition.
```
fail: [FAIL] System.Text.Json.Serialization.Tests.EnumConverterTests.VeryLargeAmountOfEnumsToSerialize
[08:10:56] info: System.PlatformNotSupportedException : Cannot wait on monitors on this runtime.
```
* add MultiArrayBuffer and use in StreamBuffer and Http2Stream
* rework EnsureAvailableSpace and add tests for it
* make dispose handling more robust, plus minor tweaks
* add AssertExtensions.SequenceEqual for providing more useful information about sequence differences, and use in StreamConformanceTests
* tweaks
* replace _blockCount with _allocatedEnd
* use uint instead of int internally to assure bitop optimizations
* fix _allocatedEnd calculation
* address PR feedback
* more PR feedback and some minor fixes/improvements
* small test improvements
* Apply suggestions from code review
Co-authored-by: Günther Foidl <[email protected]>
* address review feedback
Co-authored-by: Geoffrey Kizer <[email protected]>
Co-authored-by: Günther Foidl <[email protected]>
* Add Stream argument validation helpers and use throughout dotnet/runtime
* Delete unnecessary code in Stream
Stream.Null was using BlockingBegin/EndRead/Write, but the operations are nops (they don't even do argument validation), so the functionality was unnecessary complication. We can just use TaskToApm instead, with already completed tasks, and then also delete the SynchronousAsyncResult that was used by these operations.
Also, the Begin/EndRead/Write methods were checking CanRead/Write and throwing if they return false, but this is a private sealed type with CanRead/Write hardcoded to return true! Delete.
Finally added consistency across Stream.Null to checking for cancellation.
* Clean up some style on Stream
Also consolidate a few resources and use a few existing ThrowHelpers where appropriate.
* Fix a few issues, and remove duplicative tests missed in conformance tests rollout
* Address PR feedback
* Fix invalid assert in StreamBuffer
This can be hit by calling code and thus shouldn't be an assert. As an assert it prevents testing.
* Add ConnectedStreams.CreateUnidirectional
* Add initial set of Stream conformance tests
These primarily focus on "connected streams", ones that can be arranged to communicate with each other in a producer/consumer pattern or as a bidirectional communication mechanism, e.g. NetworkStream, PipeStream, SslStream wrapped around a NetworkStream, FileStream created around pipes, etc. Later we can add more tests focused on standalone streams, e.g. FileStream created for an on-disk file, MemoryStream, etc.
* Add ConnectedStreams tests
These are currently helpers used by many other tests. At some point they could become public API as well.
* Fix NetworkStream argument names
Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).
* Add stream conformance tests for NetworkStream
* Add stream conformance tests for QuicStream
* Fix several CryptoStream behaviors
1. Flushing a stream that wraps another stream for writing should always flush that underlying stream, even if no additional data was written as part of the flush.
2. Argument validation should validate buffers are not null rather than null ref'ing on a null buffer.
3. Checks for the CryptoStream mode should come after argument validation.
* Add stream conformance tests for CryptoStream
* Fix FileStream argument names
Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).
* Fix BufferedStream argument names
Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).
* Add stream conformance tests for FileStream
Specifically when used in a connected fashion, wrapped around an anonymous or named pipe.
* Add stream conformance tests for BufferedStream
Specifically when used in a connected fashion, wrapped around some other connected stream.
* Add stream conformance tests for SslStream and NegotiateStream
* Fix PipeStream.Flush to not fail on readable streams
Consumers may expect Stream.Flush to be a nop if the stream is readable only, but PipeStream.Flush is throwing in that case. Stop doing that.
* Add stream conformance tests for PipeStream
* Fix several BrotliStream behaviors
1. When passed a null buffer, it's throwing an exception with the argument name "array", even though the parameter's name is "buffer".
2. Even if there's no data written as part of the Flush{Async} call on a writeable stream, it should be calling flush on the wrapped stream.
* Fix several DeflateStream (and friends) issues
1. DeflateStream.Flush{Async} when writing needs to always flush the underlying stream, even if there's no data written as part of the flush call itself.
2. Several byte[] array arguments should be byte[] buffer. Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).
3. DeflateStream.EndRead/Write needs to do additional state validation.
4. Not a bug, but simplify ReadAsync to match the sync Read implementation flow.
* Add stream conformance tests for Deflate/ZLib/GZip/BrotliStream
* Fix PipeReader/WriterStream argument validation
* Add stream conformance tests for PipeReader/WriterStream
* Remove erroneous asserts from Stream.ReadWriteTask
* Address PR feedback
* Fix a few tests in CI
Reverts "Ensure FileStatus and FileSystemEntry Hidden and ReadOnly attributes are retrieved the same way"
(commit 6ed1e41e59) which introduced a perf regression.
Co-authored-by: carlossanlop <[email protected]>
* Emscripten lacks ns/ms granularity which I included a switch for and added a browser platform check
* Emscripten takes maximum of utime and atime so I set utime and atime together for Browser
* [wasm] Skip EnsureThrowWhenCopyToNonSharedFile on Browser
* Provide context for skipping Copy.cs test on Browser
Co-authored-by: Mitchell Hwang <[email protected]>
* Revert "[Wasm] Enable CopyWithData FileSystem test (#40663)"
This reverts commit 1821567ab6.
* Provide context for skipping Assert in Copy.cs
Co-authored-by: Mitchell Hwang <[email protected]>
* Revert " Use clonefile for CopyFile, if available (dotnet/corefx#37583)"
This reverts commit 02ba75ad0f.
* Add unit test
* Disable tests failing in browser-wasm
* Ensure FileStatus and FileSystemEntry IsHidden attribute is retrieved the same way
* Add missing check in public property FileSystemEntry.IsHidden. Address PR suggestions.
* Add tests for Hidden and ReadOnly attribute check for each platform. Split existing Skip attribute test into different platforms.
* Use _initialAttributes instead of Attributes for IsHidden. Add comment on top.
Co-authored-by: carlossanlop <[email protected]>
* Save last error info in SafeFileHandle.ReleaseHandle and read it in FileStream.Dispose
* Add manual test
* Remove Debug.Fail from SafeFileHandle, automate the drive filling step in the manual test, add suggested comments, make threadstatic field static.
* Address suggestions
* Update src/libraries/System.IO.FileSystem/tests/ManualTests/ManualTests.cs
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: carlossanlop <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
* mark System.Data.OleDb assembly as Windows-specific
* mark System.Windows.Extensions assembly as Windows-specific
* mark System.IO.FileInfo Encrypt and Decrypt methods as Windows-specific
* System.Runtime.InteropServices
* VB
* mark entire ComWrappers type as Windows-specific
* mark CspParameters class as Windows-specific
* [browser][file system] Tests System.IO.FileSystem
* Remove FileSystem from test project exclusions.
* [browser][filesystem] Comment on skipped tests due to IO.Pipes not supported
* [browser][filesystem] Comment on skipped tests due to monitor not supported
* Address review comments
* Address review comments on how to handle monitor PNSE
* Update src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs
Co-authored-by: Jan Kotas <[email protected]>
* Add ActiveIssue for browser platform
```
[ActiveIssue("https://github.com/dotnet/runtime/issues/39955", TestPlatforms.Browser)]
public void NotFoundErrorIsExpected()
```
* Simplify test case with `PlatformDetection.IsSuperUser` as per review comment
* Remove unused variable from tests
* Browser platform volume does not limit each component of the path to a total of 255 characters.
- Remove the test `DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException` for Browser platform.
- Add new test `DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowsException` for Browser platform in case this check is added in the future.
* Fix windows tests
* Add ActiveIssue to test System.IO.Tests.DirectoryInfo_Name.CurrentDirectory
- System.IO.Tests.DirectoryInfo_Name.CurrentDirectory does not pass because it is using Path.GetFileName on the current directory of "/".
- See issue https://github.com/dotnet/runtime/issues/39998 for more information
* Add active issue for tests that need to support file locking.
* Add active issue for tests that need to support file locking.
* Browser volume does not have a limit on segments
* Remove browser platform test
* Remove active issue for NotFoundErrorIsExpected
* Remove platform specific from SkippingHiddenFiles
* Fix enumeration test errors failing from `HiddenFilesAreReturned`.
- WebAssembly (BROWSER) has dirent d_type but is not identifying correctly but by returning UNKNOWN the managed code properly stats the file to detect if entry is directory or not.
* Fix enumeration test errors failing from `HiddenFilesAreReturned`.
- WebAssembly (BROWSER) has dirent d_type but is not identifying correctly but by returning UNKNOWN the managed code properly stats the file to detect if entry is directory or not.
* Fix build for TARGET_WASM not defined
* Address review comment by add check for IsWindows to IsSuperUser.
* Address review comment by add check for IsWindows to IsSuperUser.
* Platform Specific test for hidden files no longer needed.
* Platform Specific test fno longer needed.
* Use active issue for rename issue
* ActiveIssue no longer needed
- PR https://github.com/dotnet/runtime/pull/40310 works around the issue for now while waiting for fix https://github.com/emscripten-core/emscripten/issues/11804 / https://github.com/emscripten-core/emscripten/pull/11812
* Use ActiveIssue for SettingUpdatesProperties
* Use ActiveIssue for TimesIncludeMillisecondPart
* Use ActiveIssue for ErrorHandlingTests failures
* Use ActiveIssue for SetUptoNanoseconds
* Use ActiveIssue for GetSetTimes test failures
* Use ActiveIssue for tests failing with DirectoryNotFoundException
* Use ActiveIssue for tests failing with UnauthorizedAccessException
* Remove debugging statement from pal_io
* Address type in CreateDirectory method name
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Mitchell Hwang <[email protected]>