aboutsummaryrefslogtreecommitdiff
path: root/utils/lit
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
commit36bf506ad3c99a309ca8bd73bd03563d8d068ac0 (patch)
treeb4dc751bcee540346911aa4115729eff2f991657 /utils/lit
parentf9666f9b3a3d26810deae8cd54feb6e47ecee61a (diff)
downloadsrc-36bf506ad3c99a309ca8bd73bd03563d8d068ac0.tar.gz
src-36bf506ad3c99a309ca8bd73bd03563d8d068ac0.zip
Update LLVM to r86025.vendor/llvm/llvm-r86025
Notes
Notes: svn path=/vendor/llvm/dist/; revision=198892 svn path=/vendor/llvm/llvm-r86025/; revision=198894; tag=vendor/llvm/llvm-r86025
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/TestRunner.py68
-rw-r--r--utils/lit/Util.py2
-rwxr-xr-xutils/lit/lit.py27
3 files changed, 64 insertions, 33 deletions
diff --git a/utils/lit/TestRunner.py b/utils/lit/TestRunner.py
index 34e828bf9609..bee1167f6af7 100644
--- a/utils/lit/TestRunner.py
+++ b/utils/lit/TestRunner.py
@@ -15,6 +15,10 @@ class InternalShellError(Exception):
# Don't use close_fds on Windows.
kUseCloseFDs = platform.system() != 'Windows'
+
+# Use temporary files to replace /dev/null on Windows.
+kAvoidDevNull = platform.system() == 'Windows'
+
def executeCommand(command, cwd=None, env=None):
p = subprocess.Popen(command, cwd=cwd,
stdin=subprocess.PIPE,
@@ -63,21 +67,30 @@ def executeShCmd(cmd, cfg, cwd, results):
# output. This is null until we have seen some output using
# stderr.
for i,j in enumerate(cmd.commands):
+ # Apply the redirections, we use (N,) as a sentinal to indicate stdin,
+ # stdout, stderr for N equal to 0, 1, or 2 respectively. Redirects to or
+ # from a file are represented with a list [file, mode, file-object]
+ # where file-object is initially None.
redirects = [(0,), (1,), (2,)]
for r in j.redirects:
if r[0] == ('>',2):
redirects[2] = [r[1], 'w', None]
+ elif r[0] == ('>>',2):
+ redirects[2] = [r[1], 'a', None]
elif r[0] == ('>&',2) and r[1] in '012':
redirects[2] = redirects[int(r[1])]
elif r[0] == ('>&',) or r[0] == ('&>',):
redirects[1] = redirects[2] = [r[1], 'w', None]
elif r[0] == ('>',):
redirects[1] = [r[1], 'w', None]
+ elif r[0] == ('>>',):
+ redirects[1] = [r[1], 'a', None]
elif r[0] == ('<',):
redirects[0] = [r[1], 'r', None]
else:
raise NotImplementedError,"Unsupported redirect: %r" % (r,)
+ # Map from the final redirections to something subprocess can handle.
final_redirects = []
for index,r in enumerate(redirects):
if r == (0,):
@@ -95,7 +108,10 @@ def executeShCmd(cmd, cfg, cwd, results):
result = subprocess.PIPE
else:
if r[2] is None:
- r[2] = open(r[0], r[1])
+ if kAvoidDevNull and r[0] == '/dev/null':
+ r[2] = tempfile.TemporaryFile(mode=r[1])
+ else:
+ r[2] = open(r[0], r[1])
result = r[2]
final_redirects.append(result)
@@ -317,7 +333,24 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
return executeCommand(command, cwd=cwd, env=test.config.environment)
-def parseIntegratedTestScript(test, xfailHasColon, requireAndAnd):
+def isExpectedFail(xfails, xtargets, target_triple):
+ # Check if any xfail matches this target.
+ for item in xfails:
+ if item == '*' or item in target_triple:
+ break
+ else:
+ return False
+
+ # If so, see if it is expected to pass on this target.
+ #
+ # FIXME: Rename XTARGET to something that makes sense, like XPASS.
+ for item in xtargets:
+ if item == '*' or item in target_triple:
+ return False
+
+ return True
+
+def parseIntegratedTestScript(test, requireAndAnd):
"""parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
script and extract the lines to 'RUN' as well as 'XFAIL' and 'XTARGET'
information. The RUN lines also will have variable substitution performed.
@@ -361,12 +394,9 @@ def parseIntegratedTestScript(test, xfailHasColon, requireAndAnd):
script[-1] = script[-1][:-1] + ln
else:
script.append(ln)
- elif xfailHasColon and 'XFAIL:' in ln:
+ elif 'XFAIL:' in ln:
items = ln[ln.index('XFAIL:') + 6:].split(',')
xfails.extend([s.strip() for s in items])
- elif not xfailHasColon and 'XFAIL' in ln:
- items = ln[ln.index('XFAIL') + 5:].split(',')
- xfails.extend([s.strip() for s in items])
elif 'XTARGET:' in ln:
items = ln[ln.index('XTARGET:') + 8:].split(',')
xtargets.extend([s.strip() for s in items])
@@ -405,7 +435,8 @@ def parseIntegratedTestScript(test, xfailHasColon, requireAndAnd):
# Strip off '&&'
script[i] = ln[:-2]
- return script,xfails,xtargets,tmpBase,execdir
+ isXFail = isExpectedFail(xfails, xtargets, test.suite.config.target_triple)
+ return script,isXFail,tmpBase,execdir
def formatTestOutput(status, out, err, exitCode, script):
output = StringIO.StringIO()
@@ -428,11 +459,11 @@ def executeTclTest(test, litConfig):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- res = parseIntegratedTestScript(test, True, False)
+ res = parseIntegratedTestScript(test, False)
if len(res) == 2:
return res
- script, xfails, xtargets, tmpBase, execdir = res
+ script, isXFail, tmpBase, execdir = res
if litConfig.noExecute:
return (Test.PASS, '')
@@ -444,19 +475,6 @@ def executeTclTest(test, litConfig):
if len(res) == 2:
return res
- isXFail = False
- for item in xfails:
- if item == '*' or item in test.suite.config.target_triple:
- isXFail = True
- break
-
- # If this is XFAIL, see if it is expected to pass on this target.
- if isXFail:
- for item in xtargets:
- if item == '*' or item in test.suite.config.target_triple:
- isXFail = False
- break
-
out,err,exitCode = res
if isXFail:
ok = exitCode != 0
@@ -474,11 +492,11 @@ def executeShTest(test, litConfig, useExternalSh, requireAndAnd):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- res = parseIntegratedTestScript(test, False, requireAndAnd)
+ res = parseIntegratedTestScript(test, requireAndAnd)
if len(res) == 2:
return res
- script, xfails, xtargets, tmpBase, execdir = res
+ script, isXFail, tmpBase, execdir = res
if litConfig.noExecute:
return (Test.PASS, '')
@@ -494,7 +512,7 @@ def executeShTest(test, litConfig, useExternalSh, requireAndAnd):
return res
out,err,exitCode = res
- if xfails:
+ if isXFail:
ok = exitCode != 0
status = (Test.XPASS, Test.XFAIL)[ok]
else:
diff --git a/utils/lit/Util.py b/utils/lit/Util.py
index e62a8ed81dc1..66c5e46f690a 100644
--- a/utils/lit/Util.py
+++ b/utils/lit/Util.py
@@ -15,7 +15,7 @@ def detectCPUs():
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
# Windows:
if os.environ.has_key("NUMBER_OF_PROCESSORS"):
- ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
+ ncpus = int(os.environ["NUMBER_OF_PROCESSORS"])
if ncpus > 0:
return ncpus
return 1 # Default
diff --git a/utils/lit/lit.py b/utils/lit/lit.py
index 5b24286e22f0..a856473c228e 100755
--- a/utils/lit/lit.py
+++ b/utils/lit/lit.py
@@ -16,9 +16,13 @@ from TestingConfig import TestingConfig
import LitConfig
import Test
+# Configuration files to look for when discovering test suites. These can be
+# overridden with --config-prefix.
+#
# FIXME: Rename to 'config.lit', 'site.lit', and 'local.lit' ?
-kConfigName = 'lit.cfg'
-kSiteConfigName = 'lit.site.cfg'
+gConfigName = 'lit.cfg'
+gSiteConfigName = 'lit.site.cfg'
+
kLocalConfigName = 'lit.local.cfg'
class TestingProgressDisplay:
@@ -134,10 +138,10 @@ class Tester(threading.Thread):
self.display.update(test)
def dirContainsTestSuite(path):
- cfgpath = os.path.join(path, kSiteConfigName)
+ cfgpath = os.path.join(path, gSiteConfigName)
if os.path.exists(cfgpath):
return cfgpath
- cfgpath = os.path.join(path, kConfigName)
+ cfgpath = os.path.join(path, gConfigName)
if os.path.exists(cfgpath):
return cfgpath
@@ -268,7 +272,7 @@ def getTestsInSuite(ts, path_in_suite, litConfig,
file_sourcepath = os.path.join(source_path, filename)
if not os.path.isdir(file_sourcepath):
continue
-
+
# Check for nested test suites, first in the execpath in case there is a
# site configuration and then in the source path.
file_execpath = ts.getExecPath(path_in_suite + (filename,))
@@ -283,7 +287,7 @@ def getTestsInSuite(ts, path_in_suite, litConfig,
subiter = getTestsInSuite(ts, path_in_suite + (filename,),
litConfig, testSuiteCache,
localConfigCache)
-
+
for res in subiter:
yield res
@@ -314,6 +318,9 @@ def main():
parser.add_option("-j", "--threads", dest="numThreads", metavar="N",
help="Number of testing threads",
type=int, action="store", default=None)
+ parser.add_option("", "--config-prefix", dest="configPrefix",
+ metavar="NAME", help="Prefix for 'lit' config files",
+ action="store", default=None)
group = OptionGroup(parser, "Output Format")
# FIXME: I find these names very confusing, although I like the
@@ -379,6 +386,11 @@ def main():
if not args:
parser.error('No inputs specified')
+ if opts.configPrefix is not None:
+ global gConfigName, gSiteConfigName
+ gConfigName = '%s.cfg' % opts.configPrefix
+ gSiteConfigName = '%s.site.cfg' % opts.configPrefix
+
if opts.numThreads is None:
opts.numThreads = Util.detectCPUs()
@@ -413,7 +425,8 @@ def main():
if opts.showSuites:
suitesAndTests = dict([(ts,[])
- for ts,_ in testSuiteCache.values()])
+ for ts,_ in testSuiteCache.values()
+ if ts])
for t in tests:
suitesAndTests[t.suite].append(t)