using Microsoft.Win32.SafeHandles;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace System.IO.MemoryMappedFiles.Tests
}
}
- [Theory]
+ [ConditionalTheory]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.Read)]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.Write)]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.ReadWrite)]
AssertExtensions.ThrowsIf<IOException>(PlatformDetection.IsUap && mapAccess == MemoryMappedFileAccess.ReadWriteExecute && viewAccess == MemoryMappedFileAccess.ReadWriteExecute,
() =>
{
- using (MemoryMappedFile mmf = MemoryMappedFile.CreateNew(null, Capacity, mapAccess))
- using (MemoryMappedViewAccessor acc = mmf.CreateViewAccessor(0, Capacity, viewAccess))
+ try
+ {
+ using (MemoryMappedFile mmf = MemoryMappedFile.CreateNew(null, Capacity, mapAccess))
+ using (MemoryMappedViewAccessor acc = mmf.CreateViewAccessor(0, Capacity, viewAccess))
+ {
+ ValidateMemoryMappedViewAccessor(acc, Capacity, viewAccess);
+ }
+ }
+ catch (UnauthorizedAccessException)
{
- ValidateMemoryMappedViewAccessor(acc, Capacity, viewAccess);
+ if (PlatformDetection.IsInContainer && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
+ {
+ throw new SkipTestException("Execute permission failing in container.");
+ }
+
+ throw;
}
});
}
using Microsoft.Win32.SafeHandles;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace System.IO.MemoryMappedFiles.Tests
}
}
- [Theory]
+ [ConditionalTheory]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.Read)]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.Write)]
[InlineData(MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileAccess.ReadWrite)]
AssertExtensions.ThrowsIf<IOException>(PlatformDetection.IsUap && mapAccess == MemoryMappedFileAccess.ReadWriteExecute && viewAccess == MemoryMappedFileAccess.ReadWriteExecute,
() =>
{
- using (MemoryMappedFile mmf = MemoryMappedFile.CreateNew(null, Capacity, mapAccess))
- using (MemoryMappedViewStream s = mmf.CreateViewStream(0, Capacity, viewAccess))
+ try
+ {
+ using (MemoryMappedFile mmf = MemoryMappedFile.CreateNew(null, Capacity, mapAccess))
+ using (MemoryMappedViewStream s = mmf.CreateViewStream(0, Capacity, viewAccess))
+ {
+ ValidateMemoryMappedViewStream(s, Capacity, viewAccess);
+ }
+ }
+ catch (UnauthorizedAccessException)
{
- ValidateMemoryMappedViewStream(s, Capacity, viewAccess);
+ if (PlatformDetection.IsInContainer && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
+ {
+ throw new SkipTestException("Execute permission failing in container.");
+ }
+
+ throw;
}
});
}