Mercurial > paraspace
comparison paraspace/tests/injection_test.py @ 136:f31bfe55d9c2
Fix issue of corrupted offset list in _DEX_AnnotationSetItem after injection
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 09 Aug 2011 21:52:05 +0800 |
parents | b488ca519709 |
children | 987fead83ce3 |
comparison
equal
deleted
inserted
replaced
135:b488ca519709 | 136:f31bfe55d9c2 |
---|---|
541 except: | 541 except: |
542 print 'ERROR: protoid %d is out of order' % (idx + 1) | 542 print 'ERROR: protoid %d is out of order' % (idx + 1) |
543 raise | 543 raise |
544 pass | 544 pass |
545 pass | 545 pass |
546 | |
547 ## \brief Test case for issue of bad offset list in _DEX_AnnotationSetItem. | |
548 # | |
549 # Values of _DEX_AnnotationSetItem.annotationOffs is corrupted after | |
550 # injection. | |
551 # \pre | |
552 # E/dalvikvm( 300): No data map entry found @ 0xf31; expected 2004 | |
553 # E/dalvikvm( 300): Trouble with item 0 @ offset 0x5c0 | |
554 # E/dalvikvm( 300): Cross-item verify of section type 1003 failed | |
555 # E/dalvikvm( 300): ERROR: Byte swap + verify failed | |
556 # E/dalvikvm( 300): Optimization failed | |
557 # | |
558 # It must be the issue that back_type of an array can not be a \ref depend. | |
559 # | |
560 def annotation_set_items_verify_test(): | |
561 from paraspace.dex_deptracker import prepare_dep_decls | |
562 from paraspace.dex_deptracker import dex_sort_sorted_arrays | |
563 from paraspace.injection import inject_redir_no_restore | |
564 | |
565 _install_dexfile_4_deptracker() | |
566 | |
567 all_dep_decls = prepare_dep_decls() | |
568 | |
569 srcdir = os.path.dirname(__file__) | |
570 datapath = os.path.join(srcdir, '..', '..', 'data') | |
571 | |
572 fake_path = os.path.join(datapath, 'fakefile.dex') | |
573 hello_path = os.path.join(datapath, 'helloworld.dex') | |
574 | |
575 fake_dex = dexfile.DEXFile.open(fake_path) | |
576 fake_linked = dexfile.DEXFile_linked.build_dependencies(fake_dex, | |
577 all_dep_decls) | |
578 | |
579 hello_dex = dexfile.DEXFile.open(hello_path) | |
580 hello_linked = dexfile.DEXFile_linked.build_dependencies(hello_dex, | |
581 all_dep_decls) | |
582 | |
583 inject_redir_no_restore(fake_linked, 'Lcom/codemud/fakefile/fakefile;', | |
584 hello_linked, 'Ljava/io/File;', all_dep_decls) | |
585 | |
586 dex_sort_sorted_arrays(hello_linked) | |
587 | |
588 for setitem in hello_linked.annotationSetItems.items: | |
589 for anno in setitem.annotationOffs.items: | |
590 assert anno.offset in hello_linked.annotationItems.items | |
591 pass | |
592 pass | |
593 pass |