Exemplo n.º 1
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);
            }
        }
        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);
            }
        }
Exemplo n.º 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);
            }
        }