Skip to content

Commit

Permalink
handle UnauthorizedAccessException from mmap on OSX (dotnet#35619)
Browse files Browse the repository at this point in the history
* handle UnauthorizedAccessException on OSX

* update SkipTestException text

* add comments

Co-authored-by: Tomas Weinfurt <[email protected]>
  • Loading branch information
wfurt and Tomas Weinfurt authored Apr 30, 2020
1 parent 3735efb commit ac544ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor
}
catch (UnauthorizedAccessException)
{
if (PlatformDetection.IsInContainer && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
if ((RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
throw new SkipTestException("Execute permission failing in container.");
// Containers and OSX with SIP enabled do not have execute permissions by default.
throw new SkipTestException("Insufficient execute permission.");
}

throw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor
}
catch (UnauthorizedAccessException)
{
if (PlatformDetection.IsInContainer && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
if ((RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
throw new SkipTestException("Execute permission failing in container.");
// Containers and OSX with SIP enabled do not have execute permissions by default.
throw new SkipTestException("Insufficient execute permission.");
}

throw;
Expand Down

0 comments on commit ac544ff

Please sign in to comment.