Skip to content

Commit

Permalink
improvements for probabilistic delta-debugging, especially
Browse files Browse the repository at this point in the history
  • Loading branch information
agroce committed Apr 18, 2018
1 parent 3ddda56 commit 1dfa1ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/randomtester.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ def parse_args():
parser.add_argument('--checkDeterminism', action='store_true',
help='Check determinism of pool objects.')
parser.add_argument('--determinismTries', type=int, default = 1,
help='Number of tries to catch nondeterminism (default 1).')
help='Number of tries to catch nondeterminism (default 1).')
parser.add_argument('--determinismDelay', type=float, default = 0,
help='Delay when checking for nondeterminism (default 0).')
parser.add_argument('--checkProcessDeterminism', action='store_true',
help='Check that tests are process deterministic.')
parser.add_argument('--processDetTries', type=int, default = 1,
help='Number of tries to catch process nondeterminism (default 1).')
parser.add_argument('--processDetDelay', type=int, default = 0,
parser.add_argument('--processDetDelay', type=float, default = 0,
help='Delay when checking process nondeterminism (default 0).')
parser.add_argument('-q', '--quickTests', action='store_true',
help="Produce quick tests for coverage (save a test for each newly reached coverage target).")
Expand Down Expand Up @@ -1481,8 +1483,8 @@ def main():

if config.checkProcessDeterminism and not testFailed:
print ("CHECKING PROCESS DETERMINISM...")
nondeterministic = sut.findProcessNondeterminism(replayTest,verbose=True,tries=config.processDetTries,
delay=config.processDetDelay)
nondeterministic = sut.findProcessNondeterminism(replayTest,verbose=True,tries=config.determinismTries,
delay=config.determinismDelay)
if nondeterministic != -1:
if not config.noAlphaConvert:
alphaReplay = sut.alphaConvert(replayTest[:nondeterministic])
Expand All @@ -1500,6 +1502,7 @@ def main():
sut.restart()
nondeterministic = False
for s in replayTest:
time.sleep(config.determinismDelay)
sut.safely(s)
ti = sut.trajectoryItem()
try:
Expand Down
8 changes: 7 additions & 1 deletion src/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def parse_args():
parser.add_argument('--coverMore', action='store_true',
help='Only allow reductions that increase code coverage.')
parser.add_argument('--checkDeterminism', action='store_true',
help='Reduce with respect to test being deterministic.')
help='Reduce with respect to test being deterministic (final state).')
parser.add_argument('--checkStepDeterminism', action='store_true',
help='Reduce with respect to test being deterministic (visible value).')
parser.add_argument('--determinismDelay', type=float, default=1.0,
help='Time delay for nondeterminism check.')
parser.add_argument('--determinismDelay0', type=float, default=None,
Expand Down Expand Up @@ -194,6 +196,10 @@ def main():
if config.checkDeterminism:
pred = (lambda t: sut.nondeterministic(t,delay=config.determinismDelay,tries=config.determinismTries,
delay0=config.determinismDelay0))

if config.checkStepDeterminism:
pred = (lambda t: sut.stepNondeterministic(t,delay=config.determinismDelay,tries=config.determinismTries,
delay0=config.determinismDelay0))

if config.checkProcessDeterminism:
pred = (lambda t: sut.processNondeterministic(t,delay=config.determinismDelay,tries=config.determinismTries,iterate=config.iterate))
Expand Down
10 changes: 8 additions & 2 deletions src/static/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,8 @@ def testCandidates(self, t, n):
candidates.append(tc)
return candidates

def reduce(self, test, pred, pruneGuards = True, keepLast = False, verbose = True, rgen = None, amplify = False, amplifyReplications = 1, stopFound = False, tryFast=True, testHandler = None, findLocations = False, noResetSplit = False, safeReduce = False):
def reduce(self, test, pred, pruneGuards = True, keepLast = False, verbose = True, rgen = None, amplify = False, amplifyReplications = 1, stopFound = False, tryFast=True, testHandler = None, findLocations = False, noResetSplit = False, safeReduce = False,
saveIntermediate = None):
"""
This function takes a test that has failed, and attempts to reduce it using a simplified version of Zeller's Delta-Debugging algorithm.
pruneGuards determines if disabled guards are automatically removed from reduced tests, keepLast determines if the last action must remain unchanged
Expand All @@ -1118,6 +1119,8 @@ def reduce(self, test, pred, pruneGuards = True, keepLast = False, verbose = Tru
except:
pass

intermediate = 0

if len(test) < 2:
return test

Expand Down Expand Up @@ -1237,7 +1240,10 @@ def reduce(self, test, pred, pruneGuards = True, keepLast = False, verbose = Tru
truePos = (lastRemove + removePos) % len(tb)
lastRemove = truePos
if verbose == "VERY":
print("check #",truePos,removePos,lastRemove)
print("check #",truePos,removePos,lastRemove)
if saveIntermediate != None:
self.saveTest(tb+addLast,saveIntermediate + "." + str(intermediate) + ".test")
intermediate += 1
reduced = True
break
if not reduced:
Expand Down

0 comments on commit 1dfa1ee

Please sign in to comment.