Skip to content

Commit

Permalink
Add a new interesting test to check different behaviour based on comm…
Browse files Browse the repository at this point in the history
…and line switches.
  • Loading branch information
nbp committed Dec 17, 2015
1 parent ce5eba6 commit 2003269
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions interestingness/diffTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

from optparse import OptionParser

import timedRun
import filecmp


def parseOptions(arguments):
parser = OptionParser()
parser.disable_interspersed_args()
parser.add_option('-t', '--timeout', type='int', action='store', dest='condTimeout',
default=120,
help='Optionally set the timeout. Defaults to "%default" seconds.')
parser.add_option('-a', '--a-arg', type='string', action='append', dest='aArgs',
default=[],
help='Set of extra arguments given to first run.')
parser.add_option('-b', '--b-arg', type='string', action='append', dest='bArgs',
default=[],
help='Set of extra arguments given to second run.')

options, args = parser.parse_args(arguments)

return options.condTimeout, options.aArgs, options.bArgs, args

def interesting(cliArgs, tempPrefix):
(timeout, aArgs, bArgs, args) = parseOptions(cliArgs)

aRuninfo = timedRun.timed_run(args[:1] + aArgs + args[1:], timeout, tempPrefix + "-a")
bRuninfo = timedRun.timed_run(args[:1] + bArgs + args[1:], timeout, tempPrefix + "-b")
timeString = " (1st Run: %.3f seconds) (2nd Run: %.3f seconds)" % (aRuninfo.elapsedtime, bRuninfo.elapsedtime)

if aRuninfo.sta != timedRun.TIMED_OUT and bRuninfo.sta != timedRun.TIMED_OUT:
if aRuninfo.rc != bRuninfo.rc:
print ("[Interesting] Different return code. (%d, %d) " % (aRuninfo.rc, bRuninfo.rc)) + timeString
return True
if not filecmp.cmp(aRuninfo.out, bRuninfo.out):
print "[Interesting] Different output. " + timeString
return True
if not filecmp.cmp(aRuninfo.err, bRuninfo.err):
print "[Interesting] Different error output. " + timeString
return True
else:
print "[Uninteresting] At least one test timed out." + timeString
return False

print "[Uninteresting] Identical behaviour." + timeString
return False

0 comments on commit 2003269

Please sign in to comment.