test.mk 4.66 KB
Newer Older
1 2 3 4 5 6 7 8 9
# -----------------------------------------------------------------------------
# Examples of use:
#
# 	make		-- run all the tests in the current directory
# 	make verbose	-- as make test, but up the verbosity
# 	make accept	-- run the tests, accepting the current output
#
# The following variables may be set on the make command line:
#
10 11
#	TEST		-- specific test to run
#	TESTS		-- specific tests to run (same as $TEST really)
12 13 14
#	EXTRA_HC_OPTS	-- extra flags to send to the Haskell compiler
#	EXTRA_RUNTEST_OPTS -- extra flags to give the test driver
#	CONFIG		-- use a different configuration file
ross's avatar
ross committed
15
#	COMPILER	-- select a configuration file from config/
ei@vuokko.info's avatar
ei@vuokko.info committed
16
#       THREADS         -- run n tests at once
17 18 19
#
# -----------------------------------------------------------------------------

20 21
include $(TOP)/mk/wordsize.mk

22 23 24
$(TOP)/mk/wordsize.mk : $(TOP)/mk/wordsize.mk.in
	$(CPP) $(RAWCPP_FLAGS) -x c $(TOP)/mk/wordsize.mk.in > $(TOP)/mk/wordsize.mk

25 26 27 28
ifeq "$(PYTHON)" ""
$(error Python must be installed in order to use the testsuite)
endif

dons's avatar
dons committed
29 30 31
# export the value of $MAKE for invocation in ghc-regress/driver/
export MAKE

rrt's avatar
rrt committed
32
# ghastly hack, because the driver requires that $tool be an absolute path name.
33 34
HP2PS_ABS	= $(GHC_HP2PS_DIR_ABS)/hp2ps
GS = gs
35

36
RUNTESTS     = $(TOP)/driver/runtests.py
ross's avatar
ross committed
37
COMPILER     = ghc
38 39
CONFIGDIR    = $(TOP)/config
CONFIG       = $(CONFIGDIR)/$(COMPILER)
40

41
ifeq "$(NEWBUILD)" "YES"
42
# can be overriden from the command line
43
ifneq "$(stage)" ""
44 45 46 47 48 49 50
TEST_HC = $(GHC_STAGE$(stage)_ABS)
else
TEST_HC = $(GHC_STAGE2_ABS)
endif
GHC_PKG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_INPLACE)
else
ifneq "$(stage)" ""
51
TEST_HC = $(GHC_STAGE$(stage))
52
else
53
TEST_HC = $(GHC_STAGE2)
54
endif
Ian Lynagh's avatar
Ian Lynagh committed
55
GHC_PKG = $(GHC_PKG_INPLACE)
56
endif
57

58
RUNTEST_OPTS =
59

60
ifeq "$(GhcWithNativeCodeGen)" "YES"
61 62 63
RUNTEST_OPTS += -e ghc_with_native_codegen=1
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
64 65
endif

66
ifeq "$(filter p, $(GhcLibWays))" "p"
67 68 69
RUNTEST_OPTS += -e ghc_with_profiling=1
else
RUNTEST_OPTS += -e ghc_with_profiling=0
70
endif
71

72 73 74 75 76 77
ifeq "$(GhcWithInterpreter)" "YES"
RUNTEST_OPTS += -e ghc_with_interpreter=1
else
RUNTEST_OPTS += -e ghc_with_interpreter=0
endif

78 79 80 81 82 83
ifeq "$(GhcUnregisterised)" "YES"
RUNTEST_OPTS += -e ghc_unregisterised=1
else
RUNTEST_OPTS += -e ghc_unregisterised=0
endif

84 85 86 87 88 89
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif

90 91 92 93 94 95
ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1
else
RUNTEST_OPTS += -e ghc_with_smp=0
endif

ei@vuokko.info's avatar
ei@vuokko.info committed
96
ifneq "$(THREADS)" ""
97
RUNTEST_OPTS += --threads=$(THREADS)
ei@vuokko.info's avatar
ei@vuokko.info committed
98 99
endif

100
RUNTEST_OPTS +=  \
101
	--rootdir=. \
102
	--config=$(CONFIG) \
103
	-e config.confdir=\"$(CONFIGDIR)\" \
104
	-e config.compiler=\"$(TEST_HC)\" \
105
	-e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
106
	-e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
107
	-e config.ghc_pkg=\"$(GHC_PKG)\" \
108 109
	-e config.hp2ps=\"$(HP2PS_ABS)\" \
	-e config.gs=\"$(GS)\" \
110
	-e config.platform=\"$(TARGETPLATFORM)\" \
111
	-e config.os=\"$(TargetOS_CPP)\" \
112
	-e config.wordsize=\"$(WORDSIZE)\" \
113
	-e default_testopts.cleanup=\"$(CLEANUP)\" \
114
	-e config.timeout="int($(TIMEOUT)) or config.timeout" \
115
	-e config.timeout_prog=\"$(TIMEOUT_PROGRAM)\" \
Ian Lynagh's avatar
Ian Lynagh committed
116
	-e config.exeext=\"$(exeext)\" \
117
	-e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
118 119
	$(EXTRA_RUNTEST_OPTS)

120 121
# HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
# doesn't exist; they're always the same anyway
122

123 124 125 126 127 128 129 130 131 132 133 134
ifeq "$(fast)" "YES"
setfast = -e config.fast=1
else
setfast = 
endif

ifeq "$(accept)" "YES"
setaccept = -e config.accept=1
else
setaccept = 
endif

135
TESTS	     = 
136
TEST	     = 
137
WAY =
138 139 140

all :: test

141
ifeq "$(NEWBUILD)" "YES"
142

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
TIMEOUT_PROGRAM = $(FPTOOLS_TOP)/inplace/bin/timeout$(exeext)

$(TIMEOUT_PROGRAM) :
	@echo "Looks like you don't have timeout, building it first..."
	cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) inplace/bin/timeout$(exeext)

pwd : $(FPTOOLS_TOP)/utils/pwd$(exeext)

$(FPTOOLS_TOP)/utils/pwd$(exeext) :
	@echo "Looks like you don't have pwd, building utils first..."
	cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) utils/pwd$(exeext)

else

TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
158 159

$(TIMEOUT_PROGRAM) :
160 161 162
	@echo "Looks like you don't have timeout, building it first..."
	cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all

163 164
pwd : $(TOP)/utils/pwd$(exeext)

Simon Marlow's avatar
Simon Marlow committed
165
$(TOP)/utils/pwd$(exeext) :
166 167
	@echo "Looks like you don't have pwd, building utils first..."
	cd $(TOP)/utils && $(MAKE) $(MFLAGS) all
168
endif
169

170
test: $(TIMEOUT_PROGRAM) pwd
171
	$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
172
		$(patsubst %, --only=%, $(TEST)) \
173
		$(patsubst %, --only=%, $(TESTS)) \
174
		$(patsubst %, --way=%, $(WAY)) \
175
		$(patsubst %, --skipway=%, $(SKIPWAY)) \
176
		$(setfast) \
177
		$(setaccept)
178

179
verbose: test
180 181

accept:
182 183 184
	$(MAKE) accept=YES

fast:
185
	$(MAKE) fast=YES