3 # Configuration file for the 'lit' test runner.
11 # name: The name of this test suite.
12 config.name = 'Polly-Unit'
14 if not config.has_unittests:
17 # suffixes: A list of file extensions to treat as test files.
20 # test_source_root: The root path where tests are located.
21 # test_exec_root: The root path where tests should be run.
22 polly_obj_root = getattr(config, 'polly_obj_root', None)
23 if polly_obj_root is not None:
24 config.test_exec_root = os.path.join(polly_obj_root, 'unittests')
25 config.test_source_root = config.test_exec_root
27 # testFormat: The test format to use to interpret tests.
28 llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
29 config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
31 # Propagate the temp directory. Windows requires this because it uses \Windows\
32 # if none of these are present.
33 if 'TMP' in os.environ:
34 config.environment['TMP'] = os.environ['TMP']
35 if 'TEMP' in os.environ:
36 config.environment['TEMP'] = os.environ['TEMP']
38 # Propagate path to symbolizer for ASan/MSan.
39 for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
40 if symbolizer in os.environ:
41 config.environment[symbolizer] = os.environ[symbolizer]
45 # Check that the object root is known.
46 if config.test_exec_root is None:
47 # Otherwise, we haven't loaded the site specific configuration (the user is
48 # probably trying to run on a test file directly, and either the site
49 # configuration hasn't been created by the build system, or we are in an
50 # out-of-tree build situation).
52 # Check for 'polly_unit_site_config' user parameter, and use that if available.
53 site_cfg = lit_config.params.get('polly_unit_site_config', None)
54 if site_cfg and os.path.exists(site_cfg):
55 lit_config.load_config(config, site_cfg)
58 # Try to detect the situation where we are using an out-of-tree build by
59 # looking for 'llvm-config'.
61 # FIXME: I debated (i.e., wrote and threw away) adding logic to
62 # automagically generate the lit.site.cfg if we are in some kind of fresh
63 # build situation. This means knowing how to invoke the build system
64 # though, and I decided it was too much magic.
66 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
68 lit_config.fatal('No site specific configuration available!')
70 # Get the source and object roots.
71 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
72 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
73 polly_src_root = os.path.join(llvm_src_root, "tools", "polly")
74 polly_obj_root = os.path.join(llvm_obj_root, "tools", "polly")
76 # Validate that we got a tree which points to here, using the standard
78 this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
79 if os.path.realpath(polly_src_root) != os.path.realpath(this_src_root):
80 lit_config.fatal('No site specific configuration available!')
82 # Check that the site specific configuration exists.
83 site_cfg = os.path.join(polly_obj_root, 'test', 'Unit', 'lit.site.cfg')
84 if not os.path.exists(site_cfg):
85 lit_config.fatal('No site specific configuration available!')
87 # Okay, that worked. Notify the user of the automagic, and reconfigure.
88 lit_config.note('using out-of-tree build at %r' % polly_obj_root)
89 lit_config.load_config(config, site_cfg)
93 if platform.system() == 'Linux':
94 shlibpath_var = 'LD_LIBRARY_PATH'
95 elif platform.system() == 'Darwin':
96 shlibpath_var = 'DYLD_LIBRARY_PATH'
97 elif platform.system() == 'Windows':
98 shlibpath_var = 'PATH'
100 # Point the dynamic loader at dynamic libraries in 'lib'.
101 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
102 if not llvm_libs_dir:
103 lit_config.fatal('No LLVM libs dir set!')
104 shlibpath = os.path.pathsep.join((llvm_libs_dir,
105 config.environment.get(shlibpath_var,'')))
107 # Win32 seeks DLLs along %PATH%.
108 if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
109 shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
111 config.environment[shlibpath_var] = shlibpath