llvm.org GIT mirror llvm / db5fe93
Teach 'make check-lit' to run unittests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81753 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
2 changed file(s) with 81 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7272 @echo "*** dejagnu not found. Make sure 'runtest' is in your PATH, then reconfigure LLVM."
7373 endif
7474
75 check-local-lit:: lit.site.cfg
75 check-local-lit:: lit.site.cfg Unit/lit.site.cfg
7676 ( $(ULIMIT) \
7777 $(LLVM_SRC_ROOT)/utils/lit/lit.py \
7878 --path "$(LLVMToolDir)" \
170170 @echo >> $@
171171 @echo "# Let the main config do the real work." >> $@
172172 @echo "lit.load_config(config, \"\"\"$(LLVM_SRC_ROOT)/test/lit.cfg\"\"\")" >> $@
173
174 Unit/lit.site.cfg: Unit/.dir FORCE
175 @echo "Making unittest 'lit.site.cfg' file..."
176 @echo "## Autogenerated by Makefile ##" > $@
177 @echo "# Do not edit!" >> $@
178 @echo >> $@
179 @echo "# Preserve some key paths for use by main LLVM test suite config." >> $@
180 @echo "config.llvm_obj_root = \"\"\"$(LLVM_OBJ_ROOT)\"\"\"" >> $@
181 @echo >> $@
182 @echo "# Remember the build mode." >> $@
183 @echo "config.llvm_build_mode = \"\"\"$(BuildMode)\"\"\"" >> $@
184 @echo >> $@
185 @echo "# Let the main config do the real work." >> $@
186 @echo "lit.load_config(config, \"\"\"$(LLVM_SRC_ROOT)/test/Unit/lit.cfg\"\"\")" >> $@
187
0 # -*- Python -*-
1
2 # Configuration file for the 'lit' test runner.
3
4 import os
5
6 # name: The name of this test suite.
7 config.name = 'LLVM-Unit'
8
9 # suffixes: A list of file extensions to treat as test files, this is actually
10 # set by on_clone().
11 config.suffixes = []
12
13 # test_source_root: The root path where tests are located.
14 # test_exec_root: The root path where tests should be run.
15 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
16 if llvm_obj_root is not None:
17 config.test_exec_root = os.path.join(llvm_obj_root, 'unittests')
18 config.test_source_root = config.test_exec_root
19
20 # testFormat: The test format to use to interpret tests.
21 llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
22 config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
23
24 ###
25
26 import os
27
28 # Check that the object root is known.
29 if config.test_exec_root is None:
30 # Otherwise, we haven't loaded the site specific configuration (the user is
31 # probably trying to run on a test file directly, and either the site
32 # configuration hasn't been created by the build system, or we are in an
33 # out-of-tree build situation).
34
35 # Try to detect the situation where we are using an out-of-tree build by
36 # looking for 'llvm-config'.
37 #
38 # FIXME: I debated (i.e., wrote and threw away) adding logic to
39 # automagically generate the lit.site.cfg if we are in some kind of fresh
40 # build situation. This means knowing how to invoke the build system
41 # though, and I decided it was too much magic.
42
43 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
44 if not llvm_config:
45 lit.fatal('No site specific configuration available!')
46
47 # Get the source and object roots.
48 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
49 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
50
51 # Validate that we got a tree which points to here.
52 this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
53 if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
54 lit.fatal('No site specific configuration available!')
55
56 # Check that the site specific configuration exists.
57 site_cfg = os.path.join(llvm_obj_root, 'test', 'Unit', 'lit.site.cfg')
58 if not os.path.exists(site_cfg):
59 lit.fatal('No site specific configuration available!')
60
61 # Okay, that worked. Notify the user of the automagic, and reconfigure.
62 lit.note('using out-of-tree build at %r' % llvm_obj_root)
63 lit.load_config(config, site_cfg)
64 raise SystemExit