diff options
author | Stephen Hines <srhines@google.com> | 2014-04-23 16:57:46 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-04-24 15:53:16 -0700 |
commit | 36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch) | |
tree | e6cfb69fbbd937f450eeb83bfb83b9da3b01275a /bindings/python/llvm/tests | |
parent | 69a8640022b04415ae9fac62f8ab090601d8f889 (diff) | |
download | external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2 |
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'bindings/python/llvm/tests')
-rw-r--r-- | bindings/python/llvm/tests/test_core.py | 42 | ||||
-rw-r--r-- | bindings/python/llvm/tests/test_disassembler.py | 4 |
2 files changed, 28 insertions, 18 deletions
diff --git a/bindings/python/llvm/tests/test_core.py b/bindings/python/llvm/tests/test_core.py index 63f84c8..da7b635 100644 --- a/bindings/python/llvm/tests/test_core.py +++ b/bindings/python/llvm/tests/test_core.py @@ -1,20 +1,30 @@ from .base import TestBase -from ..core import OpCode from ..core import MemoryBuffer from ..core import PassRegistry from ..core import Context from ..core import Module +from ..core import Enums +from ..core import OpCode from ..bit_reader import parse_bitcode class TestCore(TestBase): - def test_opcode(self): - self.assertTrue(hasattr(OpCode, 'Ret')) - self.assertTrue(isinstance(OpCode.Ret, OpCode)) - self.assertEqual(OpCode.Ret.value, 1) - - op = OpCode.from_value(1) - self.assertTrue(isinstance(op, OpCode)) - self.assertEqual(op, OpCode.Ret) + def test_enumerations(self): + for enum_cls, enum_spec in Enums: + for enum_name, enum_value in enum_spec: + # First make sure that enum_cls has the name of the enum as an + # attribute. People will access these values as + # EnumCls.EnumName. + self.assertTrue(hasattr(enum_cls, enum_name)) + v_attr = getattr(enum_cls, enum_name) + self.assertTrue(isinstance(v_attr, enum_cls)) + + # Then make sure that the value returned for this attribute is + # correct in both ways. + self.assertEqual(v_attr.value, enum_value) + + e = enum_cls.from_value(enum_value) + self.assertTrue(isinstance(e, enum_cls)) + self.assertEqual(e, v_attr) def test_memory_buffer_create_from_file(self): source = self.get_test_file() @@ -61,7 +71,7 @@ class TestCore(TestBase): target = "thumbv7-apple-ios5.0.0" m.target = target m.print_module_to_file("test2.ll") - + def test_module_function_iteration(self): m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc())) i = 0 @@ -81,19 +91,19 @@ class TestCore(TestBase): def test_function_basicblock_iteration(self): m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc())) i = 0 - + bb_list = ['b1', 'b2', 'end'] - + f = m.first while f.name != "f6": f = f.next - + # Forward for bb in f: self.assertEqual(bb.name, bb_list[i]) bb.dump() i += 1 - + # Backwards for bb in reversed(f): i -= 1 @@ -103,12 +113,12 @@ class TestCore(TestBase): def test_basicblock_instruction_iteration(self): m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc())) i = 0 - + inst_list = [('arg1', OpCode.ExtractValue), ('arg2', OpCode.ExtractValue), ('', OpCode.Call), ('', OpCode.Ret)] - + bb = m.first.first # Forward diff --git a/bindings/python/llvm/tests/test_disassembler.py b/bindings/python/llvm/tests/test_disassembler.py index e960dc0..37a04e4 100644 --- a/bindings/python/llvm/tests/test_disassembler.py +++ b/bindings/python/llvm/tests/test_disassembler.py @@ -16,9 +16,9 @@ class TestDisassembler(TestBase): self.assertEqual(count, 3) self.assertEqual(s, '\tjcxz\t-127') - def test_nonexistant_triple(self): + def test_nonexistent_triple(self): with self.assertRaisesRegexp(Exception, "Could not obtain disassembler for triple"): - Disassembler("nonexistant-triple-raises") + Disassembler("nonexistent-triple-raises") def test_get_instructions(self): sequence = '\x67\xe3\x81\x01\xc7' # jcxz -127; addl %eax, %edi |