Add test for ExecutionEngine.get_pointer_to_global
This commit is contained in:
parent
5b6a1d75f8
commit
457cd24986
1 changed files with 16 additions and 0 deletions
|
|
@ -451,6 +451,22 @@ tests.append(TestEngineBuilder)
|
|||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestExecutionEngine(unittest.TestCase):
|
||||
def test_get_pointer_to_global(self):
|
||||
module = lc.Module.new(str(self))
|
||||
gvar = module.add_global_variable(Type.int(), 'hello')
|
||||
X = 1234
|
||||
gvar.initializer = lc.Constant.int(Type.int(), X)
|
||||
|
||||
ee = le.ExecutionEngine.new(module)
|
||||
ptr = ee.get_pointer_to_global(gvar)
|
||||
from ctypes import c_void_p, cast, c_int, POINTER
|
||||
casted = cast(c_void_p(ptr), POINTER(c_int))
|
||||
self.assertEqual(X, casted[0])
|
||||
|
||||
tests.append(TestExecutionEngine)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestObjCache(unittest.TestCase):
|
||||
|
||||
def test_objcache(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue