Commit Graph
55 Commits
Author SHA1 Message Date
Ian Hays 2d30bdc229 Fix Filesystem tests failing from path changes
Changes in path validation disabled some of the FileSystem tests. Re-enable them with the new path logic in place.


Commit migrated from https://github.com/dotnet/corefx/commit/11d47f621e0064e5d6384486b4b4e4e02efb15e7
2016-06-06 13:56:48 -07:00
Ian Hays 7b3731e373 FileSystem: Implement WinRT File Enumeration
The enumeration in WinRTFileSystem is currently stubbed out to return an empty array. This commit adds an implementation with behavior matching the Win32FileSystem.


Commit migrated from https://github.com/dotnet/corefx/commit/5b97cc6e329f5575335a6e5e58e092b1bf94d7cb
2016-05-20 10:09:47 -07:00
Stephen Toub f0a80d94d6 Merge pull request dotnet/corefx#7575 from ianhays/filesystem-enumeratenonexistent
Filesystem enumeratenonexistent

Commit migrated from https://github.com/dotnet/corefx/commit/837ae6802afe6c9816edc4390952d076b38ccf35
2016-04-08 19:06:12 -04:00
Ian Hays afed9b997b Make FileSystem EnumerateCurrentDirectory test remote
Commit migrated from https://github.com/dotnet/corefx/commit/2b6f33c55f088ebe381f3b6996309258a8ea0667
2016-04-08 12:27:45 -07:00
Ian Hays d37159817a Add SetCurrentDirectory test for a symlink path
Commit migrated from https://github.com/dotnet/corefx/commit/0d6cf9c9497576454b0fb384aaa6e1420417de7a
2016-04-05 08:16:27 -07:00
Ian Hays 9cdc5a7d85 Add comment for OSX specific FileSystem test
Commit migrated from https://github.com/dotnet/corefx/commit/2bf968511290f0af037c3d607c7baad764928704
2016-03-31 11:56:10 -07:00
Ian Hays 6f1c9b0f5b Fix exception bug in SetCurrentDirectory
Commit migrated from https://github.com/dotnet/corefx/commit/0a522a6c7d473919b9c74decc1e6b918bea3ef4a
2016-03-31 11:50:46 -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 11bb3f3c94 Remove and replace some stale [ActiveIssue(...)]
Remove some stale [ActiveIssues] where the tests now pass.

Replace some others with [PlatformSpecific], where the behavior is deemed to be "by design" / accepted.

And update a few issue numbers.


Commit migrated from https://github.com/dotnet/corefx/commit/9c13b0c9389189d86fb2d270c28660946b3ae80c
2016-03-25 15:24:49 -04:00
Jon Hanna c13188394b Fix multiple typos
Commit migrated from https://github.com/dotnet/corefx/commit/4bfc0ab963a7880c0d4b90b82317fe65d7842eba
2016-03-20 14:36:30 +00:00
Jon Hanna 13b30e5b37 Fix multiple typos
Commit migrated from https://github.com/dotnet/corefx/commit/efd5b13b90c59c0d75bec38a9ef938e529061b5c
2016-03-20 01:28:47 +00: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
Eric Erhardt 06df0683f8 Enable all passing tests that are marked with ActiveIssue for dotnet/corefx#846.
Commit migrated from https://github.com/dotnet/corefx/commit/1071000be4db6c545867f0a7fc41a0c4a7419dfe
2016-01-15 14:13:27 -06:00
Jeremy Kuhne 9868dd72bf Merge pull request dotnet/corefx#3549 from JeremyKuhne/GetFullPath
Address perf for GetFullPath and defer to OS.

Commit migrated from https://github.com/dotnet/corefx/commit/acf5f71fbf8a6d6bf1081c6a9d326623b9337d78
2015-10-12 15:25:27 -07:00
Rainer Sigwald e2dd621454 Allow recursive Directory.Delete of paths with trailing slash
Fixes dotnet/corefx#3780.

