Changeset 217 for test


Ignore:
Timestamp:
03/30/11 00:13:38 (14 years ago)
Author:
tim
Message:

added another test
made is_root check more correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/pyregfi-smoketest.py

    r216 r217  
    103103
    104104
     105recurseKey_stat = 0.0
     106recurseValue_stat = 0.0
     107def checkValues(key):
     108    global recurseKey_stat
     109    global recurseValue_stat
     110    recurseKey_stat += (key.mtime.low^key.mtime.high - key.max_bytes_subkeyname) * key.flags
     111    for v in key.values:
     112        recurseValue_stat += (v.data_off - v.data_size) / (1.0 + v.flags) + v.data_in_offset
     113        value = key.values[v.name]
     114        if v != value:
     115            print("WARNING: iterator value '%s' does not match dictionary value '%s'."
     116                  % (v.name, value.name))
     117
     118def recurseTree(cur, operation):
     119    for k in cur.subkeys:
     120        key = cur.subkeys[k.name]
     121        if k != key:
     122            print("WARNING: iterator subkey '%s' does not match dictionary subkey '%s'."
     123                  % (k.name, key.name))
     124        del key
     125        operation(k)
     126        recurseTree(k, operation)
     127
     128# Retrieves all keys by recursion, rather than the iterator, and validates
     129# list dictionary access.  Also builds nonsensical statistics as an excuse
     130# to access various base structure attributes.
     131def recurseKeyTally(hive):
     132    root = hive.get_root()
     133    checkValues(root)
     134    recurseTree(root, checkValues)
     135    print("  Key stat: %f" % recurseKey_stat)
     136    print("  Value stat: %f" % recurseValue_stat)
     137
    105138
    106139if len(sys.argv) < 2:
     
    109142
    110143
    111 #tests = [("iterTallyNames",iterTallyNames),("iterParentWalk",iterParentWalk),]
    112 tests = [("iterTallyData",iterTallyData),]
     144#tests = [("iterTallyNames",iterTallyNames),("iterParentWalk",iterParentWalk),("iterTallyData",iterTallyData),]
     145tests = [("recurseKeyTally",recurseKeyTally),]
    113146
    114147files = []
Note: See TracChangeset for help on using the changeset viewer.