From: Matthew Fernandez Date: Thu, 17 Jan 2013 05:23:07 +0000 (+1100) Subject: Add a test for parsing an ARM ELF file. X-Git-Tag: v0.21~28 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b2cc09bd603477ec81716153465382644b13c53b;p=pyelftools.git Add a test for parsing an ARM ELF file. --- diff --git a/test/test_arm_support.py b/test/test_arm_support.py new file mode 100644 index 0000000..6ea3969 --- /dev/null +++ b/test/test_arm_support.py @@ -0,0 +1,23 @@ +try: + import unittest2 as unittest +except ImportError: + import unittest +import sys +import os + +sys.path.extend(['.', '..']) +from elftools.elf.elffile import ELFFile + +class TestARMSupport(unittest.TestCase): + def test_hello(self): + with open(os.path.join('test', 'testfiles', 'simple_gcc.elf.arm'), 'rb') as f: + elf = ELFFile(f) + self.assertEqual(elf.get_machine_arch(), 'ARM') + + # Check some other properties of this ELF file derived from readelf + self.assertEqual(elf['e_entry'], 0x8018) + self.assertEqual(elf.num_sections(), 14) + self.assertEqual(elf.num_segments(), 2) + +if __name__ == '__main__': + sys.exit(unittest.main()) diff --git a/test/testfiles/simple_gcc.elf.arm b/test/testfiles/simple_gcc.elf.arm new file mode 100644 index 0000000..b678393 Binary files /dev/null and b/test/testfiles/simple_gcc.elf.arm differ