-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new interesting test to check different behaviour based on comm…
…and line switches.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |