diff options
author | Shih-wei Liao <sliao@google.com> | 2012-03-24 04:18:09 -0700 |
---|---|---|
committer | Shih-wei Liao <sliao@google.com> | 2012-03-24 04:18:09 -0700 |
commit | c59a7995d22e2889706810c90a20a51ecfec278b (patch) | |
tree | ef37472f01d4b6258755680b4561a667bc337dd6 /bindings/python/llvm/tests/test_object.py | |
parent | d1acd051dd8446a013b6c35b4bfe64ec68417206 (diff) | |
parent | 98a92d199ce9993dca1b65927009013ad3e5297f (diff) | |
download | external_llvm-c59a7995d22e2889706810c90a20a51ecfec278b.zip external_llvm-c59a7995d22e2889706810c90a20a51ecfec278b.tar.gz external_llvm-c59a7995d22e2889706810c90a20a51ecfec278b.tar.bz2 |
Merge branch 'upstream' into sliao_d
Diffstat (limited to 'bindings/python/llvm/tests/test_object.py')
-rw-r--r-- | bindings/python/llvm/tests/test_object.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/bindings/python/llvm/tests/test_object.py b/bindings/python/llvm/tests/test_object.py new file mode 100644 index 0000000..7ff981b --- /dev/null +++ b/bindings/python/llvm/tests/test_object.py @@ -0,0 +1,67 @@ +from .base import TestBase +from ..object import ObjectFile +from ..object import Relocation +from ..object import Section +from ..object import Symbol + +class TestObjectFile(TestBase): + def get_object_file(self): + source = self.get_test_binary() + return ObjectFile(filename=source) + + def test_create_from_file(self): + self.get_object_file() + + def test_get_sections(self): + o = self.get_object_file() + + count = 0 + for section in o.get_sections(): + count += 1 + assert isinstance(section, Section) + assert isinstance(section.name, str) + assert isinstance(section.size, long) + assert isinstance(section.contents, str) + assert isinstance(section.address, long) + + self.assertGreater(count, 0) + + for section in o.get_sections(): + section.cache() + + def test_get_symbols(self): + o = self.get_object_file() + + count = 0 + for symbol in o.get_symbols(): + count += 1 + assert isinstance(symbol, Symbol) + assert isinstance(symbol.name, str) + assert isinstance(symbol.address, long) + assert isinstance(symbol.size, long) + assert isinstance(symbol.file_offset, long) + + self.assertGreater(count, 0) + + for symbol in o.get_symbols(): + symbol.cache() + + def test_symbol_section_accessor(self): + o = self.get_object_file() + + for symbol in o.get_symbols(): + section = symbol.section + assert isinstance(section, Section) + + break + + def test_get_relocations(self): + o = self.get_object_file() + for section in o.get_sections(): + for relocation in section.get_relocations(): + assert isinstance(relocation, Relocation) + assert isinstance(relocation.address, long) + assert isinstance(relocation.offset, long) + assert isinstance(relocation.type_number, long) + assert isinstance(relocation.type_name, str) + assert isinstance(relocation.value_string, str) |