changeset 99:3898711adb2c

Make sure string data list is consistent. - Make sure string data list is uniquely - Name of inserted/injected class is also in the list.
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 25 Jul 2011 21:53:33 +0800
parents c0c127c7b37e
children 355986e5cfbd
files paraspace/injection.py paraspace/tests/injection_test.py
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/paraspace/injection.py	Mon Jul 25 20:37:32 2011 +0800
+++ b/paraspace/injection.py	Mon Jul 25 21:53:33 2011 +0800
@@ -109,11 +109,11 @@
         strdatas = [(obj_id, obj)
                     for obj_id, obj in visit_log.items()
                     if isinstance(obj, _DEX_StringDataItem)]
-        dex_str_2_strdata = dict([(strdata.data, strdata)
+        dex_str_2_strdata = dict([(strdata.data.data, strdata)
                                   for strdata in dex.stringDataItems.items])
         for obj_id, strdata in strdatas:
-            if strdata.data in dex_str_2_strdata:
-                visit_log[obj_id] = dex_str_2_strdata[strdata]
+            if strdata.data.data in dex_str_2_strdata:
+                visit_log[obj_id] = dex_str_2_strdata[strdata.data.data]
             else:
                 dex_append_obj_list(dex, strdata)
                 pass
--- a/paraspace/tests/injection_test.py	Mon Jul 25 20:37:32 2011 +0800
+++ b/paraspace/tests/injection_test.py	Mon Jul 25 21:53:33 2011 +0800
@@ -70,5 +70,11 @@
 
     classdata_map = _find_map(helloworld_unlinked, 0x2000)
     assert classdata_map.size == classdef_map.size
+
+    # Check strings
+    strdatas = helloworld_unlinked.stringDataItems.items
+    strs = sorted([strdata.data.data for strdata in strdatas])
+    assert len(strs) == len(set(strs)) # uniquely
+    assert 'Lcom/codemud/fakefile/fakefile;' in strs
     pass