aboutsummaryrefslogtreecommitdiffstats
path: root/utils/lit
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-15 01:02:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-15 01:02:09 +0000
commit40c67b5832877935a555fc63bfaa735332c79700 (patch)
treea12dd454414df2b467b39abcd5e2fe2eee46d2e9 /utils/lit
parentbfa092958393ec621767771f9f168e7ff973a179 (diff)
downloadexternal_llvm-40c67b5832877935a555fc63bfaa735332c79700.zip
external_llvm-40c67b5832877935a555fc63bfaa735332c79700.tar.gz
external_llvm-40c67b5832877935a555fc63bfaa735332c79700.tar.bz2
lit: Add --repeat=N option, for running each test N times.
- Currently just useful for timing, although it could be extended as one (bad) way to deal with flaky tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/Test.py8
-rw-r--r--utils/lit/TestRunner.py2
-rwxr-xr-xutils/lit/lit.py21
3 files changed, 27 insertions, 4 deletions
diff --git a/utils/lit/Test.py b/utils/lit/Test.py
index d3f6274..1f6556b 100644
--- a/utils/lit/Test.py
+++ b/utils/lit/Test.py
@@ -54,6 +54,14 @@ class Test:
self.output = None
# The wall time to execute this test, if timing and once complete.
self.elapsed = None
+ # The repeat index of this test, or None.
+ self.index = None
+
+ def copyWithIndex(self, index):
+ import copy
+ res = copy.copy(self)
+ res.index = index
+ return res
def setResult(self, result, output, elapsed):
assert self.result is None, "Test result already set!"
diff --git a/utils/lit/TestRunner.py b/utils/lit/TestRunner.py
index 5b4538f..20fbc6c 100644
--- a/utils/lit/TestRunner.py
+++ b/utils/lit/TestRunner.py
@@ -367,6 +367,8 @@ def parseIntegratedTestScript(test):
execpath = test.getExecPath()
execdir,execbase = os.path.split(execpath)
tmpBase = os.path.join(execdir, 'Output', execbase)
+ if test.index is not None:
+ tmpBase += '_%d' % test.index
# We use #_MARKER_# to hide %% while we do the other substitutions.
substitutions = [('%%', '#_MARKER_#')]
diff --git a/utils/lit/lit.py b/utils/lit/lit.py
index 70bd060..dcdce7d 100755
--- a/utils/lit/lit.py
+++ b/utils/lit/lit.py
@@ -388,6 +388,9 @@ def main():
group.add_option("", "--no-tcl-as-sh", dest="useTclAsSh",
help="Don't run Tcl scripts using 'sh'",
action="store_false", default=True)
+ group.add_option("", "--repeat", dest="repeatTests", metavar="N",
+ help="Repeat tests N times (for timing)",
+ action="store", default=None, type=int)
parser.add_option_group(group)
(opts, args) = parser.parse_args()
@@ -472,6 +475,11 @@ def main():
header = '-- Testing: %d%s tests, %d threads --'%(len(tests),extra,
opts.numThreads)
+ if opts.repeatTests:
+ tests = [t.copyWithIndex(i)
+ for t in tests
+ for i in range(opts.repeatTests)]
+
progressBar = None
if not opts.quiet:
if opts.succinct and opts.useProgressBar:
@@ -524,11 +532,16 @@ def main():
print
if opts.timeTests:
- byTime = list(tests)
- byTime.sort(key = lambda t: t.elapsed)
+ # Collate, in case we repeated tests.
+ times = {}
+ for t in tests:
+ key = t.getFullName()
+ times[key] = times.get(key, 0.) + t.elapsed
+
+ byTime = list(times.items())
+ byTime.sort(key = lambda (name,elapsed): elapsed)
if byTime:
- Util.printHistogram([(t.getFullName(), t.elapsed) for t in byTime],
- title='Tests')
+ Util.printHistogram(byTime, title='Tests')
for name,code in (('Expected Passes ', Test.PASS),
('Expected Failures ', Test.XFAIL),