test.mk 4.91 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
#
# -----------------------------------------------------------------------------

dons's avatar
dons committed
20 21 22
# export the value of $MAKE for invocation in ghc-regress/driver/
export MAKE

23
RUNTESTS     = $(TOP)/driver/runtests.py
ross's avatar
ross committed
24
COMPILER     = ghc
25 26
CONFIGDIR    = $(TOP)/config
CONFIG       = $(CONFIGDIR)/$(COMPILER)
27

28 29 30 31
# TEST_HC_OPTS is passed to every invocation of TEST_HC 
# in nested Makefiles
TEST_HC_OPTS = -dno-debug-output $(EXTRA_HC_OPTS)

32 33 34 35 36
RUNTEST_OPTS =

$(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
$(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
$(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
37
$(eval $(call get-ghc-rts-field,TargetARCH_CPP,Target architecture))
38 39
ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
exeext =
40
else
41
exeext = .exe
42
endif
43

44
$(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
45
ifeq "$(GhcWithNativeCodeGen)" "YES"
46 47 48
RUNTEST_OPTS += -e ghc_with_native_codegen=1
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
49 50
endif

51 52
HASKELL98_LIBDIR := $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')
HAVE_PROFILING := $(shell if [ -f $(HASKELL98_LIBDIR)/libHShaskell98-*_p.a ]; then echo YES; else echo NO; fi)
53 54

ifeq "$(HAVE_PROFILING)" "YES"
55 56 57
RUNTEST_OPTS += -e ghc_with_profiling=1
else
RUNTEST_OPTS += -e ghc_with_profiling=0
58
endif
59

60 61 62 63 64 65
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif

66 67 68 69 70 71
ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
else
RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
endif

72
$(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
73 74 75 76 77 78
ifeq "$(GhcWithInterpreter)" "YES"
RUNTEST_OPTS += -e ghc_with_interpreter=1
else
RUNTEST_OPTS += -e ghc_with_interpreter=0
endif

79
$(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
80 81 82 83 84 85
ifeq "$(GhcUnregisterised)" "YES"
RUNTEST_OPTS += -e ghc_unregisterised=1
else
RUNTEST_OPTS += -e ghc_unregisterised=0
endif

86
$(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
87 88 89 90 91 92
ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1
else
RUNTEST_OPTS += -e ghc_with_smp=0
endif

93
ifneq "$(shell $(SHELL) -c 'llvmc --version | grep version' 2> /dev/null)" ""
94 95 96 97 98
RUNTEST_OPTS += -e ghc_with_llvm=1
else
RUNTEST_OPTS += -e ghc_with_llvm=0
endif

Ian Lynagh's avatar
Ian Lynagh committed
99 100 101 102 103 104
ifeq "$(WINDOWS)" "YES"
RUNTEST_OPTS += -e windows=True
else
RUNTEST_OPTS += -e windows=False
endif

Ian Lynagh's avatar
Ian Lynagh committed
105 106 107 108 109 110
ifeq "$(DARWIN)" "YES"
RUNTEST_OPTS += -e darwin=True
else
RUNTEST_OPTS += -e darwin=False
endif

111 112 113 114 115 116
ifeq "$(IN_TREE_COMPILER)" "YES"
RUNTEST_OPTS += -e in_tree_compiler=True
else
RUNTEST_OPTS += -e in_tree_compiler=False
endif

ei@vuokko.info's avatar
ei@vuokko.info committed
117
ifneq "$(THREADS)" ""
118
RUNTEST_OPTS += --threads=$(THREADS)
ei@vuokko.info's avatar
ei@vuokko.info committed
119 120
endif

121
RUNTEST_OPTS +=  \
122
	--rootdir=. \
123
	--config=$(CONFIG) \
Ian Lynagh's avatar
Ian Lynagh committed
124 125 126 127 128 129 130 131 132
	-e 'config.confdir="$(CONFIGDIR)"' \
	-e 'config.compiler="$(TEST_HC)"' \
	-e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
	-e 'config.ghc_pkg="$(GHC_PKG)"' \
	-e 'config.hp2ps="$(HP2PS_ABS)"' \
	-e 'config.hpc="$(HPC)"' \
	-e 'config.gs="$(GS)"' \
	-e 'config.platform="$(TARGETPLATFORM)"' \
	-e 'config.os="$(TargetOS_CPP)"' \
133
	-e 'config.arch="$(TargetARCH_CPP)"' \
Ian Lynagh's avatar
Ian Lynagh committed
134 135
	-e 'config.wordsize="$(WORDSIZE)"' \
	-e 'default_testopts.cleanup="$(CLEANUP)"' \
Ian Lynagh's avatar
Ian Lynagh committed
136
	-e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
Ian Lynagh's avatar
Ian Lynagh committed
137 138
	-e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
	-e 'config.exeext="$(exeext)"' \
139 140 141 142 143 144 145 146
	-e 'config.top="$(TOP_ABS)"'

ifneq "$(OUTPUT_SUMMARY)" ""
RUNTEST_OPTS +=  \
	--output-summary "$(OUTPUT_SUMMARY)"
endif

RUNTEST_OPTS +=  \
147 148
	$(EXTRA_RUNTEST_OPTS)

149 150 151 152 153 154 155 156 157 158 159 160
ifeq "$(fast)" "YES"
setfast = -e config.fast=1
else
setfast = 
endif

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

161
TESTS	     = 
162
TEST	     = 
163
WAY =
164

165 166 167 168
.PHONY: all boot test verbose accept fast

all: test

169
TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
170

171 172
boot: $(TIMEOUT_PROGRAM)

173
$(TIMEOUT_PROGRAM) :
174
	@echo "Looks like you don't have timeout, building it first..."
Ian Lynagh's avatar
Ian Lynagh committed
175
	$(MAKE) -C $(TOP)/timeout all
176

177
test: $(TIMEOUT_PROGRAM)
178
	$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
179
		$(patsubst %, --only=%, $(TEST)) \
180
		$(patsubst %, --only=%, $(TESTS)) \
181
		$(patsubst %, --way=%, $(WAY)) \
182
		$(patsubst %, --skipway=%, $(SKIPWAY)) \
183
		$(setfast) \
184
		$(setaccept)
185

186
verbose: test
187 188

accept:
189 190 191
	$(MAKE) accept=YES

fast:
192
	$(MAKE) fast=YES
193