Commit Graph
1561 Commits
Author SHA1 Message Date
Adam Sitnik cbc1f6a551 Fix .NET 5 FileStream compat detection in the test utility project (#57288) 2021-08-12 20:41:26 +02:00
Mitchell HwangandMitchell Hwang 126e29cd6e [MacCatalyst][libraries] Update MacCatalyst as Case Preserving for tests (#57167)
Co-authored-by: Mitchell Hwang <[email protected]>
2021-08-11 09:38:58 +02:00
David KarlašandJeff Handley f03c995111 Fix performance for File.GetLastWriteTimeUtc on Unix (#53070)
All this changes are to internal methods which are later called by other public methods which correctly call `ToLocalTime` for local time "overloads".
Performance hit is most visible for application which doesn't need to load local timezone information which takes ~30ms on 2016 MacBook Pro.

Co-authored-by: Jeff Handley <[email protected]>
2021-08-10 10:12:13 +02:00
Adam Sitnik 27059fb834 Ensure Directory.Delete works fine even if user has no ListDirectory permissions (#56996) 2021-08-09 18:56:58 +02:00
Adam Sitnik 6fc8441311 Ensure FileStream.Position is correct after a failed|cancelled WriteAsync attempt (#56716) 2021-08-05 07:56:29 +02:00
Adam Sitnik e176fdf643 Update position before ReadAsync starts, but fix it after incomplete read (#56531)
* move CanRead and CanWrite checks to FileStream

* don't check IsClosed twice_(FileHandle.CanSeek already contains a IsClosed check)

* add a failing test

* handle incomplete async reads

* don't try to cache file length when file is opened for writing, as updating file position before performing async write can lead to invalid cached length value

* maybe Win 7 & 8 fix
2021-07-31 19:37:23 -04:00
Jeremy Koritzinsky 108fcdb61c Merge branch 'main' of github.com:dotnet/runtime into feature/use-dllimport-generator 2021-07-29 10:44:59 -07:00
Viktor Hofer a6b9a63f35 Update libraries solution and NuGet.config files (#56430)
* Update slngen and invocation

* Update NuGet.config files

* Update solution files with slngen
2021-07-28 18:44:17 +02:00
Adam Sitnik eeb4f368a2 Add tests for reads and writes beyond EOF (#56395)
* ensure that reads beyond EOF return 0

* ensure that writes beyond EOF extend the file and the content is zeroed
2021-07-27 20:07:49 +02:00
Maxim Lipnin 5da7094bb1 Disable some library tests due to failures/crash (#55826) 2021-07-19 09:09:35 +03:00
Maxim Lipnin 0acde243da Make Named Pipe Server Stream name fit into allowed length on Android (#55731)
* Make Named Pipe Server Stream name fit into allowed length on Android

* Apply Stephen's suggestion

* Remove redundant parameter

* Take into account possible null terminator
2021-07-16 09:56:18 -04:00
Stephen Toub d2e9f42c60 Augment tests for FileMode.Append (#55513)
To validate that seeking and writing are valid in the region of the file since its initial length.
2021-07-13 12:05:31 -04:00
Stephen Toub dfd618dc64 Use interpolated strings in more places 2021-07-13 10:11:51 -04:00
David Cantú 2d596ecea2 Change server paths to use LOCALHOST (#55523) 2021-07-13 00:50:00 -07:00
Stephen Toub da7bce7605 Change RandomAccess.Write* methods to be void-returning (#55490) 2021-07-12 19:39:21 -04:00
Tom DeseynandJeff Handley 67ecbe844f File.Unix: Replace: increase Windows compatibility (#50234)
* File.Unix: Replace: increase Windows compatibility

- When source and destination are not a file throw UnauthorizedAccessException.
- When source and destination are the same file throw IOException.

* Include paths in exception message

Co-authored-by: Jeff Handley <[email protected]>
2021-07-12 15:22:17 -06:00
Adam SitnikandStephen Toub 2eb0071689 use O_TRUNC when file locking is disabled, avoid ftruncate syscall (#55456)
* add test project with file locking disabled via config file

* use O_TRUNC when file locking is disabled, avoid ftruncate syscall

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
2021-07-10 20:38:44 +02:00
Stephen Toub e0b9fe5146 Fix File.Copy with procfs (#55358) 2021-07-09 19:56:02 -04:00
Adam Sitnik a7a9448c70 fix DeviceInterfaceCanBeOpenedForAsyncIO test (#55414) 2021-07-09 21:38:52 +02:00
Adam Sitnik 8377b0d938 allow FileStream to open any types of files from path (#54676) 2021-07-09 21:01:38 +02:00
dcce0f56e1 Add symbolic link APIs (#54253)
Co-authored-by: David Cantu <[email protected]>
Co-authored-by: carlossanlop <[email protected]>
Co-authored-by: carlossanlop <Carlos Sanchez [email protected]>
2021-07-09 13:17:31 +02:00
Stephen Toub 50413eafd5 Add UnixFileStreamStrategy (#55191)
* Add UnixFileStreamStrategy

* Address PR feedback

* Fix length caching
2021-07-08 11:28:42 -04:00
Stephen Toub 56b250b798 Handle FileOptions.DeleteOnClose on Unix in SafeFileHandle.Dispose (#55153)
* Handle FileOptions.DeleteOnClose on Unix in SafeFileHandle.Dispose

* Move file path into SafeFileHandle on Windows as well

Doing so enables cleaning up a bunch of passing around of the file path, while also enabling the path to be fed to more error paths.

* Update Net5Compat impl as well
2021-07-05 20:34:57 -04:00
f4e88f41cc all RandomAccess methods should work for both sync and async file handles (#54266)
Co-authored-by: campersau <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
2021-07-02 16:09:49 +02:00
Stephen Toub 40bd417ad8 Delete stale references to System.IO.FileSystem.Primitives (#55041) 2021-07-01 23:31:27 -04:00
Adam Sitnik 38df267589 add test for opening and reading from device interface (#54673) 2021-06-30 16:57:51 +02:00
Adam Sitnik 2abd4878e2 More file stream options tests (#53982)
* add more tests

* StreamWriter and StreamReader require FileStreamOptions with necessary access

* allow for bufferSize == 0

* extend the test

* refactor the tests

* Revert "allow for bufferSize == 0"

This reverts commit f1259be18a3446c1b8939883f484cc28347c74cf.
2021-06-26 17:20:32 -04:00
Adam Sitnik 7833828914 [FileStream] add tests for device and UNC paths (#54545)
* add a test for unseekable device by using a path to named pipe

* add a test for seekable device by using DeviceID instead of drive letter

* add a test for a UNC file path (local file share)
2021-06-24 08:58:33 +02:00
Dan Moseley f55390a2e5 Fix sporadic double fd close (#54660)
Fix https://github.com/dotnet/runtime/issues/54589
2021-06-24 00:35:39 -04:00
c0ed319ba3 Change PathInternal.IsCaseSensitive to a constant (#54340)
* Return constants in PathInternal.GetIsCaseSensitive() on mobile platforms

   In particular on Android probing using I/O is slow and contributes to slow app startup.

   Fixes https://github.com/dotnet/runtime/issues/54339

* Implement Path.IsCaseSensitive as PathInternal.IsCaseSensitive

   Also Path.StringComparison => PathInternal.StringComparison

* Add test for PathInternal.IsCaseSensitive

   Move GetIsCaseSensitiveByProbing to FileSystemTest

* Drop PathInternal.s_isCaseSensitive cache field

* Delete Path.IsCaseSensitive and Path.StringComparison

   update callers to use PathInternal.IsCaseSensitive and PathInternal.StringComparison

* Remove catch clause from GetIsCaseSensitiveByProbing

* Mark new test [OuterLoop]

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Adam Sitnik <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
2021-06-23 09:44:41 -04:00
Elinor Fung b3d6fb16c4 Merge remote-tracking branch 'upstream/main' into mergeMain 2021-06-18 10:37:13 -07:00
Adam SitnikandStephen Toub 9d771a26f0 Set of offset-based APIs for thread-safe file IO (#53669)
Co-authored-by: Stephen Toub <[email protected]>
2021-06-15 20:59:58 +02:00
Elinor Fung 6271751fca Merge remote-tracking branch 'upstream/main' into HEAD 2021-06-11 10:04:20 -07:00
Adam Sitnik 51b85b2a40 posix_fallocate should work on WASM now (#53985) 2021-06-10 13:32:13 +02:00
Emmanuel André 8538436d28 Add FileStreamOptions overloads (#52720) 2021-06-10 06:57:09 +02:00
Adam SitnikandStephen Toub 78579ef0e7 move the validaiton logic to FileStreamOptions (#53869)
Co-authored-by: Stephen Toub <[email protected]>
2021-06-09 15:49:14 +02:00
Aaron Robinson 42e903c2d8 Use GeneratedDllImport in System.IO.FileSystem (#53830)
* Convert System.IO.FileSystem to DllImport source generator
2021-06-07 15:32:45 -07:00
Elinor Fung 3b2fbeefd2 Use GeneratedDllImport in System.Diagnostics.Process (#53702) 2021-06-04 14:27:39 -07:00
Radek Doulik d43b00abe0 [wasm] Bump emscripten to 2.0.21 (#52870)
* Bump emscripten version

* Rename __padding to _padding to avoid warnings

And errors as we use `-Werror`:

    error G94F6014A: identifier '__padding' is reserved because it starts with '__'

C99 and C++ standard defines indentifiers with `__` prefix as reserved.

* Fix cast warning/error

With latest emscripten we get this warning (and error as we use
 `-Werror`):

    src/libraries/Native/Unix/System.Native/pal_process.c(374,92): error G3DC5E52A: cast from 'void (*)(int, siginfo_t *, void *)' to 'void (*)(int)' converts to incompatible function type [-Werror,-Wcast-function-type]
                  void (*oldhandler)(int) = (((unsigned int)sa_old.sa_flags) & SA_SIGINFO) ? (void (*)(int))sa_old.sa_sigaction : sa_old.sa_handler;

* Add `-s DISABLE_EXCEPTION_CATCHING=0`

when building dotnet.js

* Use EMSDK_PYTHON

* Use delayed expansion

Before the `EMSDK_PYTHON` was evaluated before running
the `emsdk_env.bat` script.

* Replace deprecated EXTRA_EXPORTED_RUNTIME_METHODS

with EXPORTED_RUNTIME_METHODS

Build warning/error:

    emcc : warning : EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]

* Don't need to cast anymore

* 2.0.21 was just released, so try our luck ;-)

* Use new docker images with 2.0.21

* Use the sys includes fix on all platforms

* Remove deprecated --llvm-opts usage

Context: https://github.com/emscripten-core/emscripten/commit/0691cc68eef89fe59f66eacdba245470bea2a113

* Update emscripten version in the workload manifest

* Update emscripten versions in the docs

* Update eng/ versions

* Add ActiveIssue attr in the MemoryCacheTest

* Add ActiveIssue attr to the FileSystem tests

* Update after merge

* Resolve one more conflict

* Add ActiveIssue to the MemoryMappedFiles tests

* Revert "Fix cast warning/error"

This reverts commit 0a1aa4a88c07bc48d3d35c68369d1dca4897d849.

* Unset HAVE_FORK for Browser

* Remove active issue

Fixed by https://github.com/dotnet/runtime/commit/93cf5df65fc13bfbc29256acc8c9c0e102a1170b

* Set HAVE_FORK to 0

* Set HAVE_FORK to 0 instead if unsetting

* Remove -s DISABLE_EXCEPTION_CATCHING=0

It might not be needed anymore
2021-06-02 12:21:53 +02:00
Levi Broderick b759ac9716 Expose Array.Clear(Array) as public API (#53388) 2021-05-27 21:08:53 -07:00
Adam Sitnik 44f050acc0 Fold System.IO.FileSystem into CoreLib (#53231)
* move Queue<T> to System.Private.CoreLib

* fold System.IO.FileSystem into System.Private.CoreLib
2021-05-27 12:56:30 +02:00
e329c2dfcd Fix: Avoid throwing if a symbolic link cycle to itself is detected while enumerating (#52749)
* Fix: Avoid throwing on FileSystemEntry.Initialize

* Add unit tests that verify cyclic symbolic links

* Fix Windows-specific unit test failures

* Use OperatingSystem.IsWindows()

* CHange 'Assert.Equal(1, ' to 'Assert.Single('

* Rename helper method that creates self referencing symlink

* Spacing

* ConditionalClass for CanCreateSymbolicLinks

* ConditionalClass does not work in browser/ios/android, use ConditionalFact/ConditionalTheory

Co-authored-by: carlossanlop <Carlos Sanchez [email protected]>
Co-authored-by: carlossanlop <[email protected]>
2021-05-24 10:48:40 -07:00
Mitchell HwangandMitchell Hwang 5b57479fcb [MacCatalyst][libraries] Add specific SkipOnPlatform and ActiveIssues instead of test level skip (#52859)
* [MacCatalyst][libraries] Add System.Console.Tests SkipOnPlatform

* [MacCatalyst][libraries] Add System.Diagnostics.Process.Tests SkipOnPlatform

* [MacCatalyst][libraries] Add Microsoft.Extensions.Hosting.Unit.Tests SkipOnPlatform

* [MacCatalyst][libraries] Add System.Net.NetworkInformation.FunctionalTests SkipOnPlatform

* [MacCatalyst][libraries] Add System.IO.FileSystems.Tests SkipOnPlatform

* [MacCatalyst][libraries] Add Microsoft.VisualBasic.Core.Tests ActiveIssue

* [MacCatalyst][libraries] Add System.Diagnostics.Process.Tests ActiveIssue

* [MacCatalyst][libraries] Add System.Threading.Thread.Tests ActiveIssue

* [MacCatalyst][libraries] Add System.IO.FileSystem.Tests ActiveIssue

* [MacCatalyst][libraries] Add System.Runtime.Extensions.Tests ActiveIssue

* [MacCatalyst][libraries] Remove test project level skips

* [MacCatalyst] Add forgotten PNSE and ActiveIssue

* [MacCatalyst][libraries] Coalesce MacCatalyst into iOS tvOS SkipOnPlatform

Co-authored-by: Mitchell Hwang <[email protected]>
2021-05-19 11:18:00 -04:00
Adam SitnikandDavid Cantú 82289b2559 Extend FileStreamOptions with BufferSize, allow to specify 0 to disable the buffering (#52928)
* extend FileStreamOptions with BufferSize

* allow to disable the buffering by setting bufferSize to 0

* Apply suggestions from code review

Co-authored-by: David Cantú <[email protected]>
2021-05-19 09:58:32 +02:00
4e4b8bf2d9 Allow to specify file preallocation size (#51111)
Co-authored-by: Carlos Sanchez <[email protected]>
Co-authored-by: David Cantú <[email protected]>
2021-05-18 09:52:03 +02:00
Elinor Fung 63ea9c6b96 Stop including some unused files for p/invokes (#52865) 2021-05-17 18:17:23 -07:00
5297337e5b [iOS][libraries] Skip failing iOS tests with ActiveIssues and proj level skips (#51491)
In effort to assess the state of the iOS library tests, a number of tests will be skipped

Test suites that crash, hang, or have a significant number of failures (mostly 20+ failing unique test methods) are skipped on at the `tests.proj` level. Otherwise, `[ActiveIssue]` attributes have been attached to either the individual test methods that fail or the entire class if the whole test class fails. Any pre-existing `ActiveIssue` attribute associated with iOS had been reassessed to either remain or be closed.

A few test suites have been skipped because they fail with some form of `PlatformNotSupportedException`. `[SkipOnPlatform]` attributes are attached to the failing test methods.

All of the Issues can be tracked at https://github.com/dotnet/runtime/projects/48#column-9236436

The ActiveIssues and `tests.proj` exclusions have been tested on https://github.com/dotnet/runtime/pull/49917 as well.

-----------
This PR makes the following changes in the following files:
`src/libraries/System.IO.Ports/tests/System.IO.Ports.Tests.csproj` - Removed `$(NetCoreAppCurrent)-iOS` from target frameworks as it is stated to currently only supported on Windows.

`src/libraries/tests.proj` - Update the test suites that need to be skipped at the project level, reducing the number and categorizing as a skip due to PNSE, a skip due to numerous failures, and a skip due to the suite crashing.

The remaining files changed are either:
`[ActiveIssue("<issue-url>", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]`
`[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS or tvOS.")]`

Co-authored-by: Mitchell Hwang <[email protected]>
Co-authored-by: Tammy Qiu <[email protected]>
2021-05-12 17:40:55 +02:00
Kareem ZedanandJan Kotas b08a97afb8 Task/use get last p invoke error (#52212)
* replacing GetLastWin32Error with GetLastPInvokeError in remaining assemblies

* replace GetLastWin32Error with GetLastPInvokeError in assemblies outside system.private.corelib

* Apply suggestions from code review

Co-authored-by: Jan Kotas <[email protected]>
2021-05-09 12:42:21 -07:00
Carlos Sanchezandcarlossanlop 6a81cfa4e8 Fix: FileSystemEntry.Attributes property is not correct on Unix (#52235)
* Hidden and ReadOnly unit tests.

* Unix: Correctly collect ReadOnly and Hidden flags from files and directories.

* Remove the _initialAttributes field from FileStatus. Directly call _status.GetAttributes from FileSYstemEntry.Attributes since the disk hit is necessary anyway.

* Address simplication and nullcheck suggestions

* Defering some more file checking actions to FileStatus. Addressing accessibility of methods/properties. Addressing suggestions.

* Address feedback: Remove unnecessary asserts but document why. Remove struct initialization. Simplify the order in which Initialize checks for unknown and symlink and add a comment.

* Cache egid and euid, and refresh should reset them

* Check IsNameHidden before ensuring cache initialized and checking HasHiddenFlag.

* The ifs inside FileSystemEntry.Initialize has two mutually exclusive conditions: symlink and unknown, so use else if.

* Use entry.IsSymbolicLink directly inside Initialize.

* Remove extra symlink check in FileSystemEnumerator.MoveNext, not needed and could cause unnecessary disk hit.

* Remove unused cache checks.

* Use HasHiddenFlag as expression body

* No need to soft retrieve hidden and read-only in FileSystemEntry.Initialize if in AttributesToSkip we are going to retrieve it anyway with a disk hit. Only in the case of DT_UNKNOWN, we will pre-retrieve the file cache, but we only need it when ShouldSkip is checked, and in that case, we won't have a disk hit.

* Make FileStatus.Initialize inlined in the only place where its called.

* EnsureCacheInitialized bring back order of conditions

* Syntax sugar for nullable egid and euid lazy retrieval

Co-authored-by: carlossanlop <Carlos Sanchez [email protected]>
2021-05-08 12:07:03 -07:00
Levi Broderick 65020c9462 Don't run "reserved device names" tests on Win10 (#52282) 2021-05-04 22:14:04 -07:00