Module rsyscall.tests.test_pointer
Expand source code Browse git
from rsyscall.tests.trio_test_case import TrioTestCase
from rsyscall import local_thread
from rsyscall.handle.pointer import UseAfterFreeError
class TestPointer(TrioTestCase):
async def asyncSetUp(self) -> None:
self.thr = local_thread
async def test_use_after_free_ptr(self) -> None:
buf = await self.thr.malloc(bytes, 16)
buf.free()
with self.assertRaises(UseAfterFreeError):
buf.near
str(buf)
async def test_use_after_free_allocation(self) -> None:
buf = await self.thr.malloc(bytes, 16)
buf.allocation.free()
with self.assertRaises(UseAfterFreeError):
buf.near
buf = await self.thr.ptr(b'foo')
buf.allocation.free()
with self.assertRaises(UseAfterFreeError):
buf.near
str(buf)
Classes
class TestPointer (methodName='runTest')
-
A trio-enabled variant of unittest.TestCase
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
Expand source code Browse git
class TestPointer(TrioTestCase): async def asyncSetUp(self) -> None: self.thr = local_thread async def test_use_after_free_ptr(self) -> None: buf = await self.thr.malloc(bytes, 16) buf.free() with self.assertRaises(UseAfterFreeError): buf.near str(buf) async def test_use_after_free_allocation(self) -> None: buf = await self.thr.malloc(bytes, 16) buf.allocation.free() with self.assertRaises(UseAfterFreeError): buf.near buf = await self.thr.ptr(b'foo') buf.allocation.free() with self.assertRaises(UseAfterFreeError): buf.near str(buf)
Ancestors
- TrioTestCase
- unittest.case.TestCase
Class variables
var nursery : trio.Nursery
Methods
async def test_use_after_free_ptr(self) ‑> NoneType
-
Expand source code Browse git
async def test_use_after_free_ptr(self) -> None: buf = await self.thr.malloc(bytes, 16) buf.free() with self.assertRaises(UseAfterFreeError): buf.near str(buf)
async def test_use_after_free_allocation(self) ‑> NoneType
-
Expand source code Browse git
async def test_use_after_free_allocation(self) -> None: buf = await self.thr.malloc(bytes, 16) buf.allocation.free() with self.assertRaises(UseAfterFreeError): buf.near buf = await self.thr.ptr(b'foo') buf.allocation.free() with self.assertRaises(UseAfterFreeError): buf.near str(buf)
Inherited members