X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2Flit%2Flit%2FLitConfig.py;h=2402221bef12daabbbfef15401948b4ac52c353d;hb=d3bcf04e8331314fbfec3f0af41e137b6bd242c7;hp=bcaea13042a101ebe6214c5786cdc4e0407244de;hpb=6c749c5fbc94a9f133ed05e389aab4309f187684;p=oota-llvm.git diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py index bcaea13042a..2402221bef1 100644 --- a/utils/lit/lit/LitConfig.py +++ b/utils/lit/lit/LitConfig.py @@ -4,11 +4,12 @@ import os import sys import lit.Test -import lit.TestFormats +import lit.formats import lit.TestingConfig -import lit.Util +import lit.util -class LitConfig: +# LitConfig must be a new style class for properties to work +class LitConfig(object): """LitConfig - Configuration data for a 'lit' test runner instance, shared across all tests. @@ -18,19 +19,11 @@ class LitConfig: easily. """ - # Provide access to Test module. - Test = lit.Test - - # Provide access to built-in formats. - formats = lit.TestFormats - - # Provide access to built-in utility functions. - util = lit.Util - def __init__(self, progname, path, quiet, useValgrind, valgrindLeakCheck, valgrindArgs, noExecute, debug, isWindows, - params, config_prefix = None): + params, config_prefix = None, + maxIndividualTestTime = 0): # The name of the test runner. self.progname = progname # The items to add to the PATH environment variable. @@ -66,6 +59,36 @@ class LitConfig: self.valgrindArgs.append('--leak-check=no') self.valgrindArgs.extend(self.valgrindUserArgs) + self.maxIndividualTestTime = maxIndividualTestTime + + @property + def maxIndividualTestTime(self): + """ + Interface for getting maximum time to spend executing + a single test + """ + return self._maxIndividualTestTime + + @maxIndividualTestTime.setter + def maxIndividualTestTime(self, value): + """ + Interface for setting maximum time to spend executing + a single test + """ + self._maxIndividualTestTime = value + if self.maxIndividualTestTime > 0: + # The current implementation needs psutil to set + # a timeout per test. Check it's available. + # See lit.util.killProcessAndChildren() + try: + import psutil + except ImportError: + self.fatal("Setting a timeout per test requires the" + " Python psutil module but it could not be" + " found. Try installing it via pip or via" + " your operating system's package manager.") + elif self.maxIndividualTestTime < 0: + self.fatal('The timeout per test must be >= 0 seconds') def load_config(self, config, path): """load_config(config, path) - Load a config object from an alternate @@ -80,31 +103,25 @@ class LitConfig: if self.bashPath is not None: return self.bashPath - self.bashPath = lit.Util.which('bash', os.pathsep.join(self.path)) + self.bashPath = lit.util.which('bash', os.pathsep.join(self.path)) if self.bashPath is None: - # Check some known paths. - for path in ('/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash'): - if os.path.exists(path): - self.bashPath = path - break + self.bashPath = lit.util.which('bash') if self.bashPath is None: - self.warning("Unable to find 'bash'.") self.bashPath = '' return self.bashPath def getToolsPath(self, dir, paths, tools): if dir is not None and os.path.isabs(dir) and os.path.isdir(dir): - if not lit.Util.checkToolsPath(dir, tools): + if not lit.util.checkToolsPath(dir, tools): return None else: - dir = lit.Util.whichTools(tools, paths) + dir = lit.util.whichTools(tools, paths) # bash - self.bashPath = lit.Util.which('bash', dir) + self.bashPath = lit.util.which('bash', dir) if self.bashPath is None: - self.note("Unable to find 'bash.exe'.") self.bashPath = '' return dir