Commit Graph
36 Commits
Author SHA1 Message Date
Jeremy Kuhne 058ab2e451 Fix Unix missing file state (dotnet/corefx#19959)
* Fix Unix missing file state

In the original .NET implementation a missing file never
throws directly with FileInfo. Attributes get the error result
from Windows (-1) and times aren't initialized.

* Feedback

* Change FileSystemTest derivation

FileSystemTest should derive from RemoteFileSystemTest so
we can have one base class.

* Add RemoteExecutorBase to performance test project

* Address test feedback

* Fix File.GetAttributes on Unix

NetFX doesn't rely on FileInfo and throws when getting attributes
on missing files through File.


Commit migrated from https://github.com/dotnet/corefx/commit/801dde95a5eac06140d0ac633ac3f9bfdd25aca5
2017-05-19 13:20:11 -07:00
Morgan Brown 975ad3c685 Scale back [Serializable] CoreFX types (dotnet/corefx#19742)
* Remove SerializableAttribute from many CoreFX types that will not be serializable.

* Removes serialization tests for types that are no longer serializable and fixes serializing a couple of types. Includes marking some internal serializable types as public so that they'll be reflectible with .NET Native.

* Remove unneeded pragmas

* Update based on review comments


Commit migrated from https://github.com/dotnet/corefx/commit/6dd451f51451a7d0ceea6104b51bd17005e9a0e6
2017-05-16 18:16:29 -04:00
Stephen Toub 4724fbf441 Fix sharing violations caused by FileShare.Inherited
The FileShareOpen test has been failing sporadically with sharing violations.  It turns out the problem has to do with FileShare.Inheritable being included in the list of FileShare values to test.  If another test in the same process concurrently spawns a process while a FileShare.Inheritable file is open, that file's handle will be inherited into the child process, which will in turn keep the file in use for longer than the test expects.  When it then tries to re-open the file, it may encounter a sharing violation if the subsequent open is incompatible with the previous one's FileShare.


Commit migrated from https://github.com/dotnet/corefx/commit/041672ff3642753807a4502a4c407cb82bfa1009
2017-05-09 10:00:21 -04:00
Daniel Harvey 252cdc5e95 Bulk updates of tests for AssertExtensions (dotnet/corefx#18491)
Bulk update to AssertExtensions.Throws for AOT support. This doesn't disable Assert.Throws.

Commit migrated from https://github.com/dotnet/corefx/commit/b43b4df2e0e2182154bb0f425cb4a61bc1269828
2017-04-18 09:52:02 -07:00
Ian Hays ebe8f66e34 Get IO.FileSystem tests running on NetFX
There were a high number of failing FileSystem tests for NetFX. This PR modifies the tests to run on NetFX without failures and adds comments for the reasons for the tests that had to be disabled.


Commit migrated from https://github.com/dotnet/corefx/commit/7d7b9be2c0eb870658722b1b78f850fbb08b4a97
2017-03-30 12:16:21 -07:00
sepidehMS e3d734c19d Add comments to PlatformSpecific tests
Commit migrated from https://github.com/dotnet/corefx/commit/493cb79ff4976479be5cc7c6f1fe2d5d9b710425
2017-02-07 15:46:26 -08:00
Santiago Fernandez Madero ce1b82e2b0 Add Replace methods to System.IO.FileInfo (dotnet/corefx#13563)
* Add Replace methods to System.IO.FileInfo


Commit migrated from https://github.com/dotnet/corefx/commit/2b0ce9c6f76cf2d68d79032f220cabe97eb4e676
2016-11-10 21:35:16 -08:00
Stephen Toub 8bc0c7486e Add System.IO.FileSystem serialization
Commit migrated from https://github.com/dotnet/corefx/commit/a8c26b8f37139e7b2fc25acd8859b1782319dcd6
2016-10-17 23:26:49 -04:00
Justin Van Patten aa68f5ce2f Replace uses of Xunit.PlatformID with renamed TestPlatforms
Replace uses of `Xunit.PlatformID` with renamed `TestPlatforms` because
the old name conflicts with `System.PlatformID` and should be plural
according to the design guidelines for flags enums.


Commit migrated from https://github.com/dotnet/corefx/commit/5179dda7331b1e201519adf76ce9ae69ffe2a0f6
2016-10-01 17:18:41 -07:00
Jose Perez Rodriguez a27ef1f7be Reving up the versions of the contracts where we have added Apis for netcoreapp1.1 (dotnet/corefx#10531)
Reving up the versions of the contracts where we have added Apis for
netcoreapp1.1

Commit migrated from https://github.com/dotnet/corefx/commit/62334804aa655a250838eefed68553f357ebec5f
2016-08-04 13:05:12 -07:00
Ian Hays 9d790f57d4 Add missing tests to System.IO.FileSystem
Adds missing tests to achieve strictly higher coverage than ToF and also adds some other new tests and cleans up existing tests.


Commit migrated from https://github.com/dotnet/corefx/commit/09e70d429a7c89abed1514a90667e0088f903d4c
2016-03-31 11:11:17 -07:00
stephentoub b540d002e5 Centralize case-sensitive PlatformID checks in FileSystem tests
Commit migrated from https://github.com/dotnet/corefx/commit/4f1d4382f5def0c000ff860f02dd02b1998e1017
2016-03-04 07:28:29 -05:00
stephentoub 7c4a049b44 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/09efd6b341ba83e7b5edd54af6600432fa8604ba
2016-03-03 17:57:55 -05:00
stephentoub 4f301f6e7c Fix System.IO.FileSystem handling of symlinks
We've visited this topic a few times... hopefully this is the last.  We previously misunderstood some of how Windows handles symlinks, leading us to make some invalid choices on Unix.  This addresses those issues.

For the most part with this commit, we now match Windows behavior on Unix wherever possible, while also trying to do something sensible on the Unix side.  The only notable difference now comes into play for broken symlinks, due to a fundamental difference between symlinks on Windows and Unix: on Windows, a symlink is created as either a file or directory symlink and thus .NET can tell which it is even if it's broken... on Unix, a symlink only stores a path to its target, so when it's broken, there's no information about whether it's intended to be a file or a directory.  As a result, we fall back to always treating it as a file.


Commit migrated from https://github.com/dotnet/corefx/commit/59da18fc926397f6674e1de86e296ca6e0dfe067
2016-03-02 13:40:27 -05:00
dotnet-bot 01a4f8e52c Deploy nameof throughout corefx in ConditionalFact/Theory
Commit migrated from https://github.com/dotnet/corefx/commit/0f9f72dec0493aa3d90fb4a5e22d7b62ffd79f79
2016-02-18 23:58:17 -05:00
dotnet-bot 39d1eab950 Update licensing headers
Commit migrated from https://github.com/dotnet/corefx/commit/7cad8486cbabbce0236bdf530e30db7036335524
2016-01-27 08:02:28 -08:00
stephentoub 9386f54542 Make Directory/FileInfo follow symlinks again
Previously on unix we would use stat to get information about directories and files for DirectoryInfo and FileInfo.  That meant that we wouldn't correctly report ReparsePoint for symlinks, and the code was changed to use LStat.  But that then breaks important use cases, such as by DirectoryInfo.Exist for a symlink to a directory always returning false.

This commit provides a compromise: we first use lstat, and if we find it's a symlink, we use stat but remember separately that it's a symlink so we can include ReparsePoint in the reported attributes.


Commit migrated from https://github.com/dotnet/corefx/commit/36259dc3c72fb1dc2a71a06db6f7dce9ea88c642
2016-01-22 16:35:23 -05:00
Mike Rousos 3d2b633341 Get Unix file stats with LStat (instead of Stat)
Stat was ignoring symbolic links (and getting stats for the target
instead) which caused checks for whether or not a path was a sym link
to fail on Unix.

Fixes dotnet/corefxdotnet/corefx#5015


Commit migrated from https://github.com/dotnet/corefx/commit/967cde5486cb290718b4b8f7779ccf832d5f4325
2016-01-14 12:06:45 -08:00
Stephen A. Imhoff a8ce720bd6 Update test namespace in System.IO.FileSystem
Update test namespace where applicable.
Cleanup `using`s in updated files.


Commit migrated from https://github.com/dotnet/corefx/commit/5b5717c2eb8fc88ed5bd59babe39890c581ad622
2015-09-25 21:30:57 +09:00
Ian Hays 0e2ae5be2d Fixed test bug with FileInfo_GetSetTimes
resolves dotnet/corefx#3272


Commit migrated from https://github.com/dotnet/corefx/commit/50aa6bbfd3921a9312392f534c5986a193486c35
2015-09-16 11:03:32 -07:00
Ian Hays 71345b4a45 Fixed OSX file creation time format
FileInfo.CreationTime on OSX was returning a correctly timed but incorrectly formatted DateTime. This commit fixes this issue and adds coverage to a existing test to fill the test gap that let the issue through.


Commit migrated from https://github.com/dotnet/corefx/commit/e59a99c6628b817e95a43880fe14cbf602602b9e
2015-09-14 10:51:15 -07:00
stephentoub 8b936e6509 Fix failing FileSystem tests on OS X
Several FileSystem tests are failing on OS X because the tests are expecting that file/directory creation time can be changed on Unix.  Fixing the tests.


Commit migrated from https://github.com/dotnet/corefx/commit/12c0d738a0c234b707b0c99e40b3cb760df8096e
2015-09-11 14:51:53 -07:00
Ian Hays 6f2190dc4e Fixed AccessTime, WriteTime, and CreationTime getters
Previously, AccessTime, WriteTime, and CreationTime would return DateTime objects with an unspecified DateTimeKind. This commit modified that behavior to have them instead return Local DateTime objects. Extra tests were also added to catch more potential error cases.

- Resolves dotnet/corefx#2603
- Resolves dotnet/corefx#2610


Commit migrated from https://github.com/dotnet/corefx/commit/df06e562a49b739655efff4b6b9f0faa23d09b78
2015-08-07 10:16:52 -07:00
stephentoub d6467ac0af Use RuntimeInformation across corefx for platform detection
This commit deletes our temporary Interop.PlatformDetection.cs mechanism and replaces usage of it with usage of System.Runtime.InteropServices.RuntimeInformation.dll.


Commit migrated from https://github.com/dotnet/corefx/commit/6861b625b391566544be9a60356c8c03b15e5fb5
2015-08-06 10:25:17 -04:00
Ian Hays 8d7c94172a - Resolves dotnet/corefx#2458. FileInfo.Open(FileMode.Append) didn't allow appending per so I modified FileInfo to allow it
- References dotnet/corefx#2460. File.Move and FileInfo.MoveTo no longer always overwrite the destination file; added a non-concurrent validity check to MoveFile in the Unix implementation to serve as a temporary solution.
- Resolves dotnet/corefx#2459. Reenabled Directory_CreateDirectory.DriveLetter_Unix as it's previous failures were not the fault of the method but of the system.
- Added test checks to work around the issue in dotnet/corefx#2537 until a final decision is reached for the desktop.
- Added Interop.Link to the Interop files for the (possible) implementation of File.Move
- Consolidated all of the related files that did nothing but inherit from other classes (e.g. File_GetFiles_str and File_GetFiles_str_str were consolidated into File_GetFiles)
- Removed the "partial" keyword from some test classes
- Finished overhauling all test cases that don't directly require solutions to Build System issues before being re-added (e.g. those that require networked drives or altering the current directory)
- Added some tests to increase code coverage slightly in some cases.
- All classes and files have been renamed to match the standard set by FileStream: only include parameters in the test/class name if there are overloads
- Modified the Unix behavior for distinguishing between a FileNotFoundException and a DirectoryNotFoundException to match that of Windows.
- Removed some redundant error checks that never catch
- DirectoryInfo.MoveTo(destPath) did not have checks for destinations with paths that are over MAXPATH. I added them to better match the behavior and error timing of Directory.Move(source, dest).


Commit migrated from https://github.com/dotnet/corefx/commit/481d5c645763da79145af50d123db3f4041aa05e
2015-07-29 08:04:18 -07:00
Ian Hays 55cc5920f4 Updated with PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/3098724684d3a9e2916fbf2100643301d9161127
2015-07-21 13:41:48 -07:00
Ian Hays 67541b0365 Update to FileSystem Tests
- Consolidated AccessTime, WriteTime, and CreationTime tests for FileInfo, File, DirectoryInfo, and Directory into one file per folder - GetSetTimes.cs
- Added some Unix tests
-Overhauled the Write/Read/Append tests for the File class and removed many duplicate tests
-Continuation of dotnet/corefx#2390


Commit migrated from https://github.com/dotnet/corefx/commit/5aebb5487de9fd481e3dd294c9d49aa25361dde2
2015-07-20 14:43:18 -07:00
Ian Hays 98b6021d8d -System.IO.UnixFileSystem has an issue with the "overwrite" being interpreted backwards. I simply reversed the conditional statement to be correct. There were previously no tests to cover this possibility. Resolves dotnet/corefx#2276
-Updated over a dozen test files to use the modern Xunit syntax.
-Solved file-in-use concurrency issues in the altered tests. Resolves dotnet/corefx#1313, dotnet/corefx#2227
-Tests will no longer intermittently fail.
-Slightly improved code coverage for the FileSystem files whose tests I altered (Directory, DirectoryInfo, File, FileInfo)
-Most tests altered now inherit from similar tests to consolidate the testing robustness into as few locations as possible. For example, Directory_GetFiles_str now inherits from Directory_GetFileSystemEntries_str since the tests for Directory_GetFiles_str were the exact same ones as in Directory_GetFileSystemEntries_str anyways.
-All altered tests now use the System.IO.FileSystem.Tests namespace
-Renamed the File_WriteAll_all class name/file name to File_WriteAllText.
-I tested my changes on Windows overnight to verify that there is no more intermittent test failures. I didn't have to modify all of the files listed in dotnet/corefx#2227 to get them to pass; this concerns me but I found no way to replicate the errors I was receiving before. My guess would be that the tests in the files I didn't alter (e.g. File_WriteAll and File_ReadAll) used the same names as the tests I did alter but now that the tests I altered are changed they no longer share test file names and no longer fail as a result.


Commit migrated from https://github.com/dotnet/corefx/commit/d21ce06332afe7aba0a52491187983744c10b4a4
2015-07-13 13:00:43 -07:00
stephentoub f574e42e5c Fix FileSystem tests for Unix
A bunch of the FileSystem tests assume that certain paths are always invalid, but many such paths are valid on Unix.  This commit fixes the tests that are failing after the revised Path implementation.


Commit migrated from https://github.com/dotnet/corefx/commit/f0882d6673308cded7726cd5f3fd8e2b448a3415
2015-07-06 20:53:20 -04:00
Ian Hays 1f363026a5 -Running the FileSystem tests no longer leaves test directories or files in the running directory. fixes dotnet/corefx#1412
-Modernized the tests for GetFIleSystemEntries and GetFiles, splitting each test case into a standalone method runnable through xunit. Similar versions of these tests now inherit from each other rather than just being copy-pasted like they were previously. Moved most test cases from using hardcoded file names to instead use GetTestFileName() in FileSystemTest.cs. Tested on Linux and Windows.
-Changed the names of some files and classes to better follow the naming conventions of the other FileSystem tests.


Commit migrated from https://github.com/dotnet/corefx/commit/9e20082a9498f2f9bf79bcebe80fd1f9efc1e39b
2015-06-30 11:31:01 -07:00
Matt Mitchell da7f2b4ca9 Fix a couple issues discovered during unit test stress
Commit migrated from https://github.com/dotnet/corefx/commit/98b480e13e87542b27330fc71deb1a2d7bd8b7e1
2015-05-28 17:08:10 -07:00
Stephen Toub 8b8bb05512 Fix a few more FileSystem tests on Unix
https://github.com/dotnet/coreclr/pull/823 fixes an where '*' and '?' are treated as invalid path characters.  Once that's fixed, some additional FileSystem tests that were expecting '*' and '?' to be invalid start failing on Unix.  This commit fixes those tests.

The fixes are all of either two flavors: using Interop.IsWindows to only run the test on Windows, or changing the path to include characters also invalid on Unix (namely '\0').  A bit arbitrary, but I used the former when there was a comment saying that wildcards were being tested, and I used the latter when there was a comment saying that illegal characters were being tested.


Commit migrated from https://github.com/dotnet/corefx/commit/d3fb391ef0d6505bd0f2f4bb6c269c4c96c126a3
2015-04-26 10:53:41 -04:00
Stephen Toub d45ff6b386 Fix FileSystem, Pipes, and MemoryMappedFiles bugs on OSX
Most of our testing until now has been on Linux.  This PR represents a pass through the tests on OSX and provides fixes to get the System.IO.FileSystem, System.IO.Pipes, and System.IO.MemoryMappedFiles tests passing at 100%.  Most of these fixes are product fixes, with just a few test fixes.

Primary src fixes:
- Lots of named values (errors, open flags, sysconf names, etc.) have different values across Linux and OSX: I've fixed those to be specific to the platform being compiled for. (In the future, we should consider introducing a native shim layer through which we make _all_ calls to Unix and have it surface a consistent view, so that we don't have to worry about this kind of issue.)
- Some functions or options to functions being used on Linux don't exist on OSX, e.g. madvise's DONTFORK, posix_fadvise, etc.; these have either been removed if not truly needed or moved behind the PAL layer to only be used on Linux.
- Some functions (e.g.  shm_open) have different behavior from Linux.  For example, shm_open doesn't appear to work well with shared memory objects, such as not allowing MAP_PRIVATE and not supporting PROT_EXEC (though the OSX man pages don't mention this).  In such cases, I've implemented a fallback, e.g. on OSX we use a temporary file rather than a shared memory object.
- Some functions have subtle differences around edge cases, e.g. mmap on Linux appears to allow the creation of a map with length that goes beyond that of the underlying medium, but then fails when trying to use it, whereas OSX moves the failure to the mmap call itself.  I've implemented workarounds to smooth over these differences.
- Various error conditions were resulting in the wrong exception type based on different exception codes being returned on OSX than on Linux, e.g. additional error codes needed to be mapped to IOException when rmdir fails.
- Replaced direct usage of getenv through P/Invoke with calls to Environment.GetEnvironmentVariable. (These are a holdover from when we didn't yet have GetEnvironmentVariable available.)
- Fixed up a few places we could be using CheckIo but instead had effectively written out its implementation manually.

Primary test fixes:
- Some of the file system tests are just plain buggy, regardless of platform, with timing issues that are more likely to show up on a debug runtime.  I've fixed the ones that manifested while I was doing this testing, but the file system tests really deserved to be overhauled in general.
- Windows' implementation of File/DirectoryInfo returns default values for CreationTime when created for a file that doesn't exist; this appears to be purely for back compat with previously buggy behavior, so I changed the test to only verify this on Windows, rather than implement similar buggy behavior on Linux/OSX.
- A few test cases that were previously exempted for Linux also needed to be exempted for OSX.
- Re-enabled the System.Dynamic.Runtime.Tests now that the associated runtime error that was causing them to fail has been fixed.


Commit migrated from https://github.com/dotnet/corefx/commit/5a912670b442f7f7984b6d7f0be190213f726fd4
2015-04-21 12:02:02 -04:00
Stephen Toub cdf97700fa Fix System.IO.FileSystem product source and tests for Linux
Prior to this set of changes, 110 of the FileSystem tests were failing on Linux.  After this change, all allowed tests pass.

Primary product fixes:
- Using rmdir/unlink for directory/file deletion rather than using remove
- Disallowing FileStreams to be opened for directories
- Supporting copying files when only target directory (not target name) is specified
- Overhauling directory enumeration to ensure to match Win32 behaviors related to search pattern normalization, input validation, supporting re-iteration through an enumerable, outputting partial paths based on user-supplied path, using a SafeHandle to ensure resources are cleaned up
- Fixing FileSystemObject.LastWriteTime to correctly return the LastWriteTime rather than LastAccessTime
- Fixing FileAttributes.ReadOnly handling due to inappropriate caching
- Validating inputs to FileSystemObject.Attributes, and make sure that changes to attributes are visible afterwards
- Adding support for getting CreationTime if it's supported by the OS
- Marking links with FileAttributes.ReparsePoint
- Working around current runtime bug related to exception handling and finally blocks getting executed twice

Primary test fixes:
- Suppressing tests as platform-specific that dependend on Win32-isms like drive letters, alternate data streams, etc.
- Changing a bunch of '\' usage to instead use Path.DirectorySeparatorChar or Path.Combine
- Adapting to behavioral differences between Windows and Unix, e.g. whether a directory can be deleted if it's readonly, invalid path characters, max path lengths, file sharing differences, etc.

These changes should all accrue to OSX as well, but we'll need to separately do an exercise to clean this library and tests up there for anything OSX-specific.


Commit migrated from https://github.com/dotnet/corefx/commit/dd48c9dc1f0a7142a005ff1d4c162e10facda306
2015-04-10 13:13:34 -04:00
Stephen Toub 54fb8cec30 Lots of FileSystem test fixes for Unix
The FileSystem tests are a mess... including on Windows, but especially on Unix.  Before the File/Directory/etc. tests got checked in, the FileSystem tests (which then were really only for FileStream and were fairly clean) could run on Unix, with 25 of the 360 tests failing due primarily to lack of support for FileShare options.  Now, with ~575 tests, when run on Unix more than 300 fail, runtime assertions occur in multiple places, and worst, all of the files in your working directory end up getting deleted!

This commit has a first set of fixes, primarily involving ensuring that paths are specified appropriately, with hundreds of changes to ensure that the right path separator is used, that particular roots aren't assumed, etc.  After this commit, on Unix we're down from > 300 failures to 114 failures, and the suite is able to finish running without deleting the working directory.


Commit migrated from https://github.com/dotnet/corefx/commit/d9465170db0be15a6e8d8ca6ba591a358f709ec5
2015-03-31 16:32:43 -04:00
dotnet-bot 58d9a445c5 Add ported System.IO.FileSystem tests
Add ported System.IO.FileSystem tests for Directory, DirectoryInfo,
File, FileInfo.


Commit migrated from https://github.com/dotnet/corefx/commit/25841a3761cab292153bd0a917a4ce192be8ffab
2015-03-27 14:31:02 -07:00