From 457cd24986b2dbccc921bd07c1170b7786ca280d Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Fri, 4 Jan 2013 14:25:39 -0600 Subject: [PATCH] Add test for ExecutionEngine.get_pointer_to_global --- llvm/test_llvmpy.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/llvm/test_llvmpy.py b/llvm/test_llvmpy.py index 82c6a81..e717dc5 100644 --- a/llvm/test_llvmpy.py +++ b/llvm/test_llvmpy.py @@ -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):