The old System.IO.MemoryMappedFiles tests had decent coverage, but were lacking in a variety of ways:
- They were written in a legacy style that didn't take advantage of xunit capabilities, that made them difficult to augment, and that made them difficult to understand
- They were spread out across several projects in a seemingly haphazard manner.
- They left behind lots of temporary files
- They caused random test failures due to conflicting map names and file names.
- Their code coverage could have been a bit better, and they were missing coverage of some corner cases
This commit completely rewrites the tests, covering all of the old scenarios tested and more while removing 2/3rds of the code, increasing code coverage, avoiding race conditions on map and file names, cleaning up temporary files used, switching to using xunit features, and hopefully making the tests more understandable and augmentable in the future.
Commit migrated from https://github.com/dotnet/corefx/commit/803180f35b82bd1cc22f0bd6b30fe54b1d171c76
A bunch of the MMF tests were using PlatformNotSupported functionality, but didn't need to be doing so, e.g. a bunch of tests were specifying map names even when naming wasn't what was being tested, causing those tests to fail on Unix where we don't currently support named maps. This commit fixes up all such issues, along with other issues, like using platform-specific functionality such as P/Invokes to Win32 functions.
I also fixed a few general issues I happened to notice, such as places where temporary files weren't being cleaned up (on both Unix and Windows).
Commit migrated from https://github.com/dotnet/corefx/commit/1e5a69b6022660437983bb8f2cdf9bb1075ae363
Previously, we used the catch all OS=Unix property in MSBuild to
determine if we were building for Windows vs Unix, and we shared the
same MSIL between Linux and OSX. However, we have already started to
take dependencies on Linux specific APIs and we plan on using OSX
specific APIs very soon.
We don't want to try to ship MSIL that contains both Linux and OSX
specific implementations of a feature, so the build system needs to
change a little.
We'll continue to use the OS property as the entry point for the build
to specificy what platform you want to build for. However, we now have
three platforms:
1. Windows_NT
2. Linux
3. OSX
However, the value of the OS property should not be tested directly,
instead we introduce properties about the target platform itself:
1. TargetsWindows
2. TargetsUnix
3. TargetsLinux
4. TargetsOSX
Code which works the same across Linux and OSX should be guarded by
TargetsUnix (which is true when OS is either 'Linux' or 'OSX'). Code
specific to one OS can be guarded with either TargetsLinux or
TargetsUnix.
In this change, I have simply rewritten all the '$(OS)' == 'Unix'
conditions to '$(TargetsUnix)' == 'true'. A few libraries may do Linux
specific stuff, but we will clean up that debt when we go to flesh out
the OSX implementations.
Commit migrated from https://github.com/dotnet/corefx/commit/4d07173fbf86631d49ed56623581eff9cb7d3f87