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