- Timestamp:
- 03/31/11 13:20:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/pyregfi-smoketest.py
r219 r220 8 8 def usage(): 9 9 sys.stderr.write("USAGE: pyregfi-smoketest.py hive1 [hive2 ...]\n") 10 11 12 13 14 # Uses the HiveIterator to walk all keys 15 # Gathers various (meaningless) statistics to exercise simple attribute access 16 # and to hopefully smoke out any bugs that can be identified by changing stats 17 def iterTallyNames(hive): 18 key_count = 0 19 key_lens = 0 20 key_rawlens = 0 21 value_count = 0 22 value_lens = 0 23 value_rawlens = 0 24 25 for k in hive: 26 key_count += 1 27 if k.name != None: 28 key_lens += len(k.name) 29 if k.name_raw != None: 30 key_rawlens += len(k.name_raw) 31 32 for v in k.values: 33 value_count += 1 34 if v.name != None: 35 value_lens += len(v.name) 36 if v.name_raw != None: 37 value_rawlens += len(v.name_raw) 38 39 print(" Counts: keys=%d, values=%d" % (key_count, value_count)) 40 print(" Total name length: keys=%d, values=%d" % (key_lens, value_lens)) 41 print(" Total raw name lengths: keys=%d, values=%d" % (key_rawlens, value_rawlens)) 10 42 11 43 … … 23 55 24 56 return path 25 26 27 # Uses the HiveIterator to walk all keys28 # Gathers various (meaningless) statistics to exercise simple attribute access29 # and to hopefully smoke out any bugs that can be identified by changing stats30 def iterTallyNames(hive):31 key_count = 032 key_lens = 033 key_rawlens = 034 value_count = 035 value_lens = 036 value_rawlens = 037 38 for k in hive:39 key_count += 140 if k.name != None:41 key_lens += len(k.name)42 if k.name_raw != None:43 key_rawlens += len(k.name_raw)44 45 for v in k.values:46 value_count += 147 if v.name != None:48 value_lens += len(v.name)49 if v.name_raw != None:50 value_rawlens += len(v.name_raw)51 52 print(" Counts: keys=%d, values=%d" % (key_count, value_count))53 print(" Total name length: keys=%d, values=%d" % (key_lens, value_lens))54 print(" Total raw name lengths: keys=%d, values=%d" % (key_rawlens, value_rawlens))55 56 57 57 58 # For each key in the hive, this traverses the parent links up to the root, … … 154 155 print(" Modified stat: %f" % modified_stat) 155 156 157 158 159 def iterIterWalk(hive): 160 sk_stat = 0.0 161 v_stat = 0.0 162 iter = pyregfi.HiveIterator(hive) 163 for k in iter: 164 path = getCurrentPath(k) 165 try: 166 hive_iter = hive.subtree(path) 167 sk = hive_iter.first_subkey() 168 while sk != None: 169 ssk = hive_iter.find_subkey(sk.name) 170 sk_stat += len(ssk.name) 171 sk = hive_iter.next_subkey() 172 173 v = hive_iter.first_value() 174 while v != None: 175 vv = hive_iter.find_value(v.name) 176 v_stat += len(vv.name) 177 v = hive_iter.next_value() 178 179 except Exception as e: 180 print("WARNING: Could not decend to path '%s'.\nError:\n %s\n%s" % (path,e.args,e)) 181 print(" Subkey stat: %f" % sk_stat) 182 print(" Value stat: %f" % v_stat) 183 184 185 156 186 if len(sys.argv) < 2: 157 187 usage() … … 159 189 160 190 161 #tests = [("iterTallyNames",iterTallyNames),("iterParentWalk",iterParentWalk),("iterTallyData",iterTallyData),("recurseKeyTally",recurseKeyTally),("iterFetchRelated",iterFetchRelated),] 162 tests = [("iterFetchRelated",iterFetchRelated),] 191 tests = [("iterTallyNames",iterTallyNames), 192 ("iterParentWalk",iterParentWalk), 193 ("iterTallyData",iterTallyData), 194 ("recurseKeyTally",recurseKeyTally), 195 ("iterFetchRelated",iterFetchRelated), 196 ("iterIterWalk",iterIterWalk),] 197 198 tests = [("iterIterWalk",iterIterWalk),] 199 163 200 164 201 files = []
Note: See TracChangeset
for help on using the changeset viewer.