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