blob: ad6095357d5bdc53e6981bf3f81379e078a97a74 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/usr/bin/python3-dbg
# -*- coding: utf-8 -*-
# Tests validant le décodage des types et des routines pour le format Dex
from chrysacase import ChrysalideTestCase
from pychrysalide.mangling import DexDemangler
class TestDexMangling(ChrysalideTestCase):
"""TestCase for pychrysalide.mangling.DexDemangler."""
def check_demangling(self, got, expected):
"""Check a given demangling result."""
self.assertTrue(str(got) == expected)
def testDexTypeMangling(self):
"""Check Dex type demangling."""
demangler = DexDemangler()
demangled = demangler.decode_type('V')
self.check_demangling(demangled, 'void')
demangled = demangler.decode_type('[I')
self.check_demangling(demangled, 'int []')
demangled = demangler.decode_type('[[I')
self.check_demangling(demangled, 'int [][]')
demangled = demangler.decode_type('Ltoto;')
self.check_demangling(demangled, 'toto')
demangled = demangler.decode_type('Ltiti/toto/tata;')
self.check_demangling(demangled, 'tata')
def testDexBadTypeMangling(self):
"""Check Dex malformed type mangling."""
demangler = DexDemangler()
demangled = demangler.decode_type('Ltiti/toto/tata/;')
self.assertIsNone(demangled)
def testDexRoutineMangling(self):
"""Check Dex routine demangling."""
demangler = DexDemangler()
demangled = demangler.decode_routine('I')
self.check_demangling(demangled, 'int ()')
def testDexBadRoutineMangling(self):
"""Check Dex malformed routine mangling."""
demangler = DexDemangler()
demangled = demangler.decode_routine('IX')
self.assertIsNone(demangled)
|