private void TestSetReadWriteAccess()
        {
            IntPtr pointer = libcProtectedMemoryAllocator.Alloc(1);

            try
            {
                libcProtectedMemoryAllocator.SetReadWriteAccess(pointer, 1);

                // Verifies we can write and read back
                Marshal.WriteByte(pointer, 0, 42);
                Assert.Equal(42, Marshal.ReadByte(pointer, 0));
            }
            finally
            {
                libcProtectedMemoryAllocator.Free(pointer, 1);
            }
        }
예제 #2
0
        private void TestCheckPointerWithRegularPointerShouldSucceed()
        {
            Skip.If(libc == null);

            Debug.WriteLine("LibcProtectedMemoryAllocatorTest.TestCheckPointerWithRegularPointerShouldSucceed");

            IntPtr pointer = libcProtectedMemoryAllocator.Alloc(1);

            try
            {
                Check.IntPtr(pointer, "TestCheckPointerWithRegularPointerShouldSucceed");
            }
            finally
            {
                libcProtectedMemoryAllocator.Free(pointer, 1);
            }
        }
예제 #3
0
        private void TestCheckPointerWithRegularPointerShouldSucceed()
        {
            // Don't run libc tests on platforms that don't match libc/posix behaviors
            if (libc == null)
            {
                return;
            }

            IntPtr pointer = libcProtectedMemoryAllocator.Alloc(1);

            try
            {
                libcProtectedMemoryAllocator.CheckIntPtr(pointer, "blah");
            }
            finally
            {
                libcProtectedMemoryAllocator.Free(pointer, 1);
            }
        }