24d770094f932b2447a7dc3583fa311bdfd9778b
[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 ifeq "$(PYTHON)" ""
23 $(error Python must be installed in order to use the testsuite)
24 endif
25
26 # export the value of $MAKE for invocation in ghc-regress/driver/
27 export MAKE
28
29 # ghastly hack, because the driver requires that $tool be an absolute path name.
30 GHC_STAGE1_ABS = $(GHC_COMPILER_DIR_ABS)/stage1/ghc-inplace
31 GHC_STAGE2_ABS = $(GHC_COMPILER_DIR_ABS)/stage2/ghc-inplace
32 GHC_STAGE3_ABS = $(GHC_COMPILER_DIR_ABS)/stage3/ghc-inplace
33
34 RUNTESTS = $(TOP)/driver/runtests.py
35 COMPILER = ghc
36 CONFIG = $(TOP)/config/$(COMPILER)
37
38 # can be overriden from the command line
39 ifneq "$(stage)" ""
40 TEST_HC = $(GHC_STAGE$(stage)_ABS)
41 else
42 TEST_HC = $(GHC_STAGE1_ABS)
43 endif
44
45 RUNTEST_OPTS =
46
47 ifeq "$(GhcWithNativeCodeGen)" "YES"
48 RUNTEST_OPTS += -e ghc_with_native_codegen=1
49 else
50 RUNTEST_OPTS += -e ghc_with_native_codegen=0
51 endif
52
53 ifeq "$(filter p, $(GhcLibWays))" "p"
54 RUNTEST_OPTS += -e ghc_with_profiling=1
55 else
56 RUNTEST_OPTS += -e ghc_with_profiling=0
57 endif
58
59 ifeq "$(filter u, $(GhcLibWays))" "u"
60 RUNTEST_OPTS += -e ghc_with_unreg=1
61 else
62 RUNTEST_OPTS += -e ghc_with_unreg=0
63 endif
64
65 ifeq "$(GhcWithInterpreter)" "YES"
66 RUNTEST_OPTS += -e ghc_with_interpreter=1
67 else
68 RUNTEST_OPTS += -e ghc_with_interpreter=0
69 endif
70
71 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
72 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
73 else
74 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
75 endif
76
77 ifeq "$(GhcWithSMP)" "YES"
78 RUNTEST_OPTS += -e ghc_with_smp=1
79 else
80 RUNTEST_OPTS += -e ghc_with_smp=0
81 endif
82
83 ifneq "$(THREADS)" ""
84 RUNTEST_OPTS += --thread=$(THREADS)
85 else
86 USETHREADS=0
87 endif
88
89 RUNTEST_OPTS += \
90 --config=$(CONFIG) \
91 -e config.compiler=\"$(TEST_HC)\" \
92 -e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
93 -e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
94 -e config.platform=\"$(TARGETPLATFORM)\" \
95 -e config.wordsize=\"$(WORDSIZE)\" \
96 -e default_testopts.cleanup=\"$(CLEANUP)\" \
97 -e "if '$(USETHREADS)': config.use_threads=int($(USETHREADS))" \
98 -e config.timeout="int($(TIMEOUT)) or config.timeout" \
99 -e config.timeout_prog=\"$(TOP)/timeout/timeout\" \
100 $(EXTRA_RUNTEST_OPTS)
101
102 # HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
103 # doesn't exist; they're always the same anyway
104
105 ifeq "$(fast)" "YES"
106 setfast = -e config.fast=1
107 else
108 setfast =
109 endif
110
111 ifeq "$(accept)" "YES"
112 setaccept = -e config.accept=1
113 else
114 setaccept =
115 endif
116
117 TESTS =
118 TEST =
119 WAY =
120
121 all :: test
122
123 test:
124 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
125 $(patsubst %, --only=%, $(TEST)) \
126 $(patsubst %, --only=%, $(TESTS)) \
127 $(patsubst %, --way=%, $(WAY)) \
128 $(setfast) \
129 $(setaccept)
130
131 verbose: test
132
133 accept:
134 $(MAKE) accept=YES
135
136 fast:
137 $(MAKE) fast=YES
138