Adding unit test for an ARM file with DW_FORM_indirect
authorEli Bendersky <eliben@gmail.com>
Sat, 18 Jan 2014 14:34:37 +0000 (06:34 -0800)
committerEli Bendersky <eliben@gmail.com>
Sat, 18 Jan 2014 14:34:37 +0000 (06:34 -0800)
test/test_arm_support.py
test/testfiles_for_unittests/arm_with_form_indirect.elf [new file with mode: 0644]

index 0d7bfcc8339b0ed1c1d09e14244c7641c70848b4..649366319f1e5c297e8cb3cb111defff3093dfa0 100644 (file)
@@ -25,6 +25,20 @@ class TestARMSupport(unittest.TestCase):
             self.assertEqual(elf.num_sections(), 14)
             self.assertEqual(elf.num_segments(), 2)
 
+    def test_DWARF_indirect_forms(self):
+        # This file uses a lot of DW_FORM_indirect, and is also an ARM ELF
+        # with non-trivial DWARF info.
+        # So this is a simple sanity check that we can successfully parse it
+        # and extract the expected amount of CUs.
+        with open(os.path.join('test', 'testfiles_for_unittests',
+                               'arm_with_form_indirect.elf'), 'rb') as f:
+            elffile = ELFFile(f)
+            self.assertTrue(elffile.has_dwarf_info())
+
+            dwarfinfo = elffile.get_dwarf_info()
+            all_CUs = list(dwarfinfo.iter_CUs())
+            self.assertEqual(len(all_CUs), 9)
+
 if __name__ == '__main__':
     unittest.main()
 
diff --git a/test/testfiles_for_unittests/arm_with_form_indirect.elf b/test/testfiles_for_unittests/arm_with_form_indirect.elf
new file mode 100644 (file)
index 0000000..ff0a3ba
Binary files /dev/null and b/test/testfiles_for_unittests/arm_with_form_indirect.elf differ