Mercurial > paraspace
diff paraspace/tests/injection_test.py @ 98:c0c127c7b37e
Check and fix issues of map sizes
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 25 Jul 2011 20:37:32 +0800 |
parents | 00cd331f8aa8 |
children | 3898711adb2c |
line wrap: on
line diff
--- a/paraspace/tests/injection_test.py Mon Jul 25 17:46:20 2011 +0800 +++ b/paraspace/tests/injection_test.py Mon Jul 25 20:37:32 2011 +0800 @@ -19,6 +19,14 @@ pass +def _find_map(dex, map_type): + for map in dex.maps.items.items: + if map.type == map_type: + return map + pass + pass + + def inject_fakefile_to_helloworld_test(): from paraspace.dex_deptracker import prepare_dep_decls from paraspace.injection import dexfile_insert_class @@ -32,6 +40,10 @@ helloworld_fn = os.path.join(srcroot, 'data', 'helloworld.dex') helloworld_dex = dexfile.DEXFile.open(helloworld_fn) + + classdef_map = _find_map(helloworld_dex, 0x0006) + saved_classdef_map_sz = classdef_map.size + helloworld_linked = \ dexfile.DEXFile_linked.build_dependencies(helloworld_dex, all_dep_decls) @@ -45,11 +57,18 @@ fakefile_def = fakefile_linked. \ find_class_name('Lcom/codemud/fakefile/fakefile;') - clone = dexfile_insert_class(helloworld_dex, fakefile_def) + clone = dexfile_insert_class(helloworld_linked, fakefile_def) assert clone assert clone != fakefile_def helloworld_unlinked = helloworld_linked.get_unlinked() assert helloworld_unlinked + + # map size for classdef must be increased by 1 + classdef_map = _find_map(helloworld_unlinked, 0x0006) + assert classdef_map.size == saved_classdef_map_sz + 1 + + classdata_map = _find_map(helloworld_unlinked, 0x2000) + assert classdata_map.size == classdef_map.size pass