4 OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
8 TestingConfig - Information on the tests inside a suite.
12 def fromdefaults(litConfig):
14 fromdefaults(litConfig) -> TestingConfig
16 Create a TestingConfig object with default values.
18 # Set the environment based on the command line arguments.
20 'PATH' : os.pathsep.join(litConfig.path +
21 [os.environ.get('PATH','')]),
22 'LLVM_DISABLE_CRASH_REPORT' : '1',
25 pass_vars = ['LIBRARY_PATH', 'LD_LIBRARY_PATH', 'SYSTEMROOT', 'TERM',
26 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS',
27 'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL',
28 'SANITIZER_IGNORE_CVE_2016_2143']
30 val = os.environ.get(var, '')
31 # Check for empty string as some variables such as LD_PRELOAD cannot be empty
32 # ('') for OS's such as OpenBSD.
34 environment[var] = val
36 if sys.platform == 'win32':
38 'INCLUDE' : os.environ.get('INCLUDE',''),
39 'PATHEXT' : os.environ.get('PATHEXT',''),
40 'PYTHONUNBUFFERED' : '1',
41 'TEMP' : os.environ.get('TEMP',''),
42 'TMP' : os.environ.get('TMP',''),
45 # The option to preserve TEMP, TMP, and TMPDIR.
46 # This is intended to check how many temporary files would be generated
47 # (and be not cleaned up) in automated builders.
48 if 'LIT_PRESERVES_TMP' in os.environ:
50 'TEMP' : os.environ.get('TEMP',''),
51 'TMP' : os.environ.get('TMP',''),
52 'TMPDIR' : os.environ.get('TMPDIR',''),
55 # Set the default available features based on the LitConfig.
56 available_features = []
57 if litConfig.useValgrind:
58 available_features.append('valgrind')
59 if litConfig.valgrindLeakCheck:
60 available_features.append('vg_leak')
62 return TestingConfig(None,
66 environment = environment,
69 test_exec_root = None,
70 test_source_root = None,
72 available_features = available_features,
75 def load_from_path(self, path, litConfig):
77 load_from_path(path, litConfig)
79 Load the configuration module at the provided path into the given config
83 # Load the config script data.
90 litConfig.fatal('unable to load config file: %r' % (path,))
93 # Execute the config script to initialize the object.
94 cfg_globals = dict(globals())
95 cfg_globals['config'] = self
96 cfg_globals['lit_config'] = litConfig
97 cfg_globals['__file__'] = path
100 execfile(path, cfg_globals)
102 exec(compile(data, path, 'exec'), cfg_globals, None)
104 litConfig.note('... loaded config %r' % path)
106 e = sys.exc_info()[1]
107 # We allow normal system exit inside a config file to just
108 # return control without error.
114 'unable to parse config file %r, traceback: %s' % (
115 path, traceback.format_exc()))
117 self.finish(litConfig)
119 def __init__(self, parent, name, suffixes, test_format,
120 environment, substitutions, unsupported,
121 test_exec_root, test_source_root, excludes,
122 available_features, pipefail, limit_to_features = [],
125 self.name = str(name)
126 self.suffixes = set(suffixes)
127 self.test_format = test_format
128 self.environment = dict(environment)
129 self.substitutions = list(substitutions)
130 self.unsupported = unsupported
131 self.test_exec_root = test_exec_root
132 self.test_source_root = test_source_root
133 self.excludes = set(excludes)
134 self.available_features = set(available_features)
135 self.pipefail = pipefail
136 # This list is used by TestRunner.py to restrict running only tests that
137 # require one of the features in this list if this list is non-empty.
138 # Configurations can set this list to restrict the set of tests to run.
139 self.limit_to_features = set(limit_to_features)
140 # Whether the suite should be tested early in a given run.
141 self.is_early = bool(is_early)
143 def finish(self, litConfig):
144 """finish() - Finish this config object, after loading is complete."""
146 self.name = str(self.name)
147 self.suffixes = set(self.suffixes)
148 self.environment = dict(self.environment)
149 self.substitutions = list(self.substitutions)
150 if self.test_exec_root is not None:
151 # FIXME: This should really only be suite in test suite config
152 # files. Should we distinguish them?
153 self.test_exec_root = str(self.test_exec_root)
154 if self.test_source_root is not None:
155 # FIXME: This should really only be suite in test suite config
156 # files. Should we distinguish them?
157 self.test_source_root = str(self.test_source_root)
158 self.excludes = set(self.excludes)
162 """root attribute - The root configuration for the test suite."""
163 if self.parent is None:
166 return self.parent.root