Add a test for parsing an ARM ELF file.
authorMatthew Fernandez <matthew.fernandez@nicta.com.au>
Thu, 17 Jan 2013 05:23:07 +0000 (16:23 +1100)
committerMatthew Fernandez <matthew.fernandez@nicta.com.au>
Thu, 17 Jan 2013 05:23:07 +0000 (16:23 +1100)
test/test_arm_support.py [new file with mode: 0644]
test/testfiles/simple_gcc.elf.arm [new file with mode: 0644]

diff --git a/test/test_arm_support.py b/test/test_arm_support.py
new file mode 100644 (file)
index 0000000..6ea3969
--- /dev/null
@@ -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 (file)
index 0000000..b678393
Binary files /dev/null and b/test/testfiles/simple_gcc.elf.arm differ