Fix for mixed version loclists, tests (#521)
[pyelftools.git] / test / test_mips_support.py
1 #-------------------------------------------------------------------------------
2 # elftools tests
3 #
4 # Karl Vogel (karl.vogel@gmail.com)
5 # Eli Bendersky (eliben@gmail.com)
6 #
7 # This code is in the public domain
8 #-------------------------------------------------------------------------------
9 import unittest
10 import os
11
12 from elftools.elf.elffile import ELFFile
13
14
15 class TestMIPSSupport(unittest.TestCase):
16 def test_basic(self):
17 with open(os.path.join('test', 'testfiles_for_unittests',
18 'simple_gcc.elf.mips'), 'rb') as f:
19 elf = ELFFile(f)
20 self.assertEqual(elf.get_machine_arch(), 'MIPS')
21
22 # Check some other properties of this ELF file derived from readelf
23 self.assertEqual(elf['e_entry'], 0x0)
24 self.assertEqual(elf.num_sections(), 25)
25 self.assertEqual(elf.num_segments(), 0)
26
27 # Test that Mips-specific section types work; these types are
28 # available only when the file is identified as MIPS in the
29 # e_machine header field.
30 sec9 = elf.get_section(9)
31 self.assertEqual(sec9['sh_type'], 'SHT_MIPS_DWARF')
32
33
34 if __name__ == '__main__':
35 unittest.main()