Mercurial > paraspace
comparison paraspace/tests/injection_test.py @ 90:fe7b3f111d57
Testcase for code injection
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 24 Jul 2011 22:28:21 +0800 |
parents | |
children | 1728795c29b7 |
comparison
equal
deleted
inserted
replaced
89:7a059ab408f0 | 90:fe7b3f111d57 |
---|---|
1 from paraspace import dexfile | |
2 import os | |
3 | |
4 def _install_dexfile_4_deptracker(): | |
5 global dexfile | |
6 import imp | |
7 from paraspace import dex_deptracker | |
8 | |
9 try: | |
10 new_dexfile = imp.load_compiled('dexfile', dexfile.__file__) | |
11 except ImportError: | |
12 new_dexfile = imp.load_source('dexfile', dexfile.__file__) | |
13 pass | |
14 dex_deptracker.dexfile = new_dexfile | |
15 dexfile = new_dexfile | |
16 dex_deptracker._nest_types = (dexfile.array, dexfile.cond, dexfile.switch) | |
17 pass | |
18 | |
19 | |
20 def inject_fakefile_to_helloworld_test(): | |
21 from paraspace.dex_deptracker import prepare_dep_decls | |
22 | |
23 _install_dexfile_4_deptracker() | |
24 | |
25 all_dep_decls = prepare_dep_decls() | |
26 | |
27 srcdir = os.path.dirname(__file__) | |
28 srcroot = os.path.join(srcdir, '..', '..') | |
29 | |
30 helloworld_fn = os.path.join(srcroot, 'data', 'helloworld.dex') | |
31 helloworld_dex = dexfile.DEXFile.open(helloworld_fn) | |
32 | |
33 fakefile_fn = os.path.join(srcroot, 'data', 'fakefile.dex') | |
34 fakefile_dex = dexfile.DEXFile.open(fakefile_fn) | |
35 pass | |
36 |