1 #===- test/Makefile ----------------------------------------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
14 # Make Dejagnu the default for testing
18 # Include other test rules
19 include Makefile.tests
21 #===------------------------------------------------------------------------===#
22 # DejaGNU testing support
23 #===------------------------------------------------------------------------===#
25 ifneq ($(GREP_OPTIONS),)
26 $(warning GREP_OPTIONS environment variable may interfere with test results)
30 RUNTESTFLAGS := $(VERBOSE)
37 LIT_TESTSUITE := $(TESTSUITE)
38 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
39 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
40 RUNTESTFLAGS += --tool $(CLEANED_TESTSUITE)
46 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full $(VALGRIND_EXTRA_ARGS)
49 # Check what to run for -all.
50 LIT_ALL_TESTSUITES := $(LIT_TESTSUITE)
53 .PHONY: extra-lit-site-cfgs
55 ifneq ($(strip $(filter check-local-all,$(MAKECMDGOALS))),)
57 ifeq ($(shell test -d $(PROJ_SRC_DIR)/../tools/clang && echo OK), OK)
58 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/test
60 # Force creation of Clang's lit.site.cfg.
61 clang-lit-site-cfg: FORCE
62 $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/test lit.site.cfg
63 extra-lit-site-cfgs:: clang-lit-site-cfg
71 IGNORE_TESTS += llvm2cpp.exp
75 RUNTESTFLAGS += --ignore "$(strip $(IGNORE_TESTS))"
78 # Both AuroraUX & Solaris do not have the -m flag for ulimit
79 ifeq ($(HOST_OS),SunOS)
80 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
82 ifeq ($(HOST_OS),AuroraUX)
83 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
85 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 512000 ;
90 check-local:: site.exp
92 PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(LLVMGCCDIR)/bin:$(PATH)" \
93 $(RUNTEST) $(RUNTESTFLAGS) )
95 check-local:: site.exp
96 @echo "*** dejagnu not found. Make sure 'runtest' is in your PATH, then reconfigure LLVM."
99 check-local-lit:: lit.site.cfg Unit/lit.site.cfg
101 $(LLVM_SRC_ROOT)/utils/lit/lit.py \
102 --path "$(LLVMToolDir)" \
103 --path "$(LLVM_SRC_ROOT)/test/Scripts" \
104 --path "$(LLVMGCCDIR)/bin" \
105 $(LIT_ARGS) $(LIT_TESTSUITE) )
107 check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-lit-site-cfgs
109 $(LLVM_SRC_ROOT)/utils/lit/lit.py \
110 --path "$(LLVMToolDir)" \
111 --path "$(LLVM_SRC_ROOT)/test/Scripts" \
112 --path "$(LLVMGCCDIR)/bin" \
113 $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
116 CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE))
117 CLEANED_TESTONE := $(patsubst test/%,%,$(CLEANED_TESTONE))
118 SUBDIR := $(shell dirname $(CLEANED_TESTONE))
119 TESTPATH := $(LLVM_SRC_ROOT)/test/$(CLEANED_TESTONE)
120 check-one: site.exp $(TCLSH)
121 $(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/site.exp" ; \
122 echo "set subdir $(SUBDIR)" ; \
123 echo "proc pass { msg } { puts \"PASS: \$$msg\" } "; \
124 echo "proc fail { msg } { puts \"FAIL: \$$msg\" }" ; \
125 echo "proc xfail { msg } { puts \"XFAIL: \$$msg\" }" ; \
126 echo "proc xpass { msg } { puts \"XPASS: \$$msg\" }" ; \
127 echo "proc verbose args { }" ; \
128 echo "source $(LLVM_SRC_ROOT)/test/lib/llvm.exp" ; \
129 echo "RunLLVMTests $(TESTPATH)" ) | \
131 PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
136 $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
138 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
139 ifeq ($(TARGET_OS),Darwin)
144 ifdef TargetCommonOpts
145 BUGPOINT_TOPTS="-gcc-tool-args $(TargetCommonOpts)"
151 CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
152 CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT))
158 @echo 'Making a new site.exp file...'
159 @echo '## these variables are automatically generated by make ##' >site.tmp
160 @echo '# Do not edit here. If you wish to override these values' >>site.tmp
161 @echo '# edit the last section' >>site.tmp
162 @echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
163 @echo 'set TARGETS_TO_BUILD "$(TARGETS_TO_BUILD)"' >> site.tmp
164 @echo 'set llvmgcc_langs "$(LLVMGCC_LANGS)"' >> site.tmp
165 @echo 'set llvmgcc_version "$(LLVMGCC_VERSION)"' >> site.tmp
166 @echo 'set llvmtoolsdir "$(ToolDir)"' >>site.tmp
167 @echo 'set llvmlibsdir "$(LibDir)"' >>site.tmp
168 @echo 'set llvm_bindings "$(BINDINGS_TO_BUILD)"' >> site.tmp
169 @echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
170 @echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
171 @echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
172 @echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
173 @echo 'set gccpath "$(CC)"' >>site.tmp
174 @echo 'set gxxpath "$(CXX)"' >>site.tmp
175 @echo 'set compile_c "' $(CC) $(CPP.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >>site.tmp
176 @echo 'set compile_cxx "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >> site.tmp
177 @echo 'set link "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) '"' >>site.tmp
178 @echo 'set llvmgcc "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
179 @echo 'set llvmgxx "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
180 @echo 'set llvmgccmajvers "$(LLVMGCC_MAJVERS)"' >> site.tmp
181 @echo 'set bugpoint_topts $(BUGPOINT_TOPTS)' >> site.tmp
182 @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp
183 @echo 'set ocamlopt "$(OCAMLOPT) -cc \"$(CXX_FOR_OCAMLOPT)\" -I $(LibDir)/ocaml"' >> site.tmp
184 @echo 'set valgrind "$(VALGRIND)"' >> site.tmp
185 @echo 'set grep "$(GREP)"' >>site.tmp
186 @echo 'set gas "$(GAS)"' >>site.tmp
187 @echo 'set llvmdsymutil "$(DSYMUTIL)"' >>site.tmp
188 @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
189 @test ! -f site.exp || \
190 sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
192 @test ! -f site.exp || mv site.exp site.bak
193 @mv site.tmp site.exp
195 lit.site.cfg: site.exp
196 @echo "Making LLVM 'lit.site.cfg' file..."
197 @sed -e "s#@LLVM_SOURCE_DIR@#$(LLVM_SRC_ROOT)#g" \
198 -e "s#@LLVM_BINARY_DIR@#$(LLVM_OBJ_ROOT)#g" \
199 -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \
200 -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \
201 $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
203 Unit/lit.site.cfg: $(PROJ_OBJ_DIR)/Unit/.dir FORCE
204 @echo "Making LLVM unittest 'lit.site.cfg' file..."
205 @echo "## Autogenerated by Makefile ##" > $@
206 @echo "# Do not edit!" >> $@
208 @echo "# Preserve some key paths for use by main LLVM test suite config." >> $@
209 @echo "config.llvm_obj_root = \"\"\"$(LLVM_OBJ_ROOT)\"\"\"" >> $@
211 @echo "# Remember the build mode." >> $@
212 @echo "config.llvm_build_mode = \"\"\"$(BuildMode)\"\"\"" >> $@
214 @echo "# Let the main config do the real work." >> $@
215 @echo "lit.load_config(config, \"\"\"$(LLVM_SRC_ROOT)/test/Unit/lit.cfg\"\"\")" >> $@