Added unit test for solaris (SUNW_syminfo section only for now)
authorYann Rouillard <yann@pleiades.fr.eu.org>
Mon, 29 Apr 2013 23:40:00 +0000 (01:40 +0200)
committerYann Rouillard <yann@pleiades.fr.eu.org>
Mon, 29 Apr 2013 23:40:00 +0000 (01:40 +0200)
test/test_solaris_support.py [new file with mode: 0644]
test/testfiles/exe_solaris32_cc.elf [new file with mode: 0755]
test/testfiles/exe_solaris32_cc.elf.sparc [new file with mode: 0755]
test/testfiles/exe_solaris64_cc.elf [new file with mode: 0755]
test/testfiles/exe_solaris64_cc.elf.sparc [new file with mode: 0755]

diff --git a/test/test_solaris_support.py b/test/test_solaris_support.py
new file mode 100644 (file)
index 0000000..9ad535c
--- /dev/null
@@ -0,0 +1,50 @@
+#-------------------------------------------------------------------------------
+# elftools tests
+#
+# Yann Rouillard (yann@pleiades.fr.eu.org)
+# This code is in the public domain
+#-------------------------------------------------------------------------------
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+import os
+
+from utils import setup_syspath; setup_syspath()
+from elftools.elf.elffile import ELFFile
+from elftools.elf.constants import SYMINF0_FLAGS
+
+
+class TestSolarisSupport(unittest.TestCase):
+
+    def _test_SUNW_syminfo_section_generic(self, testfile):
+        with open(os.path.join('test', 'testfiles',
+                               testfile), 'rb') as f:
+            elf = ELFFile(f)
+            syminfo_section = elf.get_section_by_name('.SUNW_syminfo')
+            self.assertIsNotNone(syminfo_section)
+
+            exit_symbols = [s for s in syminfo_section.iter_symbols()
+                            if 'exit' in s.name]
+            self.assertNotEqual(len(exit_symbols), 0)
+
+            for symbol in exit_symbols:
+                self.assertEqual(symbol['si_boundto'], 0)
+                self.assertEqual(symbol['si_flags'],
+                                 SYMINF0_FLAGS.SYMINFO_FLG_DIRECT |
+                                 SYMINF0_FLAGS.SYMINFO_FLG_DIRECTBIND)
+
+    def test_SUNW_syminfo_section_x86(self):
+        self._test_SUNW_syminfo_section_generic('exe_solaris32_cc.elf')
+
+    def test_SUNW_syminfo_section_x64(self):
+        self._test_SUNW_syminfo_section_generic('exe_solaris64_cc.elf')
+
+    def test_SUNW_syminfo_section_sparc32(self):
+        self._test_SUNW_syminfo_section_generic('exe_solaris32_cc.elf.sparc')
+
+    def test_SUNW_syminfo_section_sparc64(self):
+        self._test_SUNW_syminfo_section_generic('exe_solaris64_cc.elf.sparc')
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/test/testfiles/exe_solaris32_cc.elf b/test/testfiles/exe_solaris32_cc.elf
new file mode 100755 (executable)
index 0000000..51b925c
Binary files /dev/null and b/test/testfiles/exe_solaris32_cc.elf differ
diff --git a/test/testfiles/exe_solaris32_cc.elf.sparc b/test/testfiles/exe_solaris32_cc.elf.sparc
new file mode 100755 (executable)
index 0000000..7e879ef
Binary files /dev/null and b/test/testfiles/exe_solaris32_cc.elf.sparc differ
diff --git a/test/testfiles/exe_solaris64_cc.elf b/test/testfiles/exe_solaris64_cc.elf
new file mode 100755 (executable)
index 0000000..b6bad65
Binary files /dev/null and b/test/testfiles/exe_solaris64_cc.elf differ
diff --git a/test/testfiles/exe_solaris64_cc.elf.sparc b/test/testfiles/exe_solaris64_cc.elf.sparc
new file mode 100755 (executable)
index 0000000..b9e4a17
Binary files /dev/null and b/test/testfiles/exe_solaris64_cc.elf.sparc differ