rts: Add --internal-counters RTS flag and several counters
[ghc.git] / testsuite / tests / rts / Makefile
1 TOP=../..
2 include $(TOP)/mk/boilerplate.mk
3 include $(TOP)/mk/test.mk
4
5 outofmem-prep::
6 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make -fforce-recomp outofmem.hs -o outofmem
7
8 outofmem::
9 $(MAKE) -s --no-print-directory outofmem-prep
10 @ulimit -m 10000000 2>/dev/null; ./outofmem || echo "exit($$?)"
11
12 outofmem2-prep::
13 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts --make -fforce-recomp outofmem2.hs -o outofmem2
14
15 outofmem2::
16 $(MAKE) -s --no-print-directory outofmem2-prep
17 @ulimit -m 1000000 2>/dev/null; ./outofmem2 +RTS -M5m -RTS || echo "exit($$?)"
18
19 T2615-prep:
20 $(RM) libfoo_T2615.so
21 '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -c libfoo_T2615.c -o libfoo_T2615.o
22 '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -shared -no-auto-link-packages libfoo_T2615.o -o libfoo_T2615.so
23
24 .PHONY: T4059
25 T4059:
26 $(RM) T4059_c.o T4059.o T4059.hi
27 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make T4059 T4059_c.c
28 ./T4059
29
30 exec_signals-prep:
31 $(CC) -o exec_signals_child exec_signals_child.c
32 $(CC) -o exec_signals_prepare exec_signals_prepare.c
33
34 .PHONY: T4850
35 T4850:
36 $(RM) T4850.o T4850.hi T4850$(exeext)
37 "$(TEST_HC)" $(TEST_HC_OPTS) -v0 -rtsopts -debug -threaded --make T4850
38 ./T4850 +RTS -s 2>&1 | grep TASKS | sed 's/^ *TASKS: *\([0-9]*\).*$$/\1/'
39
40 .PHONY: T5423
41 T5423:
42 $(RM) T5423_cmm.o T5423.o T5423.hi T5423$(exeext)
43 "$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c T5423_cmm.cmm
44 "$(TEST_HC)" $(TEST_HC_OPTS) -v0 -c T5423.hs
45 "$(TEST_HC)" $(TEST_HC_OPTS) -v0 T5423.o T5423_cmm.o -o T5423$(exeext)
46 ./T5423
47
48 .PHONY: T9405
49 T9405:
50 @'$(TEST_HC)' $(TEST_HC_OPTS) -ticky -rtsopts T9405.hs; \
51 ./T9405 +RTS -rT9405.ticky & \
52 sleep 0.2; \
53 kill -2 $$!; \
54 wait $$!; \
55 [ -e T9405.ticky ] || echo "Error: Ticky profile doesn't exist"; \
56 [ -s T9405.ticky ] || echo "Error: Ticky profile is empty"; \
57 echo Ticky-Ticky;
58
59 # Naming convention: 'T5423_' obj-way '_' obj-src
60 # obj-way ::= v | dyn
61 # obj-src ::= gcc // using __attribute__(constructor)
62 # | asm // manually laid out sections
63 # $(0) = obj-src
64
65 define run_T5435_v
66 $(RM) T5435_load_v_$(1) T5435_v_$(1)$(exeext)
67 '$(TEST_HC)' $(TEST_HC_OPTS) -optc-D$(HostOS)_HOST_OS -v0 -c T5435_$(1).c -o T5435_load_v_$(1).o
68 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_v_$(1)_o -o T5435_v_$(1)$(exeext)
69 ./T5435_v_$(1) v ./T5435_load_v_$(1).o
70 endef
71
72 define run_T5435_dyn
73 $(RM) T5435_load_dyn_$(1) T5435_dyn_$(1)$(exeext)
74 '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -optc-D$(HostOS)_HOST_OS -v0 -fPIC -shared -c T5435_$(1).c -osuf dyn_$(1)_o -o T5435_load_dyn_$(1)$(dllext)
75 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_dyn_$(1)_o -o T5435_dyn_$(1)$(exeext)
76 ./T5435_dyn_$(1) dyn ./T5435_load_dyn_$(1)$(dllext)
77 endef
78
79 .PHONY: T5435_v_gcc
80 T5435_v_gcc :
81 $(call run_T5435_v,gcc)
82
83 .PHONY: T5435_v_asm
84 T5435_v_asm :
85 $(call run_T5435_v,asm)
86
87 .PHONY: T5435_dyn_gcc
88 T5435_dyn_gcc :
89 $(call run_T5435_dyn,gcc)
90
91 .PHONY: T5435_dyn_asm
92 T5435_dyn_asm :
93 $(call run_T5435_dyn,asm)
94
95 T6006_setup :
96 '$(TEST_HC)' $(TEST_HC_OPTS) -c T6006.hs
97
98 T8124_setup :
99 '$(TEST_HC)' $(TEST_HC_OPTS) -c T8124.hs
100
101 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
102 T7037_CONST = const
103 else
104 T7037_CONST =
105 endif
106 .PHONY: T7037
107 T7037:
108 $(RM) 7037.o 7037.hi 7037$(exeext)
109 "$(TEST_HC)" $(TEST_HC_OPTS) T7037.hs -v0
110 "$(TEST_HC)" -optc-DT7037_CONST=$(T7037_CONST) $(filter-out -rtsopts, $(TEST_HC_OPTS)) T7037_main.c -v0 -o T7037_main -no-hs-main
111 ./T7037_main
112
113 T7040_ghci_setup :
114 '$(TEST_HC)' $(TEST_HC_OPTS) $(ghciWayFlags) -c T7040_ghci_c.c
115
116 .PHONY: T10296a
117 T10296a:
118 $(RM) T10296a_c.o T10296a.o T10296a.hi T10296a_stub.h
119 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -threaded T10296a.hs T10296a_c.c -o T10296a
120 ./T10296a +RTS -N2
121
122 .PHONY: linker_unload
123 linker_unload:
124 $(RM) Test.o Test.hi
125 "$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0
126 # -rtsopts causes a warning
127 "$(TEST_HC)" LinkerUnload.hs -package ghc $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror
128 ./linker_unload "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
129
130 # -----------------------------------------------------------------------------
131 # Testing failures in the RTS linker. We should be able to repeatedly
132 # load bogus object files of various kinds without crashing and
133 # without any memory leaks.
134 #
135 # Check for memory leaks manually by running e.g.
136 #
137 # make linker_error1
138 # valgrind --leak-check=full --show-reachable=yes ./linker_error1 linker_error1_o.o
139
140 # linker_error1: not a valid object file
141
142 .PHONY: linker_error1
143 linker_error1:
144 "$(TEST_HC)" -c linker_error.c -o linker_error1.o
145 "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug -threaded
146 ./linker_error1 linker_error.c
147
148 # linker_error2: the object file has an unknown symbol (fails in
149 # resolveObjs())
150
151 .PHONY: linker_error2
152 linker_error2:
153 "$(TEST_HC)" -c linker_error.c -o linker_error2.o
154 "$(TEST_HC)" -c linker_error2.c -o linker_error2_o.o
155 "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug -threaded
156 ./linker_error2 linker_error2_o.o
157
158 # linker_error3: the object file duplicates an existing symbol (fails
159 # in loadObj())
160
161 .PHONY: linker_error3
162 linker_error3:
163 "$(TEST_HC)" -c linker_error.c -o linker_error3.o
164 "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o
165 "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded
166 ./linker_error3 linker_error3_o.o
167
168 .PHONY: T11788
169 T11788:
170 "$(TEST_HC)" -c T11788.c -o T11788_obj.o
171 "$(AR)" rsT libT11788.a T11788_obj.o 2> /dev/null
172 echo main | "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE)) T11788.hs -lT11788 -L"$(PWD)"
173
174 .PHONY: T12497
175 T12497:
176 echo main | "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE)) T12497.hs
177
178 .PHONY: T14695
179 T14695:
180 echo ":quit" | LD_LIBRARY_PATH="foo:" "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE))
181
182 .PHONY: InternalCounters
183 InternalCounters:
184 "$(TEST_HC)" +RTS -s --internal-counters -RTS 2>&1 | grep "Internal Counters"
185 -"$(TEST_HC)" +RTS -s -RTS 2>&1 | grep "Internal Counters"