diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index a042993849156..fb7db1e40d04f 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -47,9 +47,7 @@ public static partial class PlatformDetection public static bool IsNotFedoraOrRedHatFamily => !IsFedora && !IsRedHatFamily; public static bool IsNotDebian10 => !IsDebian10; - public static bool IsSuperUser => IsBrowser ? false : (!IsWindows ? - libc.geteuid() == 0 : - throw new PlatformNotSupportedException()); + public static bool IsSuperUser => IsBrowser || IsWindows ? false : libc.geteuid() == 0; public static Version OpenSslVersion => !IsOSXLike && !IsWindows ? GetOpenSslVersion() : diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index 85c5bf045bf3f..e0ed6cadfd687 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -91,7 +91,10 @@ c_static_assert(PAL_S_IFSOCK == S_IFSOCK); // Validate that our enum for inode types is the same as what is // declared by the dirent.h header on the local system. // (AIX doesn't have dirent d_type, so none of this there) -#if defined(DT_UNKNOWN) +// WebAssembly (BROWSER) has dirent d_type but is not correct +// by returning UNKNOWN the managed code properly stats the file +// to detect if entry is directory or not. +#if defined(DT_UNKNOWN) || defined(TARGET_WASM) c_static_assert((int)PAL_DT_UNKNOWN == (int)DT_UNKNOWN); c_static_assert((int)PAL_DT_FIFO == (int)DT_FIFO); c_static_assert((int)PAL_DT_CHR == (int)DT_CHR); @@ -345,10 +348,13 @@ static void ConvertDirent(const struct dirent* entry, DirectoryEntry* outputEntr // the start of the unmanaged string. Give the caller back a pointer to the // location of the start of the string that exists in their own byte buffer. outputEntry->Name = entry->d_name; -#if !defined(DT_UNKNOWN) +#if !defined(DT_UNKNOWN) || defined(TARGET_WASM) // AIX has no d_type, and since we can't get the directory that goes with // the filename from ReadDir, we can't stat the file. Return unknown and // hope that managed code can properly stat the file. + // WebAssembly (BROWSER) has dirent d_type but is not correct + // by returning UNKNOWN the managed code properly stats the file + // to detect if entry is directory or not. outputEntry->InodeType = PAL_DT_UNKNOWN; #else outputEntry->InodeType = (int32_t)entry->d_type; diff --git a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs index 58a515e0b7d43..67d9655b1fee5 100644 --- a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs @@ -41,6 +41,7 @@ public static TimeFunction Create(SetTime setter, GetTime getter, DateTimeKind k } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40528", TestPlatforms.Browser)] public void SettingUpdatesProperties() { T item = GetExistingItem(); @@ -77,6 +78,7 @@ public void CanGetAllTimesAfterCreation() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support millisec granularity + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void TimesIncludeMillisecondPart() { T item = GetExistingItem(); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs index 5b3b2dcbf79b1..78c234d5627cd 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs @@ -210,17 +210,26 @@ public void DirectoryEqualToMaxDirectory_CanBeCreatedAllAtOnce() Assert.Equal(path, result.FullName); Assert.True(Directory.Exists(result.FullName)); } + #endregion + + #region PlatformSpecific [Theory, MemberData(nameof(PathsWithComponentLongerThanMaxComponent))] + [PlatformSpecific(~TestPlatforms.Browser)] // Browser does not have a limit on the maximum component length public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException(string path) { AssertExtensions.ThrowsAny(() => Create(path)); } - #endregion - - #region PlatformSpecific + [Theory, + MemberData(nameof(PathsWithComponentLongerThanMaxComponent))] + [PlatformSpecific(TestPlatforms.Browser)] // Browser specific test in case the check changes in the future + public void DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowException(string path) + { + DirectoryInfo result = Create(path); + Assert.True(Directory.Exists(path)); + } [Theory, MemberData(nameof(PathsWithInvalidColons))] [PlatformSpecific(TestPlatforms.Windows)] diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs index 386b847728ebe..00d5c46cef7ea 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs @@ -244,6 +244,7 @@ public void RecursiveDelete() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)] public void RecursiveDeleteWithTrailingSlash() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs index 04b1411fca3a5..44d07e2c7749d 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs @@ -390,7 +390,7 @@ public void SubdirectoryOnNonExistentDriveAsPath_ReturnsFalse() } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Makes call to native code (libc) + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Makes call to native code (libc) public void FalseForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs index 3dcd99c3a44cf..c5a145c686cff 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs @@ -173,6 +173,7 @@ public void DirectoryNameWithSpaces() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)] public void TrailingDirectorySeparators() { string testDirSource = Path.Combine(TestDirectory, GetTestFileName()); diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs index 615bd4c1b1dbf..1be25240b0d6a 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs @@ -110,7 +110,7 @@ public void FalseForFile() } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void FalseForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs index e5e5478fcb39d..fba22eb092824 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs @@ -24,6 +24,7 @@ protected virtual void Move(DirectoryInfo sourceDir, string destDir) #region UniversalTests [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)] public void DirectoryPathUpdatesOnMove() { //NOTE: MoveTo adds a trailing separator character to the FullName of a DirectoryInfo diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs index 52e08f5c6a08f..30021757a4d6d 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs @@ -8,6 +8,7 @@ namespace System.IO.Tests public class DirectoryInfo_Name : FileSystemTest { [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/39998", TestPlatforms.Browser)] public void CurrentDirectory() { var info = new DirectoryInfo("."); diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index 2c330cb0b2e70..675b86ccda22d 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -102,6 +102,7 @@ public void DeleteDirectoryAfterOpening() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); @@ -119,6 +120,7 @@ public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs index 9da51a7cd6073..e0b69578aca99 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs @@ -108,6 +108,7 @@ public static IEnumerable CopyFileWithData_MemberData() [Theory] [MemberData(nameof(CopyFileWithData_MemberData))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40543", TestPlatforms.Browser)] public void CopyFileWithData(char[] data, bool readOnly) { string testFileSource = GetTestFilePath(); @@ -140,7 +141,10 @@ public void CopyFileWithData(char[] data, bool readOnly) } // Ensure last write/access time on the new file is appropriate - Assert.InRange(File.GetLastWriteTimeUtc(testFileDest), lastWriteTime.AddSeconds(-1), lastWriteTime.AddSeconds(1)); + if (PlatformDetection.IsNotBrowser) // There is only one write time on browser vfs + { + Assert.InRange(File.GetLastWriteTimeUtc(testFileDest), lastWriteTime.AddSeconds(-1), lastWriteTime.AddSeconds(1)); + } Assert.Equal(readOnly, (File.GetAttributes(testFileDest) & FileAttributes.ReadOnly) != 0); if (readOnly) diff --git a/src/libraries/System.IO.FileSystem/tests/File/Create.cs b/src/libraries/System.IO.FileSystem/tests/File/Create.cs index 405d1f92ba690..447bb323baffd 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Create.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Create.cs @@ -111,6 +111,7 @@ public void InvalidDirectory() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void FileInUse() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); @@ -144,7 +145,12 @@ public void OverwriteReadOnly() Assert.True(File.Exists(testFile)); } + #endregion + + #region PlatformSpecific + [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // Browser platform volume does not limit segments public void LongPathSegment() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); @@ -153,10 +159,6 @@ public void LongPathSegment() Create(Path.Combine(testDir.FullName, new string('a', 300)))); } - #endregion - - #region PlatformSpecific - [Fact] [PlatformSpecific(TestPlatforms.AnyUnix)] public void LongDirectoryName() diff --git a/src/libraries/System.IO.FileSystem/tests/File/Exists.cs b/src/libraries/System.IO.FileSystem/tests/File/Exists.cs index 40d5ebce3d4b7..225ed8e04e892 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Exists.cs @@ -247,7 +247,7 @@ public void DirectoryWithComponentLongerThanMaxComponentAsPath_ReturnsFalse(stri } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void FalseForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs index a7840ebf94919..07140ac9c4ee5 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs @@ -13,7 +13,7 @@ public class File_GetSetTimes : StaticGetSetTimes { // OSX has the limitation of setting upto 2262-04-11T23:47:16 (long.Max) date. // 32bit Unix has time_t up to ~ 2038. - private static bool SupportsLongMaxDateTime => PlatformDetection.IsWindows || (RuntimeInformation.ProcessArchitecture != Architecture.Arm && RuntimeInformation.ProcessArchitecture != Architecture.X86 && !PlatformDetection.IsOSXLike); + private static bool SupportsLongMaxDateTime => PlatformDetection.IsWindows || (!PlatformDetection.Is32BitProcess && !PlatformDetection.IsOSXLike); protected override string GetExistingItem() { @@ -135,6 +135,7 @@ public void SetLastWriteTimeTicks() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support nanosecond granularity. + [ActiveIssue("https://github.com/dotnet/runtime/issues/40532", TestPlatforms.Browser)] public void SetUptoNanoseconds() { string file = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index b6b47961363b2..a5d9b5ee9952f 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -80,6 +80,7 @@ public void Overwrite() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -105,7 +106,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index 598fc0184871e..3c46acff8b4b7 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -94,6 +94,7 @@ public async Task OverwriteAsync() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -119,7 +120,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index d5ef0eed9cee0..62ff39339e2be 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -78,6 +78,7 @@ public virtual void Overwrite() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -111,7 +112,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -266,6 +267,7 @@ public virtual void Overwrite() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -299,7 +301,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 87b3ad7df7cb6..d717e2839956e 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -76,6 +76,7 @@ public virtual async Task OverwriteAsync() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -106,7 +107,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index e511b69540c7b..9d330b27583ea 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -85,6 +85,7 @@ public virtual void Overwrite() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -118,7 +119,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 33813987cd10a..ac77b2509bb1a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -84,6 +84,7 @@ public virtual async Task OverwriteAsync() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -114,7 +115,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!OperatingSystem.IsWindows() && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs b/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs index 777a5448afc76..b0f1779745f61 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs @@ -91,7 +91,7 @@ public void FalseForDirectory() } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void TrueForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs index b27adf59f27c8..27b2e845868bc 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs @@ -104,6 +104,7 @@ public override IEnumerable TimeFunctions(bool requiresRoundtrippi } [ConditionalFact(nameof(isNotHFS))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void CopyToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); @@ -118,6 +119,7 @@ public void CopyToMillisecondPresent() } [ConditionalFact(nameof(isNotHFS))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void CopyToNanosecondsPresent() { FileInfo input = GetNonZeroNanoseconds(); @@ -160,6 +162,7 @@ public void MoveToMillisecondPresent_HFS() } [ConditionalFact(nameof(isNotHFS))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void MoveToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs index 0bf573c15cb85..bb1c7836e95e7 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs @@ -43,6 +43,7 @@ public void CanSeekFalseForDisposedStream() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public void CanSeekReturnsFalseForPipe() { using (var pipeStream = new AnonymousPipeServerStream()) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs index da7145719b90d..6141240ce7f76 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs @@ -177,6 +177,7 @@ public static IEnumerable File_AllDataCopied_MemberData() [Theory] [InlineData(10, 1024)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeViaFileStream_AllDataCopied(int writeSize, int numWrites) { long totalLength = writeSize * numWrites; diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs index ba965283fb16b..b9552084b60e3 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs @@ -135,6 +135,7 @@ public void FlushCallsFlush_flushToDisk_False() [InlineData(null)] [InlineData(false)] [InlineData(true)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public void FlushCanBeUsedOnPipes_Success(bool? flushToDisk) { using (var pipeStream = new AnonymousPipeServerStream(PipeDirection.In)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs index 7c6f08e2057ee..fd366dc702fff 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs @@ -15,6 +15,7 @@ public class Pipes : FileSystemTest [Theory] [InlineData(true)] [InlineData(false)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeWriteViaFileStream(bool asyncWrites) { using (var server = new AnonymousPipeServerStream(PipeDirection.In)) @@ -70,6 +71,7 @@ await Task.WhenAll( [Theory] [InlineData(true)] [InlineData(false)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeReadViaFileStream(bool asyncReads) { using (var server = new AnonymousPipeServerStream(PipeDirection.Out)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs index f6b74164f5ac4..4d66807a3c993 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs @@ -23,7 +23,7 @@ public void DisposedStream_ReadWrite_Throws() Assert.Throws(() => fs.Write(new Span(new byte[1]))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void EmptyFile_Read_Succeeds() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) @@ -46,7 +46,7 @@ public void EmptyFile_Read_Succeeds() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void NonEmptyFile_Read_GetsExpectedData() { string fileName = GetTestFilePath(); @@ -111,7 +111,7 @@ public void EmptyWrites_NoDataWritten() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void NonEmptyWrite_WritesExpectedData() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs index 5f606907dcb2a..7b236db7b4b2f 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs @@ -276,7 +276,7 @@ public static IEnumerable MemberData_FileStreamAsyncWriting() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public Task ManyConcurrentWriteAsyncs() { // For inner loop, just test one case diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs index b719725f2a453..805354e31cd44 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs @@ -121,6 +121,7 @@ public void FileShareOpenOrCreate() [Theory] [InlineData(FileMode.Create)] [InlineData(FileMode.Truncate)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void NoTruncateOnFileShareViolation(FileMode fileMode) { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs index 6f1abef3d17ad..e0d619187c399 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs @@ -40,6 +40,7 @@ public void FileShareWriteExisting() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void FileShareWithoutWriteThrows() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs new file mode 100644 index 0000000000000..afaa1cc90e916 --- /dev/null +++ b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +using Xunit; + +namespace System.IO.Tests +{ + public abstract partial class FileSystemTest + { + protected static int mkfifo(string path, int mode) + { + throw new PlatformNotSupportedException(); + } + } +} diff --git a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj index e0769d47d16a4..7115d412c0742 100644 --- a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj +++ b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj @@ -46,12 +46,15 @@ - + + + + diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs index f23da731a67ef..4a08c3f7e3a80 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs @@ -696,13 +696,13 @@ private void WriteToReadOnlyFile(MemoryMappedFileAccess access, bool succeeds) public void WriteToReadOnlyFile_ReadWrite(MemoryMappedFileAccess access) { WriteToReadOnlyFile(access, access == MemoryMappedFileAccess.Read || - (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser)); + PlatformDetection.IsSuperUser); } [Fact] public void WriteToReadOnlyFile_CopyOnWrite() { - WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser)); + WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, PlatformDetection.IsSuperUser); } /// diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 9ba9856ed6562..28cee277be5e2 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -25,7 +25,6 @@ -