summaryrefslogtreecommitdiff
path: root/tests/format/flat.py
blob: f84f7a4ab4990c182ff533fba2e23a8b601c4f20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

from chrysacase import ChrysalideTestCase
from pychrysalide import SourceEndian
#from pychrysalide.analysis import LoadedBinary
from pychrysalide.analysis.contents import MemoryContent
#from pychrysalide.arch import vmpa
from pychrysalide.format import FlatFormat
#from pychrysalide.glibext import BinPortion


class TestFlatFormat(ChrysalideTestCase):
    """TestCase for format.FlatFormat."""


    def testSimpleFlatFormatContent(self):
        """Load a simple content for a flat format."""

        data  = b'\x00\x00\x00\xef'

        cnt = MemoryContent(data)

        fmt = FlatFormat(cnt, 'armv7', SourceEndian.LITTLE)

        self.assertEqual(fmt.target_machine, 'armv7')
        self.assertEqual(fmt.endianness, SourceEndian.LITTLE)


        # base = vmpa(0, 0)

        # p = BinPortion(BinPortion.BPC_CODE, base, cnt.size)
        # p.rights = BinPortion.PAC_READ | BinPortion.PAC_EXEC

        # fmt.register_user_portion(p)

        # binary = LoadedBinary(fmt)

        # binary.analyze_and_wait()

        # self.assertTrue(list(binary.processor.instrs)[0].keyword == 'svc')