Mercurial > paraspace
changeset 96:1769e52bdd9d
Make dexfile_insert_class() pass the testcase
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 25 Jul 2011 16:49:28 +0800 |
parents | 9373465643e0 |
children | 00cd331f8aa8 |
files | paraspace/injection.py paraspace/tests/injection_test.py |
diffstat | 2 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/injection.py Mon Jul 25 15:22:03 2011 +0800 +++ b/paraspace/injection.py Mon Jul 25 16:49:28 2011 +0800 @@ -23,7 +23,7 @@ rel_children = _relocatable_children(obj) for attr, value in rel_children: - _travel_conn_objs(value, worker, visit_log) + _travel_desc_relocatable(value, worker, visit_log) pass pass @@ -67,8 +67,10 @@ array.items.append(obj) count_name = array.count_name - count = _dex_tree_get_child(dex, count_name) - _dex_tree_set_child(dex, count_name, count + 1) + if count_name: + count = _dex_tree_get_child(dex, count_name) + _dex_tree_set_child(dex, count_name, count + 1) + pass pass @@ -154,9 +156,9 @@ def has_classdef(clazz): class_typeIds = set([classdef.classIdx for classdef in dex.classDefs.items]) - return dex.classIdx in class_typeIds + return clazz.classIdx in class_typeIds - _travel_desc_relocatable(obj, cloner, visit_log) + _travel_desc_relocatable(clazz, cloner, visit_log) merge_unique_strdata() merge_unique_strid() @@ -171,12 +173,12 @@ dex_append_obj_list(dex, obj) pass - if has_classef(clazz): + if has_classdef(clazz): raise RuntimeError, \ 'clone a class \'%s\'that is already in the DEXFile' % \ classdef_name(clazz) - clone = visit_log[id(obj)] + clone = visit_log[id(clazz)] return clone
--- a/paraspace/tests/injection_test.py Mon Jul 25 15:22:03 2011 +0800 +++ b/paraspace/tests/injection_test.py Mon Jul 25 16:49:28 2011 +0800 @@ -21,7 +21,7 @@ def inject_fakefile_to_helloworld_test(): from paraspace.dex_deptracker import prepare_dep_decls - from paraspace.dex_deptracker import build_dependencies + from paraspace.injection import dexfile_insert_class _install_dexfile_4_deptracker() @@ -44,5 +44,9 @@ fakefile_def = fakefile_linked. \ find_class_name('Lcom/codemud/fakefile/fakefile;') + + clone = dexfile_insert_class(helloworld_dex, fakefile_def) + assert clone + assert clone != fakefile_def pass