1 #-------------------------------------------------------------------------------
4 # Eli Bendersky (eliben@gmail.com)
5 # This code is in the public domain
6 #-------------------------------------------------------------------------------
9 from elftools
.dwarf
.structs
import DWARFStructs
12 class TestDWARFStructs(unittest
.TestCase
):
13 def test_lineprog_header(self
):
14 ds
= DWARFStructs(little_endian
=True, dwarf_format
=32, address_size
=4)
16 c
= ds
.Dwarf_lineprog_header
.parse(
17 b
'\x04\x10\x00\x00' + # initial length
18 b
'\x02\x00' + # version
19 b
'\x20\x00\x00\x00' + # header length
20 b
'\x05\x10\x40\x50' + # until and including line_range
21 b
'\x06' + # opcode_base
22 b
'\x00\x01\x04\x08\x0C' + # standard_opcode_lengths
23 # 2 dir names followed by a NULL
24 b
'\x61\x62\x00\x70\x00\x00' +
26 b
'\x61\x72\x00\x0C\x0D\x0F' +
28 b
'\x45\x50\x51\x00\x86\x12\x07\x08' +
31 self
.assertEqual(c
.version
, 2)
32 self
.assertEqual(c
.opcode_base
, 6)
33 self
.assertEqual(c
.standard_opcode_lengths
, [0, 1, 4, 8, 12])
34 self
.assertEqual(c
.include_directory
, [b
'ab', b
'p'])
35 self
.assertEqual(len(c
.file_entry
), 2)
36 self
.assertEqual(c
.file_entry
[0].name
, b
'ar')
37 self
.assertEqual(c
.file_entry
[1].name
, b
'EPQ')
38 self
.assertEqual(c
.file_entry
[1].dir_index
, 0x12 * 128 + 6)
41 if __name__
== '__main__':