FindFirstFile with a normal path will happily collapse multiple
backslashes into a single logical path separator, but when presented
with a `\\?\` path, that doesn't happen.  As a result, unconditionally
concatenating a path-separator was fine until RemoveDirectoryHelper was
always called with EnsureExtendedPrefix (which is needed for extended
path support, introduced in 0721434).  With that, Win32 FindFirstFile
returns an error if there's a double backslash in the path beyond the
prefix.


Commit migrated from https://github.com/dotnet/corefx/commit/cb3724deb88743495f8b73f56509267db9796300
2015-10-12 11:30:50 -05:00
Jeremy Kuhne 93dce22a24 Address perf for GetFullPath and defer to OS.
This change attempts to limit the number of allocations made when evaluating
full paths. This is particularly important when Windows paths can be way over
the historical max of 260 characters. (The new max is over 32K)

We no longer kick paths in Windows that are valid, outside of paths with colons
that are not directory separators. (This has the effect of blocking alternate
data stream access- which is a legacy behavior.)

When creating directories, we still drop the trailing separator, which causes
trailing whitespace to be trimmed. This makes it particularly difficult to create
paths with trailing spaces in .NET, which is still desirable as most code has
a tough time dealing with this scenario. We'll open them fine now, which hits
the above point of not kicking valid legacy paths (paths that don't require
extended syntax).

Several simplifications to the logic were made, including moving relative segment
evaluation to shared code and calling it directly when getting directory names
rather than relying on the not-so-obvious prior behavior of GetFullPath without
"full checks".


Commit migrated from https://github.com/dotnet/corefx/commit/11b457d1186c364bdf3e7d978006eb2417e8d060
2015-10-07 11:22:27 -07: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
Jeremy Kuhne 16099fc5a4 Move max path directory check up front.
No need to create a bunch of intermediate directories when we'll fail at the end.
This was having significant impact on test times with dotnet/corefx#3192.


Commit migrated from https://github.com/dotnet/corefx/commit/d5f7c91ac455244195135c48ab3b94bb24eeb78f
2015-09-21 22:52:39 -07:00
stephentoub b07d619076 Reduce FileSystem inner loop test time from 90 to 5 seconds
Three tests were consuming the vast majority of the time:
- DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsPathTooLongException. It was taking 70 seconds on my machine.  I moved it to outer loop.
- ManyConcurrentWriteAsyncs.  It uses a MemberData that results in it executing ~40 times, for a combined time of around 7 seconds on my machine.  I made one combination run in inner loop and moved the rest to outer.
- CopyToAsyncBetweenFileStreams.  Same MemberData, same solution.


Commit migrated from https://github.com/dotnet/corefx/commit/03205295cc6834b1fdcd8b7ba364515f4ec7164a
2015-09-12 19:46:49 -04: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
Dmitry Turin 946da9d4e3 Fix System.IO.FileSystem.Tests
System.IO.FileSystem.Tests leaves behind temp directories in %TMP%.
This commit fixes this issue.


Commit migrated from https://github.com/dotnet/corefx/commit/889d024aca35e0c98500f5b34e6db1dc9071edf7
2015-09-11 18:06:35 +03:00
Jeremy Kuhne b2782d7f70 Unblock paths > MAX_PATH without extended syntax.
Also allow directories up to max component length (255) as opening does not
require extended syntax.


Commit migrated from https://github.com/dotnet/corefx/commit/496c66e0b498077d5d349d324713a51be6b91c68
2015-08-28 15:32:31 -07:00
Ian Hays 1bc633088f Fixed test that was leaving temp directories in root folder
One of the Extended Path FileSystem tests was leaving temporary test directories in the root folder of the running directory. This small change modified the tests to instead treat the user's temp directory as the root.


Commit migrated from https://github.com/dotnet/corefx/commit/bd2d87d7abcf092840e0929c6df1116665f90460
2015-08-13 14:28:37 -07:00
Ian Hays e8723ef1b5 Cleaned up tests for closed issues
Design review feedback brought about the closed issues dotnet/corefx#2537, dotnet/corefx#2403, dotnet/corefx#2402, dotnet/corefx#2369, dotnet/corefx#1728. This Commit cleaned up the tests around those decisions and removed OuterLoop from the GetSetTimes tests.


Commit migrated from https://github.com/dotnet/corefx/commit/3eb22a0ef2eb007b8fc8410d1a0fefc23311dc08
2015-08-11 14:53:51 -07:00
Jeremy Kuhne 3b5bfc51a3 Allow extended long path directories
Add methods for checking max length as it varies on path format.

Most code paths hit PathTooLong with GetFullPath- directories are a special
case as Win32 apis have a special limit (248) for directory creation.


Commit migrated from https://github.com/dotnet/corefx/commit/6f363e65bfd09bebdf09ba236f63da952948ba8e
2015-08-09 19:19:27 -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
Stephen Toub 7b28c3d30e Merge pull request dotnet/corefx#2630 from stephentoub/consolidate_tempfiles
Change System.IO.FileSystem.Tests to use FileCleanupTestBase

Commit migrated from https://github.com/dotnet/corefx/commit/37b0abb008ef543e57cbe02e0b4435bc1908a303
2015-08-05 12:20:05 -04:00
stephentoub 2e9fbca627 Change System.IO.FileSystem.Tests to use FileCleanupTestBase
When I rewrote the MemoryMappedFiles tests, I cribbed from the
System.IO.FileSystem test's base class and created a Common base class
that could be used by test projects that had temporary files to be cleaned up.
At the time, however, FileSystem's tests were undergoing heavy changes and
so I didn't update FileSystem's tests to use the common base.  Now that
things have quieted down, I've made that change.

In doing so, I made a few tweaks to the FileSystem tests, where tests were
assuming that the test directory was always in the current directory, and
the consolidated base class puts temporary files in the user's temporary
directory instead.


Commit migrated from https://github.com/dotnet/corefx/commit/d7a19e92824e8a038553de20abf2497db0424ddb
2015-08-04 23:24:06 -04:00
stephentoub b6046f97e0 Fix UnixFileSystem.MaxDirectoryName to be MaxPath
UnixFileSystem's override of MaxDirectoryName was assuming the property meant the maximum size of the file name of a directory, i.e. the component length, not the full path length of everything from the beginning of the root.  As a result, checks against MaxDirectoryName, such as in CreateDirectory, were failing incorrectly with longer path lengths.

The fix is just to return MaxPath from MaxDirectoryName; there's no difference on Unix.  I also added a test to cover this case, included a previously excluded test, and deleted a faulty test.


Commit migrated from https://github.com/dotnet/corefx/commit/5de40bfa898dc2a03fd5efb3f21ea2f69d16a94a
2015-08-04 21:48:54 -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
Jeremy Kuhne 7f446020aa Allow extended syntax for paths
Additional work unblocking extended syntax. Fixes a few issues,
adds a number of tests, normalizes naming a bit more and moves/adds
helpers to shared code.

One nice side effect of this change is that you can now delete directories
that were undeletable before (if you had subdirectories that had trailing
spaces as one example).


Commit migrated from https://github.com/dotnet/corefx/commit/0721434e19e7f9ecf8bf6dba7485f6c86827388c
2015-07-23 19:17:34 -07:00
Jeremy Kuhne c25bace1a2 Merge pull request dotnet/corefx#2410 from JeremyKuhne/AllowExtended
Allow extended syntax for paths

Commit migrated from https://github.com/dotnet/corefx/commit/14e98f7acc0420c93218768f89dd69c9b4c12c86
2015-07-23 15:52:33 -07:00
Matt Mitchell b92c666b03 Enable globstar in run-test.sh
Globstar is not enabled by default, and a recent commit attempting to increase the number of directories being run for the Linux build actually skipped a bunch of stuff.  Enable globstar in the script (this is local) to fix.

Mark DriveLetter_Unix as a failing test, which appears to have snuck in in the meantime


Commit migrated from https://github.com/dotnet/corefx/commit/0b798760c7844e489bfb1432dd97b3ce184bb374
2015-07-23 10:28:52 -07:00
Jeremy Kuhne 911f36ebd9 Allow extended syntax for paths
Start on unblocking extended syntax. Moves some shared code to PathInternal.
Start adding tests for key scenarios. Temporarily use local libraries when
testing FileSystem (until we get an updated Runtime.Extensions package).


Commit migrated from https://github.com/dotnet/corefx/commit/72429b2ba76ebecb4c422a1d5eec05daf279b05e
2015-07-22 11:26:21 -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 6a4d9d4794 Fix System.IO.FileSystem's PathHelpers for Unix
The FileSystem's PathHelpers internal class contains some utility functions for processing paths.  Some of these functions are copies of non-exposed Path members, while others are unique.  A bunch of those members have Windows-specifics coded into them, which is causing problems when dealing with various special paths on Unix, for example paths that end with double dots, relative paths that begin with a space, etc.

This commit splits PathHelpers into a PathHelpers.cs, PathHelpers.Windows.cs, and PathHelpers.Unix.cs, and implements the Unix functions appropriately.

It also fixes up a variety of tests that are now failing because they were expecting the Windows behavior.


Commit migrated from https://github.com/dotnet/corefx/commit/5945d8ced21c36e091290fb92f15a5c1f4cb2274
2015-07-07 22:12:38 -04: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
stephentoub 4f3ed512b0 Fix FileSystem enumeration with broken symlinks
Today when enumerating directories, we look only for entries with DT_DIR (directory) or DT_REG (regular file); if we encounter something unknown or a symlink, we stat to resolve it and determine whether it's actually an S_IFDIR (directory) or S_IFREG (regular file). There are (at least) two problems with this:

1) The stat to a symlink will fail if the symlink points to a non-existent entry.
2) We end up skipping lots of special files, e.g. FIFOs.

The commit changes our logic to simply special case directories: we treat everything as a file unless we're sure it's a directory. This directly fixes (2), and indirectly fixes (1): our logic for DirectoryExists already ignores any stat errors, returning false if the symlink couldn't be resolved, such that this naturally maps to our desired behavior of broken symlinks being categorized as a file.


Commit migrated from https://github.com/dotnet/corefx/commit/5428c98a421fe7e5907c050a7e820f5045b61e61
2015-07-06 17:28:08 -04:00
Ian Hays f0f11fb21b -Updated with responses to PR feedback
-Added OSX checks for Case Sensitivity tests
-Fixed a bug within several Enumerable tests that was causing a test directory to be left over.
-Increased code coverage slightly for Directory.
-Added tests to ensure whitespace file names are acceptable on Unix machines and marked those tests with an ActiveIssue referencing the newly created dotnet/corefx#2205


Commit migrated from https://github.com/dotnet/corefx/commit/b86274bbc18186768156cf3534c25c4d48656a67
2015-07-06 09:07:05 -07: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
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