Move arm reloc test to proper location and simplify its code a bit
authorEli Bendersky <eliben@gmail.com>
Wed, 5 Sep 2018 12:42:10 +0000 (05:42 -0700)
committerEli Bendersky <eliben@gmail.com>
Wed, 5 Sep 2018 12:42:10 +0000 (05:42 -0700)
test/test_arm_call_reloc.py [new file with mode: 0644]
test/test_dwarf_expr.py
test_arm_call_reloc.py [deleted file]

diff --git a/test/test_arm_call_reloc.py b/test/test_arm_call_reloc.py
new file mode 100644 (file)
index 0000000..354c3a7
--- /dev/null
@@ -0,0 +1,45 @@
+#-------------------------------------------------------------------------------
+# elftools tests
+#
+# Test 'R_ARM_CALL' relocation type support.
+# Compare the '.text' section data of ELF file that was relocated by elftools
+# with an ELF file that was relocated by linker.
+#
+# Dmitry Koltunov (koltunov@ispras.ru)
+# This code is in the public domain
+#-------------------------------------------------------------------------------
+import os
+import sys
+import unittest
+
+from elftools.common.py3compat import BytesIO
+from elftools.elf.elffile import ELFFile
+from elftools.elf.relocation import RelocationHandler
+
+
+def do_relocation(rel_elf):
+    data = rel_elf.get_section_by_name('.text').data()
+    rh = RelocationHandler(rel_elf)
+
+    stream = BytesIO()
+    stream.write(data)
+
+    rel = rel_elf.get_section_by_name('.rel.text')
+    rh.apply_section_relocations(stream, rel)
+    return stream.getvalue()
+
+
+class TestARMRElocation(unittest.TestCase):
+    def test_reloc(self):
+        test_dir = os.path.join('test', 'testfiles_for_unittests')
+        with open(os.path.join(test_dir, 'arm_reloc_unrelocated.o'), 'rb') as rel_f, \
+             open(os.path.join(test_dir, 'arm_reloc_relocated.elf'), 'rb') as f:
+            rel_elf = ELFFile(rel_f)
+            elf = ELFFile(f)
+
+            # Comparison of '.text' section data
+            self.assertEquals(do_relocation(rel_elf),
+                              elf.get_section_by_name('.text').data())
+
+if __name__ == '__main__':
+    unittest.main()
index 747ee388a814bd562f8b197c7a2628c1b0aad0d7..a04c20641ab42bb1f210c8d9d757b91e17c8aeb6 100644 (file)
@@ -68,5 +68,3 @@ class TestExprDumper(unittest.TestCase):
 
 if __name__ == '__main__':
     unittest.main()
-
-
diff --git a/test_arm_call_reloc.py b/test_arm_call_reloc.py
deleted file mode 100755 (executable)
index 8a2eac5..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#-------------------------------------------------------------------------------
-# elftools tests
-#
-# Test 'R_ARM_CALL' relocation type support.
-# Compare the '.text' section data of ELF file that was relocated by elftools
-# with an ELF file that was relocated by linker.
-#
-# Dmitry Koltunov (koltunov@ispras.ru)
-# This code is in the public domain
-#-------------------------------------------------------------------------------
-import os
-import sys
-import unittest
-
-from elftools.common.py3compat import BytesIO
-from elftools.elf.elffile import ELFFile
-from elftools.elf.relocation import RelocationHandler
-
-
-def do_relocation(rel_elf):
-    data = rel_elf.get_section_by_name('.text').data()
-    rh = RelocationHandler(rel_elf)
-
-    stream = BytesIO()
-    stream.write(data)
-
-    rel = rel_elf.get_section_by_name('.rel.text')
-    rh.apply_section_relocations(stream, rel)
-    return data.getvalue()
-
-    #stream.seek(0)
-    #data = stream.readlines()
-
-    #return data
-
-
-class TestARMRElocation(unittest.TestCase):
-    def test_reloc(self):
-        test_dir = os.path.joinjoin('test', 'testfiles_for_unittests')
-        with open(join(test_dir, 'arm_reloc_unrelocated.o'), 'rb') as rel_f, \
-                open(join(test_dir, 'arm_reloc_relocated.elf'), 'rb') as f:
-            rel_elf = ELFFile(rel_f)
-            elf = ELFFile(f)
-
-            # Comparison of '.text' section data
-            self.assertEquals(do_relocation(rel_elf),
-                              elf.get_section_by_name('.text').data())