test.mk 4.33 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 35 36 37 38
ifeq "$(Windows)" "YES"
GHC_STAGE1_ABS	= $(GHC_COMPILER_DIR_ABS)/stage1/ghc-inplace.bat
GHC_STAGE2_ABS	= $(GHC_COMPILER_DIR_ABS)/stage2/ghc-inplace.bat
GHC_STAGE3_ABS	= $(GHC_COMPILER_DIR_ABS)/stage3/ghc-inplace.bat
GHC_PKG_ABS     = $(GHC_PKG_DIR_ABS)/ghc-pkg-inplace.bat
else
39 40 41
GHC_STAGE1_ABS	= $(GHC_COMPILER_DIR_ABS)/stage1/ghc-inplace
GHC_STAGE2_ABS	= $(GHC_COMPILER_DIR_ABS)/stage2/ghc-inplace
GHC_STAGE3_ABS	= $(GHC_COMPILER_DIR_ABS)/stage3/ghc-inplace
42
GHC_PKG_ABS     = $(GHC_PKG_DIR_ABS)/ghc-pkg-inplace
43
endif
44 45
HP2PS_ABS	= $(GHC_HP2PS_DIR_ABS)/hp2ps
GS = gs
46

47
RUNTESTS     = $(TOP)/driver/runtests.py
ross's avatar
ross committed
48
COMPILER     = ghc
49 50
CONFIGDIR    = $(TOP)/config
CONFIG       = $(CONFIGDIR)/$(COMPILER)
51 52

# can be overriden from the command line
53 54 55 56 57
ifneq "$(stage)" ""
TEST_HC = $(GHC_STAGE$(stage)_ABS)
else
TEST_HC = $(GHC_STAGE1_ABS)
endif
58

59 60
GHC_PKG = $(GHC_PKG_ABS)

61
RUNTEST_OPTS =
62

63
ifeq "$(GhcWithNativeCodeGen)" "YES"
64 65 66
RUNTEST_OPTS += -e ghc_with_native_codegen=1
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
67 68
endif

69
ifeq "$(filter p, $(GhcLibWays))" "p"
70 71 72
RUNTEST_OPTS += -e ghc_with_profiling=1
else
RUNTEST_OPTS += -e ghc_with_profiling=0
73
endif
74

75 76 77 78 79 80
ifeq "$(filter u, $(GhcLibWays))" "u"
RUNTEST_OPTS += -e ghc_with_unreg=1
else
RUNTEST_OPTS += -e ghc_with_unreg=0
endif

81 82 83 84 85 86
ifeq "$(GhcWithInterpreter)" "YES"
RUNTEST_OPTS += -e ghc_with_interpreter=1
else
RUNTEST_OPTS += -e ghc_with_interpreter=0
endif

87 88 89 90 91 92
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif

93 94 95 96 97 98
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
99 100
ifneq "$(THREADS)" ""
RUNTEST_OPTS += --thread=$(THREADS)
101 102
else
USETHREADS=0
ei@vuokko.info's avatar
ei@vuokko.info committed
103 104
endif

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 114
	-e config.hp2ps=\"$(HP2PS_ABS)\" \
	-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 122
	$(EXTRA_RUNTEST_OPTS)

123 124
# HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
# doesn't exist; they're always the same anyway
125

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

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

138
TESTS	     = 
139
TEST	     = 
140
WAY =
141 142 143

all :: test

144 145 146 147 148 149 150
timeout : $(TOP)/timeout/timeout$(exeext)

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

test: timeout
151
	$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
152
		$(patsubst %, --only=%, $(TEST)) \
153
		$(patsubst %, --only=%, $(TESTS)) \
154
		$(patsubst %, --way=%, $(WAY)) \
155
		$(patsubst %, --skipway=%, $(SKIPWAY)) \
156
		$(setfast) \
157
		$(setaccept)
158

159
verbose: test
160 161

accept:
162 163 164
	$(MAKE) accept=YES

fast:
165
	$(MAKE) fast=YES MAKEFLAGS=
166