diff --git a/clang/utils/test/MultiTestRunner.py b/clang/utils/test/MultiTestRunner.py index 93532ebf64a7..00cdfd49368c 100755 --- a/clang/utils/test/MultiTestRunner.py +++ b/clang/utils/test/MultiTestRunner.py @@ -167,14 +167,12 @@ class Tester(threading.Thread): opts = self.provider.opts startTime = time.time() code, output = TestRunner.runOneTest(self.provider.config, - path, base, - opts.clang, opts.clangcc, - opts.useValgrind) + path, base) elapsed = time.time() - startTime except KeyboardInterrupt: # This is a sad hack. Unfortunately subprocess goes # bonkers with ctrl-c and we start forking merrily. - print 'Ctrl-C detected, goodbye.' + print '\nCtrl-C detected, goodbye.' os.kill(0,9) self.provider.setResult(index, TestResult(path, code, output, elapsed)) @@ -313,6 +311,10 @@ def main(): if opts.clangcc is None: opts.clangcc = TestRunner.inferClangCC(cfg, opts.clang) + cfg.clang = opts.clang + cfg.clangcc = opts.clangcc + cfg.useValgrind = opts.useValgrind + # FIXME: It could be worth loading these in parallel with testing. allTests = list(getTests(cfg, args)) allTests.sort() diff --git a/clang/utils/test/TestRunner.py b/clang/utils/test/TestRunner.py index fb3d172fb660..9206427b451a 100755 --- a/clang/utils/test/TestRunner.py +++ b/clang/utils/test/TestRunner.py @@ -1,20 +1,3 @@ -#!/usr/bin/env python -# -# TestRunner.py - This script is used to run arbitrary unit tests. Unit -# tests must contain the command used to run them in the input file, starting -# immediately after a "RUN:" string. -# -# This runner recognizes and replaces the following strings in the command: -# -# %s - Replaced with the input name of the program, or the program to -# execute, as appropriate. -# %S - Replaced with the directory where the input resides. -# %llvmgcc - llvm-gcc command -# %llvmgxx - llvm-g++ command -# %prcontext - prcontext.tcl script -# %t - temporary file name (derived from testcase name) -# - import errno import os import platform @@ -39,7 +22,7 @@ class TestStatus: def getName(code): return TestStatus.kNames[code] -def executeScript(cfg, script, commands, cwd, useValgrind): +def executeScript(cfg, script, commands, cwd): # Write script file f = open(script,'w') if kSystemName == 'Windows': @@ -53,9 +36,9 @@ def executeScript(cfg, script, commands, cwd, useValgrind): command = ['cmd','/c', script] else: command = ['/bin/sh', script] - if useValgrind: + if cfg.useValgrind: # FIXME: Running valgrind on sh is overkill. We probably could just - # ron on clang with no real loss. + # run on clang with no real loss. command = ['valgrind', '-q', '--tool=memcheck', '--leak-check=no', '--trace-children=yes', '--error-exitcode=123'] + command @@ -75,7 +58,7 @@ def executeScript(cfg, script, commands, cwd, useValgrind): return out, err, exitCode import StringIO -def runOneTest(cfg, testPath, tmpBase, clang, clangcc, useValgrind): +def runOneTest(cfg, testPath, tmpBase): # Make paths absolute. tmpBase = os.path.abspath(tmpBase) testPath = os.path.abspath(testPath) @@ -90,8 +73,8 @@ def runOneTest(cfg, testPath, tmpBase, clang, clangcc, useValgrind): substitutions = [('%s', testPath), ('%S', os.path.dirname(testPath)), ('%t', tmpBase + '.tmp'), - (' clang ', ' ' + clang + ' '), - (' clang-cc ', ' ' + clangcc + ' ')] + (' clang ', ' ' + cfg.clang + ' '), + (' clang-cc ', ' ' + cfg.clangcc + ' ')] # Collect the test lines from the script. scriptLines = [] @@ -137,8 +120,7 @@ def runOneTest(cfg, testPath, tmpBase, clang, clangcc, useValgrind): scriptLines[i] = ln[:-2] out, err, exitCode = executeScript(cfg, script, scriptLines, - os.path.dirname(testPath), - useValgrind) + os.path.dirname(testPath)) if xfailLines: ok = exitCode != 0 status = (TestStatus.XPass, TestStatus.XFail)[ok] diff --git a/clang/utils/test/TestingConfig.py b/clang/utils/test/TestingConfig.py index 6b33589da5b2..998642b47b7c 100644 --- a/clang/utils/test/TestingConfig.py +++ b/clang/utils/test/TestingConfig.py @@ -13,9 +13,13 @@ class TestingConfig: environment = data.get('environment', {})) def __init__(self, suffixes, environment): - self.root = None self.suffixes = set(suffixes) self.environment = dict(environment) - + # Variables set internally. + self.root = None + self.useValgrind = None + # FIXME: These need to move into a substitutions mechanism. + self.clang = None + self.clangcc = None