Pass --threads rather than --thread
[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 include $(TOP)/mk/wordsize.mk
21
22 $(TOP)/mk/wordsize.mk : $(TOP)/mk/wordsize.mk.in
23 $(CPP) $(RAWCPP_FLAGS) -x c $(TOP)/mk/wordsize.mk.in > $(TOP)/mk/wordsize.mk
24
25 ifeq "$(PYTHON)" ""
26 $(error Python must be installed in order to use the testsuite)
27 endif
28
29 # export the value of $MAKE for invocation in ghc-regress/driver/
30 export MAKE
31
32 # ghastly hack, because the driver requires that $tool be an absolute path name.
33 GHC_STAGE1_ABS = $(GHC_COMPILER_DIR_ABS)/stage1/ghc-inplace
34 GHC_STAGE2_ABS = $(GHC_COMPILER_DIR_ABS)/stage2/ghc-inplace
35 GHC_STAGE3_ABS = $(GHC_COMPILER_DIR_ABS)/stage3/ghc-inplace
36 GHC_PKG_ABS = $(GHC_PKG_DIR_ABS)/ghc-pkg-inplace
37 HP2PS_ABS = $(GHC_HP2PS_DIR_ABS)/hp2ps
38 GS = gs
39
40 RUNTESTS = $(TOP)/driver/runtests.py
41 COMPILER = ghc
42 CONFIGDIR = $(TOP)/config
43 CONFIG = $(CONFIGDIR)/$(COMPILER)
44
45 # can be overriden from the command line
46 ifneq "$(stage)" ""
47 TEST_HC = $(GHC_STAGE$(stage)_ABS)
48 else
49 TEST_HC = $(GHC_STAGE2_ABS)
50 endif
51
52 GHC_PKG = $(GHC_PKG_ABS)
53
54 RUNTEST_OPTS =
55
56 ifeq "$(GhcWithNativeCodeGen)" "YES"
57 RUNTEST_OPTS += -e ghc_with_native_codegen=1
58 else
59 RUNTEST_OPTS += -e ghc_with_native_codegen=0
60 endif
61
62 ifeq "$(filter p, $(GhcLibWays))" "p"
63 RUNTEST_OPTS += -e ghc_with_profiling=1
64 else
65 RUNTEST_OPTS += -e ghc_with_profiling=0
66 endif
67
68 ifeq "$(GhcWithInterpreter)" "YES"
69 RUNTEST_OPTS += -e ghc_with_interpreter=1
70 else
71 RUNTEST_OPTS += -e ghc_with_interpreter=0
72 endif
73
74 ifeq "$(GhcUnregisterised)" "YES"
75 RUNTEST_OPTS += -e ghc_unregisterised=1
76 else
77 RUNTEST_OPTS += -e ghc_unregisterised=0
78 endif
79
80 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
81 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
82 else
83 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
84 endif
85
86 ifeq "$(GhcWithSMP)" "YES"
87 RUNTEST_OPTS += -e ghc_with_smp=1
88 else
89 RUNTEST_OPTS += -e ghc_with_smp=0
90 endif
91
92 ifneq "$(THREADS)" ""
93 RUNTEST_OPTS += --threads=$(THREADS)
94 else
95 USETHREADS=0
96 endif
97
98 RUNTEST_OPTS += \
99 --rootdir=. \
100 --config=$(CONFIG) \
101 -e config.confdir=\"$(CONFIGDIR)\" \
102 -e config.compiler=\"$(TEST_HC)\" \
103 -e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
104 -e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
105 -e config.ghc_pkg=\"$(GHC_PKG)\" \
106 -e config.hp2ps=\"$(HP2PS_ABS)\" \
107 -e config.gs=\"$(GS)\" \
108 -e config.platform=\"$(TARGETPLATFORM)\" \
109 -e config.os=\"$(TargetOS_CPP)\" \
110 -e config.wordsize=\"$(WORDSIZE)\" \
111 -e default_testopts.cleanup=\"$(CLEANUP)\" \
112 -e "if '$(USETHREADS)': config.use_threads=int($(USETHREADS))" \
113 -e config.timeout="int($(TIMEOUT)) or config.timeout" \
114 -e config.timeout_prog=\"$(TOP)/timeout/timeout\" \
115 -e config.exeext=\"$(exeext)\" \
116 -e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
117 $(EXTRA_RUNTEST_OPTS)
118
119 # HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
120 # doesn't exist; they're always the same anyway
121
122 ifeq "$(fast)" "YES"
123 setfast = -e config.fast=1
124 else
125 setfast =
126 endif
127
128 ifeq "$(accept)" "YES"
129 setaccept = -e config.accept=1
130 else
131 setaccept =
132 endif
133
134 TESTS =
135 TEST =
136 WAY =
137
138 all :: test
139
140 timeout : $(TOP)/timeout/timeout$(exeext)
141
142 $(TOP)/timeout/timeout$(exeext) :
143 @echo "Looks like you don't have timeout, building it first..."
144 cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
145
146 pwd : $(TOP)/utils/pwd$(exeext)
147
148 $(TOP)/utils/pwd$(exeext) :
149 @echo "Looks like you don't have pwd, building utils first..."
150 cd $(TOP)/utils && $(MAKE) $(MFLAGS) all
151
152 test: timeout pwd
153 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
154 $(patsubst %, --only=%, $(TEST)) \
155 $(patsubst %, --only=%, $(TESTS)) \
156 $(patsubst %, --way=%, $(WAY)) \
157 $(patsubst %, --skipway=%, $(SKIPWAY)) \
158 $(setfast) \
159 $(setaccept)
160
161 verbose: test
162
163 accept:
164 $(MAKE) accept=YES
165
166 fast:
167 $(MAKE) fast=YES
168