Tweak settings for LLVM tests
[ghc.git] / testsuite / mk / test.mk
1 # -----------------------------------------------------------------------------
2 # Examples of use:
3 #
4 # make -- run all the tests in the current directory
5 # make verbose -- as make test, but up the verbosity
6 # make accept -- run the tests, accepting the current output
7 #
8 # The following variables may be set on the make command line:
9 #
10 # TEST -- specific test to run
11 # TESTS -- specific tests to run (same as $TEST really)
12 # EXTRA_HC_OPTS -- extra flags to send to the Haskell compiler
13 # EXTRA_RUNTEST_OPTS -- extra flags to give the test driver
14 # CONFIG -- use a different configuration file
15 # COMPILER -- select a configuration file from config/
16 # THREADS -- run n tests at once
17 #
18 # -----------------------------------------------------------------------------
19
20 # export the value of $MAKE for invocation in tests/driver/
21 export MAKE
22
23 RUNTESTS = $(TOP)/driver/runtests.py
24 COMPILER = ghc
25 CONFIGDIR = $(TOP)/config
26 CONFIG = $(CONFIGDIR)/$(COMPILER)
27
28 ifeq "$(GhcUnregisterised)" "YES"
29 # Otherwise C backend generates many warnings about
30 # imcompatible proto casts for GCC's buitins:
31 # memcpy, printf, strlen.
32 EXTRA_HC_OPTS += -optc-fno-builtin
33 endif
34
35 # TEST_HC_OPTS is passed to every invocation of TEST_HC
36 # in nested Makefiles
37 TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)
38
39 # The warning suppression flag below is a temporary kludge. While working with
40 # tests that contain tabs, please de-tab them so this flag can be eventually
41 # removed. See
42 # http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
43 # for details
44 #
45 TEST_HC_OPTS += -fno-warn-tabs
46
47 ifeq "$(MinGhcVersion711)" "YES"
48 # Don't warn about missing specialisations. They can only occur with `-O`, but
49 # we want tests to produce the same output for all test ways.
50 TEST_HC_OPTS += -fno-warn-missed-specialisations
51 endif
52
53 RUNTEST_OPTS =
54
55 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
56 exeext =
57 else
58 exeext = .exe
59 endif
60
61 ifneq "$(filter $(TargetOS_CPP),cygwin32 mingw32)" ""
62 dllext = .dll
63 else ifeq "$(TargetOS_CPP)" "darwin"
64 dllext = .dylib
65 else
66 dllext = .so
67 endif
68
69 RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"
70
71 RUNTEST_OPTS += -e ghc_debugged=$(GhcDebugged)
72
73 ifeq "$(GhcWithNativeCodeGen)" "YES"
74 RUNTEST_OPTS += -e ghc_with_native_codegen=1
75 else
76 RUNTEST_OPTS += -e ghc_with_native_codegen=0
77 endif
78
79 GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output))
80 HAVE_VANILLA := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.hi ]; then echo YES; else echo NO; fi)
81 HAVE_DYNAMIC := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.dyn_hi ]; then echo YES; else echo NO; fi)
82 HAVE_PROFILING := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.p_hi ]; then echo YES; else echo NO; fi)
83
84 ifeq "$(HAVE_VANILLA)" "YES"
85 RUNTEST_OPTS += -e ghc_with_vanilla=1
86 else
87 RUNTEST_OPTS += -e ghc_with_vanilla=0
88 endif
89
90 ifeq "$(HAVE_DYNAMIC)" "YES"
91 RUNTEST_OPTS += -e ghc_with_dynamic=1
92 else
93 RUNTEST_OPTS += -e ghc_with_dynamic=0
94 endif
95
96 ifeq "$(HAVE_PROFILING)" "YES"
97 RUNTEST_OPTS += -e ghc_with_profiling=1
98 else
99 RUNTEST_OPTS += -e ghc_with_profiling=0
100 endif
101
102 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
103 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
104 else
105 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
106 endif
107
108 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
109 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
110 else
111 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
112 endif
113
114 ifeq "$(GhcWithInterpreter)" "NO"
115 RUNTEST_OPTS += -e ghc_with_interpreter=0
116 else ifeq "$(GhcStage)" "1"
117 RUNTEST_OPTS += -e ghc_with_interpreter=0
118 else
119 RUNTEST_OPTS += -e ghc_with_interpreter=1
120 endif
121
122 ifeq "$(GhcUnregisterised)" "YES"
123 RUNTEST_OPTS += -e ghc_unregisterised=1
124 else
125 RUNTEST_OPTS += -e ghc_unregisterised=0
126 endif
127
128 ifeq "$(GhcDynamicByDefault)" "YES"
129 RUNTEST_OPTS += -e ghc_dynamic_by_default=True
130 CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla
131 else
132 RUNTEST_OPTS += -e ghc_dynamic_by_default=False
133 CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared
134 endif
135
136 ifeq "$(GhcDynamic)" "YES"
137 RUNTEST_OPTS += -e ghc_dynamic=True
138 CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla
139 else
140 RUNTEST_OPTS += -e ghc_dynamic=False
141 CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared
142 endif
143
144 ifeq "$(GhcWithSMP)" "YES"
145 RUNTEST_OPTS += -e ghc_with_smp=1
146 else
147 RUNTEST_OPTS += -e ghc_with_smp=0
148 endif
149
150 ifeq "$(LLC)" ""
151 RUNTEST_OPTS += -e ghc_with_llvm=0
152 else ifeq "$(TargetARCH_CPP)" "powerpc"
153 RUNTEST_OPTS += -e ghc_with_llvm=0
154 else ifneq "$(LLC)" "llc"
155 # If we have a real detected value for LLVM, then it really ought to work
156 RUNTEST_OPTS += -e ghc_with_llvm=1
157 else
158 RUNTEST_OPTS += -e ghc_with_llvm=0
159 endif
160
161 ifeq "$(WINDOWS)" "YES"
162 RUNTEST_OPTS += -e windows=True
163 else
164 RUNTEST_OPTS += -e windows=False
165 endif
166
167 ifeq "$(DARWIN)" "YES"
168 RUNTEST_OPTS += -e darwin=True
169 else
170 RUNTEST_OPTS += -e darwin=False
171 endif
172
173 ifeq "$(IN_TREE_COMPILER)" "YES"
174 RUNTEST_OPTS += -e in_tree_compiler=True
175 else
176 RUNTEST_OPTS += -e in_tree_compiler=False
177 endif
178
179 ifneq "$(THREADS)" ""
180 RUNTEST_OPTS += --threads=$(THREADS)
181 endif
182
183 ifneq "$(VERBOSE)" ""
184 RUNTEST_OPTS += --verbose=$(VERBOSE)
185 endif
186
187 ifeq "$(SKIP_PERF_TESTS)" "YES"
188 RUNTEST_OPTS += --skip-perf-tests
189 endif
190
191 ifneq "$(CLEAN_ONLY)" ""
192 RUNTEST_OPTS += -e clean_only=True
193 else
194 RUNTEST_OPTS += -e clean_only=False
195 endif
196
197 ifneq "$(CHECK_FILES_WRITTEN)" ""
198 RUNTEST_OPTS += --check-files-written
199 endif
200
201 RUNTEST_OPTS += \
202 --rootdir=. \
203 --configfile=$(CONFIG) \
204 -e 'config.confdir="$(CONFIGDIR)"' \
205 -e 'config.platform="$(TARGETPLATFORM)"' \
206 -e 'config.os="$(TargetOS_CPP)"' \
207 -e 'config.arch="$(TargetARCH_CPP)"' \
208 -e 'config.wordsize="$(WORDSIZE)"' \
209 -e 'default_testopts.cleanup="$(CLEANUP)"' \
210 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
211 -e 'config.exeext="$(exeext)"' \
212 -e 'config.top="$(TOP_ABS)"'
213
214 # Wrap non-empty program paths in quotes, because they may contain spaces. Do
215 # it here, so we don't have to (and don't forget to do it) in the .T test
216 # scripts (search for '{compiler}' or '{hpc}'). This may or may not be a good
217 # idea.
218 # Use `--config` instead of `-e`, because `-e` (which calls Python's `eval`
219 # function) would require another pair of (escaped) quotes, which interfers
220 # with MinGW's magic path handling (see #10449, and
221 # http://www.mingw.org/wiki/Posix_path_conversion).
222 # We use double instead of single quotes, which may or may not be important
223 # when using msys2 (#9626, #10441).
224 quote_path = $(if $1,"$1")
225 RUNTEST_OPTS += \
226 --config 'compiler=$(call quote_path,$(TEST_HC))' \
227 --config 'ghc_pkg=$(call quote_path,$(GHC_PKG))' \
228 --config 'haddock=$(call quote_path,$(HADDOCK))' \
229 --config 'hp2ps=$(call quote_path,$(HP2PS_ABS))' \
230 --config 'hpc=$(call quote_path,$(HPC))' \
231 --config 'gs=$(call quote_path,$(GS))' \
232 --config 'timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))'
233
234 ifneq "$(SUMMARY_FILE)" ""
235 RUNTEST_OPTS += \
236 --summary-file "$(SUMMARY_FILE)"
237 endif
238 ifeq "$(NO_PRINT_SUMMARY)" "YES"
239 RUNTEST_OPTS += \
240 --no-print-summary 1
241 endif
242
243 RUNTEST_OPTS += \
244 $(EXTRA_RUNTEST_OPTS)
245
246 ifeq "$(list_broken)" "YES"
247 set_list_broken = -e config.list_broken=True
248 else
249 set_list_broken =
250 endif
251
252 # See Note [validate and testsuite speed] in toplevel Makefile.
253 ifneq "$(SPEED)" ""
254 setspeed = -e config.speed="$(SPEED)"
255 else ifeq "$(fast)" "YES"
256 # Backward compatibility. Maybe some people are running 'make accept fast=YES'?
257 setspeed = -e config.speed=2
258 else
259 setspeed =
260 endif
261
262 ifeq "$(accept)" "YES"
263 setaccept = -e config.accept=1
264 else
265 setaccept =
266 endif
267
268 .PHONY: all boot test verbose accept fast slow list_broken
269
270 all: test
271
272 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
273
274 boot: $(TIMEOUT_PROGRAM)
275
276 $(TIMEOUT_PROGRAM) :
277 @echo "Looks like you don't have timeout, building it first..."
278 $(MAKE) -C $(TOP)/timeout all
279
280 test: $(TIMEOUT_PROGRAM)
281 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
282 $(patsubst %, --only=%, $(TEST)) \
283 $(patsubst %, --only=%, $(TESTS)) \
284 $(patsubst %, --way=%, $(WAY)) \
285 $(patsubst %, --skipway=%, $(SKIPWAY)) \
286 $(set_list_broken) \
287 $(setspeed) \
288 $(setaccept)
289
290 verbose: test
291
292 accept:
293 $(MAKE) accept=YES
294
295 fast:
296 # See Note [validate and testsuite speed] in toplevel Makefile.
297 $(MAKE) SPEED=2
298
299 slow:
300 $(MAKE) SPEED=0
301
302 list_broken:
303 $(MAKE) list_broken=YES
304