Roll r96559 forward again, adding libLLVM-2.7svn.so to LLVM. This links 3 of
[oota-llvm.git] / test / Makefile
1 #===- test/Makefile ----------------------------------------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===------------------------------------------------------------------------===#
9
10 LEVEL = ..
11 DIRS  =
12
13 #
14 # Make Dejagnu the default for testing
15 #
16 all:: check-local
17
18 # Include other test rules
19 include Makefile.tests
20
21 #===------------------------------------------------------------------------===#
22 # DejaGNU testing support
23 #===------------------------------------------------------------------------===#
24
25 ifneq ($(GREP_OPTIONS),)
26 $(warning GREP_OPTIONS environment variable may interfere with test results)
27 endif
28
29 ifdef VERBOSE
30 RUNTESTFLAGS := $(VERBOSE)
31 LIT_ARGS := -v
32 else
33 LIT_ARGS := -s -v
34 endif
35
36 ifdef TESTSUITE
37 LIT_TESTSUITE := $(TESTSUITE)
38 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
39 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
40 RUNTESTFLAGS += --tool $(CLEANED_TESTSUITE)
41 else
42 LIT_TESTSUITE := .
43 endif
44
45 ifdef VG
46 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full $(VALGRIND_EXTRA_ARGS)
47 endif
48
49 # Check what to run for -all.
50 LIT_ALL_TESTSUITES := $(LIT_TESTSUITE)
51
52 extra-lit-site-cfgs::
53 .PHONY: extra-lit-site-cfgs
54
55 ifneq ($(strip $(filter check-local-all,$(MAKECMDGOALS))),)
56 ifndef TESTSUITE
57 ifeq ($(shell test -d $(PROJ_SRC_DIR)/../tools/clang && echo OK), OK)
58 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/test
59
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
64 endif
65 endif
66 endif
67
68 IGNORE_TESTS :=
69
70 ifndef RUNLLVM2CPP
71 IGNORE_TESTS += llvm2cpp.exp
72 endif
73
74 ifdef IGNORE_TESTS
75 RUNTESTFLAGS += --ignore "$(strip $(IGNORE_TESTS))"
76 endif
77
78 # ulimits like these are redundantly enforced by the buildbots, so
79 # just removing them here won't work.
80 # Both AuroraUX & Solaris do not have the -m flag for ulimit
81 ifeq ($(HOST_OS),SunOS)
82 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
83 else # !SunOS
84 ifeq ($(HOST_OS),AuroraUX)
85 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
86 else # !AuroraUX
87 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 512000 ;
88 endif # AuroraUX
89 endif # SunOS
90
91 ifneq ($(RUNTEST),)
92 check-local:: site.exp
93         ( $(ULIMIT) \
94           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(LLVMGCCDIR)/bin:$(PATH)" \
95           $(RUNTEST) $(RUNTESTFLAGS) )
96 else
97 check-local:: site.exp
98         @echo "*** dejagnu not found.  Make sure 'runtest' is in your PATH, then reconfigure LLVM."
99 endif
100
101 check-local-lit:: lit.site.cfg Unit/lit.site.cfg
102         ( $(ULIMIT) \
103           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) )
104
105 check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-lit-site-cfgs
106         ( $(ULIMIT) \
107           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
108
109 ifdef TESTONE
110 CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE))
111 CLEANED_TESTONE := $(patsubst test/%,%,$(CLEANED_TESTONE))
112 SUBDIR := $(shell dirname $(CLEANED_TESTONE))
113 TESTPATH := $(LLVM_SRC_ROOT)/test/$(CLEANED_TESTONE)
114 check-one: site.exp $(TCLSH)
115         $(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/site.exp" ; \
116           echo "set subdir $(SUBDIR)" ; \
117           echo "proc pass  { msg } { puts \"PASS: \$$msg\" } "; \
118           echo "proc fail  { msg } { puts \"FAIL: \$$msg\" }" ; \
119           echo "proc xfail { msg } { puts \"XFAIL: \$$msg\" }" ; \
120           echo "proc xpass { msg } { puts \"XPASS: \$$msg\" }" ; \
121           echo "proc verbose args { }" ; \
122           echo "source $(LLVM_SRC_ROOT)/test/lib/llvm.exp" ; \
123           echo "RunLLVMTests $(TESTPATH)" ) | \
124         ( $(ULIMIT) \
125           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
126           $(TCLSH) )
127 endif
128
129 clean::
130         $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
131
132 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
133 ifeq ($(TARGET_OS),Darwin)
134 DSYMUTIL=dsymutil
135 else
136 DSYMUTIL=true
137 endif
138 ifdef TargetCommonOpts
139 BUGPOINT_TOPTS="-gcc-tool-args $(TargetCommonOpts)"
140 else
141 BUGPOINT_TOPTS=""
142 endif
143
144 ifneq ($(OCAMLOPT),)
145 CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
146 CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT))
147 endif
148
149 FORCE:
150
151 site.exp: FORCE
152         @echo 'Making a new site.exp file...'
153         @echo '## Autogenerated by LLVM configuration.' > site.tmp
154         @echo '# Do not edit!' >> site.tmp
155         @echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
156         @echo 'set TARGETS_TO_BUILD "$(TARGETS_TO_BUILD)"' >> site.tmp
157         @echo 'set llvmgcc_langs "$(LLVMGCC_LANGS)"' >> site.tmp
158         @echo 'set llvmtoolsdir "$(ToolDir)"' >>site.tmp
159         @echo 'set llvmlibsdir "$(LibDir)"' >>site.tmp
160         @echo 'set llvm_bindings "$(BINDINGS_TO_BUILD)"' >> site.tmp
161         @echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
162         @echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
163         @echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
164         @echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
165         @echo 'set gccpath "$(CC)"' >>site.tmp
166         @echo 'set gxxpath "$(CXX)"' >>site.tmp
167         @echo 'set compile_c "' $(CC) $(CPP.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >>site.tmp
168         @echo 'set compile_cxx "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >> site.tmp
169         @echo 'set link "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) '"' >>site.tmp
170         @echo 'set llvmgcc "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
171         @echo 'set llvmgxx "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
172         @echo 'set bugpoint_topts $(BUGPOINT_TOPTS)' >> site.tmp
173         @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp
174         @echo 'set ocamlopt "$(OCAMLOPT) -cc \"$(CXX_FOR_OCAMLOPT)\" -I $(LibDir)/ocaml"' >> site.tmp
175         @echo 'set valgrind "$(VALGRIND)"' >> site.tmp
176         @echo 'set grep "$(GREP)"' >>site.tmp
177         @echo 'set gas "$(GAS)"' >>site.tmp
178         @echo 'set llvmdsymutil "$(DSYMUTIL)"' >>site.tmp
179         @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
180         @test ! -f site.exp || \
181         sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
182         @-rm -f site.bak
183         @test ! -f site.exp || mv site.exp site.bak
184         @mv site.tmp site.exp
185
186 lit.site.cfg: site.exp
187         @echo "Making LLVM 'lit.site.cfg' file..."
188         @sed -e "s#@LLVM_SOURCE_DIR@#$(LLVM_SRC_ROOT)#g" \
189              -e "s#@LLVM_BINARY_DIR@#$(LLVM_OBJ_ROOT)#g" \
190              -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \
191              -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \
192              $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
193
194 Unit/lit.site.cfg: $(PROJ_OBJ_DIR)/Unit/.dir FORCE
195         @echo "Making LLVM unittest 'lit.site.cfg' file..."
196         @sed -e "s#@LLVM_SOURCE_DIR@#$(LLVM_SRC_ROOT)#g" \
197              -e "s#@LLVM_BINARY_DIR@#$(LLVM_OBJ_ROOT)#g" \
198              -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \
199              -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \
200              -e "s#@LLVM_BUILD_MODE@#$(BuildMode)#g" \
201              -e "s#@ENABLE_SHARED@#$(ENABLE_SHARED)#g" \
202              -e "s#@SHLIBPATH_VAR@#$(SHLIBPATH_VAR)#g" \
203              $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@