Fixed a stupid mistake on SYMINFO name (I should change my terminal font)
[pyelftools.git] / test / test_solaris_support.py
1 #-------------------------------------------------------------------------------
2 # elftools tests
3 #
4 # Yann Rouillard (yann@pleiades.fr.eu.org)
5 # This code is in the public domain
6 #-------------------------------------------------------------------------------
7 try:
8 import unittest2 as unittest
9 except ImportError:
10 import unittest
11 import os
12
13 from utils import setup_syspath; setup_syspath()
14 from elftools.elf.elffile import ELFFile
15 from elftools.elf.constants import SYMINFO_FLAGS
16
17
18 class TestSolarisSupport(unittest.TestCase):
19
20 def _test_SUNW_syminfo_section_generic(self, testfile):
21 with open(os.path.join('test', 'testfiles',
22 testfile), 'rb') as f:
23 elf = ELFFile(f)
24 syminfo_section = elf.get_section_by_name('.SUNW_syminfo')
25 self.assertIsNotNone(syminfo_section)
26
27 exit_symbols = [s for s in syminfo_section.iter_symbols()
28 if 'exit' in s.name]
29 self.assertNotEqual(len(exit_symbols), 0)
30
31 for symbol in exit_symbols:
32 self.assertEqual(symbol['si_boundto'], 0)
33 self.assertEqual(symbol['si_flags'],
34 SYMINFO_FLAGS.SYMINFO_FLG_DIRECT |
35 SYMINFO_FLAGS.SYMINFO_FLG_DIRECTBIND)
36
37 def test_SUNW_syminfo_section_x86(self):
38 self._test_SUNW_syminfo_section_generic('exe_solaris32_cc.elf')
39
40 def test_SUNW_syminfo_section_x64(self):
41 self._test_SUNW_syminfo_section_generic('exe_solaris64_cc.elf')
42
43 def test_SUNW_syminfo_section_sparc32(self):
44 self._test_SUNW_syminfo_section_generic('exe_solaris32_cc.elf.sparc')
45
46 def test_SUNW_syminfo_section_sparc64(self):
47 self._test_SUNW_syminfo_section_generic('exe_solaris64_cc.elf.sparc')
48
49 if __name__ == '__main__':
50 unittest.main()