2016-08-25 20:36:15 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'Polly-Unit'
|
|
|
|
|
[Polly][CMake] Skip unit-tests in lit if gtest is not available
Summary:
There is a bug in the current lit configurations for the unittests. If gtest is not available, the site-config for the unit tests won't be generated. Because lit recurses through the test directory, the lit configuration for the unit tests will be discovered nevertheless, leading to a fatal error in lit.
This patch semi-gracefully skips the unittests if gtest is not available. As a result, running lit now prints this: `warning: test suite 'Polly-Unit' contained no test`.
If people think that this is too annoying, the alternative would be to pick apart the test directory, so that the lit testsuite discovery will always only find one configuration. In fact, both of these things could be combined. While it's certainly nice that running a single lit command runs all the tests, I suppose people use the `check-polly` make target over lit most of the time, so the difference might not be noticed.
Reviewers: Meinersbur, grosser
Reviewed By: grosser
Subscribers: mgorny, bollu, pollydev, llvm-commits
Tags: #polly
Differential Revision: https://reviews.llvm.org/D34053
llvm-svn: 307651
2017-07-11 19:37:35 +08:00
|
|
|
if not config.has_unittests:
|
|
|
|
raise SystemExit
|
|
|
|
|
2016-08-25 20:36:15 +08:00
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
|
|
|
config.suffixes = []
|
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
# test_exec_root: The root path where tests should be run.
|
2017-09-16 06:10:46 +08:00
|
|
|
config.test_exec_root = os.path.join(config.polly_obj_root, 'unittests')
|
|
|
|
config.test_source_root = config.test_exec_root
|
2016-08-25 20:36:15 +08:00
|
|
|
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
2017-09-16 06:10:46 +08:00
|
|
|
config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
|
2016-08-25 20:36:15 +08:00
|
|
|
|
|
|
|
# Propagate the temp directory. Windows requires this because it uses \Windows\
|
|
|
|
# if none of these are present.
|
|
|
|
if 'TMP' in os.environ:
|
|
|
|
config.environment['TMP'] = os.environ['TMP']
|
|
|
|
if 'TEMP' in os.environ:
|
|
|
|
config.environment['TEMP'] = os.environ['TEMP']
|
|
|
|
|
|
|
|
# Propagate path to symbolizer for ASan/MSan.
|
|
|
|
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
|
|
|
|
if symbolizer in os.environ:
|
|
|
|
config.environment[symbolizer] = os.environ[symbolizer]
|
|
|
|
|
|
|
|
shlibpath_var = ''
|
|
|
|
if platform.system() == 'Linux':
|
|
|
|
shlibpath_var = 'LD_LIBRARY_PATH'
|
|
|
|
elif platform.system() == 'Darwin':
|
|
|
|
shlibpath_var = 'DYLD_LIBRARY_PATH'
|
|
|
|
elif platform.system() == 'Windows':
|
|
|
|
shlibpath_var = 'PATH'
|
|
|
|
|
|
|
|
# Point the dynamic loader at dynamic libraries in 'lib'.
|
2017-09-16 06:10:46 +08:00
|
|
|
shlibpath = os.path.pathsep.join((config.llvm_libs_dir,
|
2016-08-25 20:36:15 +08:00
|
|
|
config.environment.get(shlibpath_var,'')))
|
|
|
|
|
|
|
|
# Win32 seeks DLLs along %PATH%.
|
|
|
|
if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
|
|
|
|
shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
|
|
|
|
|
|
|
|
config.environment[shlibpath_var] = shlibpath
|