Changeset 225 for test


Ignore:
Timestamp:
04/05/11 11:17:41 (13 years ago)
Author:
tim
Message:

added test case for python callback read/seek
began adding windows support in pyregfi
improved win32 build target

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/pyregfi-smoketest.py

    r224 r225  
    33import sys
    44import gc
     5import io
    56import time
    67import pyregfi
     8
    79
    810def usage():
     
    1517# Gathers various (meaningless) statistics to exercise simple attribute access
    1618# and to hopefully smoke out any bugs that can be identified by changing stats
    17 def iterTallyNames(hive):
     19def iterTallyNames(hive, fh):
    1820    key_count = 0
    1921    key_lens = 0
     
    6062# to find the same key again, verifying it is the same.  This test is currently
    6163# very slow because no key caching is used.
    62 def iterParentWalk(hive):
     64def iterParentWalk(hive, fh):
    6365    i = 1
    6466    for k in hive:
     
    7779# Uses the HiveIterator to walk all keys
    7880# Gathers various (meaningless) statistics about data/data_raw attributes
    79 def iterTallyData(hive):
     81def iterTallyData(hive, fh):
    8082    data_stat = 0.0
    8183    dataraw_stat = 0.0
     
    127129# list dictionary access.  Also builds nonsensical statistics as an excuse
    128130# to access various base structure attributes.
    129 def recurseKeyTally(hive):
     131def recurseKeyTally(hive, fh):
    130132    checkValues(hive.root)
    131133    recurseTree(hive.root, checkValues)
     
    135137
    136138# Iterates hive gathering stats about security and classname records
    137 def iterFetchRelated(hive):
     139def iterFetchRelated(hive, fh):
    138140    security_stat = 0.0
    139141    classname_stat = 0.0
     
    157159
    158160
    159 def iterIterWalk(hive):
     161def iterIterWalk(hive, fh):
    160162    sk_stat = 0.0
    161163    v_stat = 0.0
     
    183185
    184186
    185 
     187def iterCallbackIO(hive, fh):
     188    fh.seek(0)
     189    new_fh = io.BytesIO(fh.read())
     190    new_hive = pyregfi.Hive(new_fh)
     191    for k in new_hive:
     192        pass
     193
     194   
    186195if len(sys.argv) < 2:
    187196    usage()
     
    196205         ("iterIterWalk",iterIterWalk),]
    197206
    198 tests = [("iterIterWalk",iterIterWalk),]
     207tests = [("iterCallbackIO",iterCallbackIO),]
    199208
    200209
     
    211220        tstr = "'%s' on '%s'" % (tname,hname)
    212221        print("##BEGIN %s:" % tstr)
    213         t(hive)
     222        t(hive, fh)
    214223        print("##END %s; runtime=%f; messages:" % (tstr, time.time() - teststart))
    215224        print(pyregfi.GetLogMessages())
Note: See TracChangeset for help on using the changeset viewer.