Skip to content

Commit

Permalink
adding strongly connected check to debug tool
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeggleston committed Apr 19, 2014
1 parent 54b8fab commit be65fe4
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions pydebug/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def deps(self):
def in_deps(self):
return [instances.get(d) for d in self._in_deps]

def depends_on(self, iid):
return iid in self._deps
def depends_on(self, *iids):
return [iid in self._deps for iid in iids]

def is_dependency_of(self, iid):
return iid in self._in_deps
def is_dependency_of(self, *iids):
return [iid in self._in_deps for iid in iids]

@property
def is_strongly_connected(self):
Expand Down Expand Up @@ -118,11 +118,19 @@ def _component_cmp(x, y):
else:
return -1 if xID.bytes < yID.bytes else 1

strong_map = {}
for component in tsorted:
if len(component) > 1:
cset = set(component)
for iid in cset:
strong_map[iid] = cset


expected_execution_order = sum([sorted(c, cmp=_component_cmp) for c in tsorted], [])

minlen = min(len(execution_order), len(expected_execution_order))

def evaluate_consistency(history=2):
def check_consistency(history=5):
for i, (actual, expected) in enumerate(zip(execution_order[:minlen], expected_execution_order[:minlen])):
if actual != expected:
print "execution inconsistency at", i
Expand All @@ -135,7 +143,22 @@ def evaluate_consistency(history=2):

break

evaluate_consistency()
check_consistency()

print ""
print ""

def check_strong_connections():
for iid, component in strong_map.items():
instance = instances[iid]
if instance.strongly_connected != component:
if instance.status >= COMMITTED:
print "strongly connected inconsistency for", iid
print " expected:", component
print " got:", instances[iid].strongly_connected
print ""

check_strong_connections()

instance = instances.get(argv.instance)
if instance:
Expand Down

0 comments on commit be65fe4

Please sign in to comment.