# HG changeset patch # User Thinker K.F. Li # Date 1312466242 -28800 # Node ID 7b537e0d8e7ae5620388076fe81677744f719d80 # Parent 2833c1337dc0c1e188290961970f218e80e7827c Check redirection diff -r 2833c1337dc0 -r 7b537e0d8e7a paraspace/tests/injection_test.py --- 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('', \ + 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