- Timestamp:
- 03/27/11 21:46:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/pyregfi-smoketest.py
r214 r215 3 3 import sys 4 4 import gc 5 import time 5 6 import pyregfi 6 7 7 8 def usage(): 8 9 sys.stderr.write("USAGE: pyregfi-smoketest.py hive1 [hive2 ...]\n") 10 11 12 # helper function 13 def getCurrentPath(key): 14 if key == None: 15 return '' 16 path = [] 17 p = key 18 while p != None: 19 path.append(p.name) 20 if p.is_root(): 21 break 22 else: 23 p = p.get_parent() 24 path.reverse() 25 del path[0] 26 27 return path 9 28 10 29 … … 39 58 40 59 60 # For each key in the hive, this traverses the parent links up to the root, 61 # recording the path as it goes, and then uses the subtree/descend method 62 # to find the same key again, verifying it is the same. This test is currently 63 # very slow because no key caching is used. 64 def iterParentWalk(hive): 65 i = 1 66 for k in hive: 67 path = getCurrentPath(k) 68 try: 69 hive_iter = hive.subtree(path) 70 if hive_iter.current_key() != k: 71 print("WARNING: k != current_key for path '%s'." % path) 72 else: 73 i += 1 74 except Exception as e: 75 print("WARNING: Could not decend to path '%s'.\nError:\n %s\n%s" % (path,e.args,e)) 76 print(" Successfully tested paths on %d keys." % i) 77 41 78 42 79 if len(sys.argv) < 2: … … 44 81 sys.exit(1) 45 82 83 84 tests = [("iterTally",iterTally),("iterParentWalk",iterParentWalk),] 85 46 86 files = [] 47 87 for f in sys.argv[1:]: 48 88 files.append((f, open(f,"r+b"))) 49 89 50 tests = [("iterTally",iterTally),]51 90 91 start_time = time.time() 52 92 for hname,fh in files: 53 93 hive = pyregfi.Hive(fh) 54 94 for tname,t in tests: 95 teststart = time.time() 55 96 tstr = "'%s' on '%s'" % (tname,hname) 56 97 print("##BEGIN %s:" % tstr) 57 98 t(hive) 58 print("##END %s; messages:" % tstr)99 print("##END %s; runtime=%f; messages:" % (tstr, time.time() - teststart)) 59 100 print(pyregfi.GetLogMessages()) 60 101 print 61 hive = None102 sys.stdout.flush() 62 103 104 hive = None 63 105 files = None 64 106 tests = None 65 107 gc.collect() 108 print("### Tests Completed, runtime: %f ###" % (time.time() - start_time)) 66 109 #print(gc.garbage)
Note: See TracChangeset
for help on using the changeset viewer.