diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index a4a74cdc9ee4af..a042993849156e 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -47,9 +47,9 @@ public static partial class PlatformDetection public static bool IsNotFedoraOrRedHatFamily => !IsFedora && !IsRedHatFamily; public static bool IsNotDebian10 => !IsDebian10; - public static bool IsSuperUser => !IsWindows ? + public static bool IsSuperUser => IsBrowser ? false : (!IsWindows ? libc.geteuid() == 0 : - throw new PlatformNotSupportedException(); + throw new PlatformNotSupportedException()); public static Version OpenSslVersion => !IsOSXLike && !IsWindows ? GetOpenSslVersion() : 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 548bcbc323648b..d5edbbc05b2944 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs @@ -614,6 +614,7 @@ public void FileInUse_CreateFromFile_FailsWithExistingReadWriteMap() /// Test exceptional behavior when trying to create a map for a non-shared file that's currently in use. /// [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // the emscripten implementation ignores FileShare.None public void FileInUse_CreateFromFile_FailsWithExistingNoShareFile() { // Already opened with a FileStream @@ -696,13 +697,13 @@ private void WriteToReadOnlyFile(MemoryMappedFileAccess access, bool succeeds) public void WriteToReadOnlyFile_ReadWrite(MemoryMappedFileAccess access) { WriteToReadOnlyFile(access, access == MemoryMappedFileAccess.Read || - (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)); + (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser)); } [Fact] public void WriteToReadOnlyFile_CopyOnWrite() { - WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0)); + WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser)); } /// @@ -768,6 +769,7 @@ public void LeaveOpenRespected_OutstandingViews(bool leaveOpen) /// Test to validate we can create multiple maps from the same FileStream. /// [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // the emscripten implementation doesn't share data public void MultipleMapsForTheSameFileStream() { const int Capacity = 4096; diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs index 6b1042ae1e4e34..c754fcb8daaf15 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs @@ -14,6 +14,9 @@ public abstract partial class MemoryMappedFilesTestBase : FileCleanupTestBase /// Gets the system's page size. protected static Lazy s_pageSize = new Lazy(() => { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) + return Environment.SystemPageSize; + int pageSize; const int _SC_PAGESIZE_FreeBSD = 47; const int _SC_PAGESIZE_Linux = 30; @@ -31,9 +34,6 @@ public abstract partial class MemoryMappedFilesTestBase : FileCleanupTestBase [DllImport("libc", SetLastError = true)] private static extern int sysconf(int name); - [DllImport("libc", SetLastError = true)] - protected static extern int geteuid(); - /// Asserts that the handle's inheritability matches the specified value. protected static void AssertInheritability(SafeHandle handle, HandleInheritability inheritability) { diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs index 99268f6f7d8429..f96e00479ae3e1 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs @@ -334,6 +334,7 @@ public void FlushSupportedOnBothReadAndWriteAccessors(MemoryMappedFileAccess acc /// Test to validate that multiple accessors over the same map share data appropriately. /// [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // the emscripten implementation doesn't share data public void ViewsShareData() { const int MapLength = 256; diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs index a4ab65c1263667..5f98409f3fe2f8 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs @@ -264,6 +264,7 @@ public void FlushSupportedOnBothReadAndWriteAccessors(MemoryMappedFileAccess acc /// Test to validate that multiple accessors over the same map share data appropriately. /// [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] // the emscripten implementation doesn't share data public void ViewsShareData() { const int MapLength = 256; diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index d6dd69b9138cce..d871351d197163 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -32,7 +32,6 @@ -