aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/python/llvm/tests
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-09-11 00:23:14 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-09-11 00:23:14 +0000
commit37a8807323672ab0bb366272e5a798b8e63752a4 (patch)
treef7b06a1fd959d1ec6639ee7c23b4c69feb3e4e0a /bindings/python/llvm/tests
parent6a63cd12813fea01d711f098126d199c936c8f6b (diff)
downloadexternal_llvm-37a8807323672ab0bb366272e5a798b8e63752a4.zip
external_llvm-37a8807323672ab0bb366272e5a798b8e63752a4.tar.gz
external_llvm-37a8807323672ab0bb366272e5a798b8e63752a4.tar.bz2
[python-bindings] Added code for loading a module from bitcode, getset its datalayout, getset its target, dump it, print it to a file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/llvm/tests')
-rw-r--r--bindings/python/llvm/tests/base.py3
-rw-r--r--bindings/python/llvm/tests/test.bcbin0 -> 1344 bytes
-rw-r--r--bindings/python/llvm/tests/test_core.py27
3 files changed, 30 insertions, 0 deletions
diff --git a/bindings/python/llvm/tests/base.py b/bindings/python/llvm/tests/base.py
index 22da5fd..194f1a4 100644
--- a/bindings/python/llvm/tests/base.py
+++ b/bindings/python/llvm/tests/base.py
@@ -33,3 +33,6 @@ class TestBase(unittest.TestCase):
def get_test_file(self):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_file")
+
+ def get_test_bc(self):
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.bc")
diff --git a/bindings/python/llvm/tests/test.bc b/bindings/python/llvm/tests/test.bc
new file mode 100644
index 0000000..8d3d28f
--- /dev/null
+++ b/bindings/python/llvm/tests/test.bc
Binary files differ
diff --git a/bindings/python/llvm/tests/test_core.py b/bindings/python/llvm/tests/test_core.py
index 3364a66..e5fffba 100644
--- a/bindings/python/llvm/tests/test_core.py
+++ b/bindings/python/llvm/tests/test_core.py
@@ -3,6 +3,7 @@ from ..core import OpCode
from ..core import MemoryBuffer
from ..core import PassRegistry
from ..core import Context
+from ..core import Module
class TestCore(TestBase):
def test_opcode(self):
@@ -33,3 +34,29 @@ class TestCore(TestBase):
def test_create_context(self):
Context.GetGlobalContext()
+
+ def test_create_module_with_name(self):
+ # Make sure we can not create a module without a LLVMModuleRef.
+ with self.assertRaises(RuntimeError):
+ m = Module()
+ m = Module.CreateWithName("test-module")
+
+ def test_module_getset_datalayout(self):
+ m = Module.CreateWithName("test-module")
+ dl = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
+ m.datalayout = dl
+ self.assertEqual(m.datalayout, dl)
+
+ def test_module_getset_target(self):
+ m = Module.CreateWithName("test-module")
+ m.target = "thumbv7-apple-ios5.0.0"
+ self.assertEqual(m.target, target)
+
+ def test_module_print_module_to_file(self):
+ m = Module.CreateWithName("test")
+ dl = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
+ m.datalayout = dl
+ target = "thumbv7-apple-ios5.0.0"
+ m.target = target
+ m.print_module_to_file("test2.ll")
+