Remove unused import
[pyelftools.git] / test / test_dwarf_structs.py
1 #-------------------------------------------------------------------------------
2 # elftools tests
3 #
4 # Eli Bendersky (eliben@gmail.com)
5 # This code is in the public domain
6 #-------------------------------------------------------------------------------
7 try:
8 import unittest2 as unittest
9 except ImportError:
10 import unittest
11
12 from utils import setup_syspath; setup_syspath()
13 from elftools.dwarf.structs import DWARFStructs
14
15
16 class TestDWARFStructs(unittest.TestCase):
17 def test_lineprog_header(self):
18 ds = DWARFStructs(little_endian=True, dwarf_format=32, address_size=4)
19
20 c = ds.Dwarf_lineprog_header.parse(
21 b'\x04\x10\x00\x00' + # initial lenght
22 b'\x05\x02' + # version
23 b'\x20\x00\x00\x00' + # header length
24 b'\x05\x10\x40\x50' + # until and including line_range
25 b'\x06' + # opcode_base
26 b'\x00\x01\x04\x08\x0C' + # standard_opcode_lengths
27 # 2 dir names followed by a NULL
28 b'\x61\x62\x00\x70\x00\x00' +
29 # a file entry
30 b'\x61\x72\x00\x0C\x0D\x0F' +
31 # and another entry
32 b'\x45\x50\x51\x00\x86\x12\x07\x08' +
33 # followed by NULL
34 b'\x00')
35
36 self.assertEqual(c.version, 0x205)
37 self.assertEqual(c.opcode_base, 6)
38 self.assertEqual(c.standard_opcode_lengths, [0, 1, 4, 8, 12])
39 self.assertEqual(c.include_directory, [b'ab', b'p'])
40 self.assertEqual(len(c.file_entry), 2)
41 self.assertEqual(c.file_entry[0].name, b'ar')
42 self.assertEqual(c.file_entry[1].name, b'EPQ')
43 self.assertEqual(c.file_entry[1].dir_index, 0x12 * 128 + 6)
44
45
46 if __name__ == '__main__':
47 unittest.main()
48