Mercurial > paraspace
changeset 118:7b537e0d8e7a
Check redirection
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 04 Aug 2011 21:57:22 +0800 |
parents | 2833c1337dc0 |
children | 4f508f84c8a1 |
files | paraspace/tests/injection_test.py |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/tests/injection_test.py Thu Aug 04 19:12:49 2011 +0800 +++ b/paraspace/tests/injection_test.py Thu Aug 04 21:57:22 2011 +0800 @@ -298,6 +298,8 @@ def inject_classdefs_test(): from paraspace.dex_deptracker import prepare_dep_decls from paraspace.injection import inject_classdefs + from paraspace.injection import make_methodidxs_redir_map + from paraspace.injection import dexfile_redirect_types from paraspace import dalvik_opcodes from paraspace.dexfile import DEXFile_linked @@ -356,4 +358,33 @@ opvector = opvectors[0] args = opvector[1] assert args[2] == initidx + + fakefile_typeidx = \ + helloworld_linked.get_idx_typeid(fakefile_cloning.classIdx) + typeidxs_redir_map = {file_typeidx: fakefile_typeidx} + methodidxs_redir_map = \ + make_methodidxs_redir_map(helloworld_linked, \ + helloworld_linked, \ + typeidxs_redir_map) + dexfile_redirect_types(helloworld_linked, typeidxs_redir_map, + methodidxs_redir_map, excludes=[fakefile_typeidx]) + + cloning_initdef = \ + helloworld_linked.find_method_name_proto('<init>', \ + protoid, \ + fakefile_cloning) + fakefile_codes = [cloning_initdef.codeOffRef.value] + for code in helloworld_linked.codeItems.items: + op_vectors = dalvik_opcodes.decode_insn_blk(code.insns.data) + for opcode, args in op_vectors: + if opcode == dalvik_opcodes.all_opcodes.OP_NEW_INSTANCE: + assert args[1] != file_typeidx + pass + elif opcode == dalvik_opcodes.all_opcodes.OP_INVOKE_DIRECT: + methodid = helloworld_linked.find_methodid_idx(args[2]) + assert methodid.classIdx != file_typeid or \ + code in fakefile_codes + pass + pass + pass pass