e9cce901b0e28909686f253a8c8381d0d336c2c8
[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 [ -s T9405.ticky ] && echo Ticky-Ticky
56
57 # Naming convention: 'T5423_' obj-way '_' obj-src
58 # obj-way ::= v | dyn
59 # obj-src ::= gcc // using __attribute__(constructor)
60 # | asm // manually laid out sections
61 # $(0) = obj-src
62
63 define run_T5435_v
64 $(RM) T5435_load_v_$(1) T5435_v_$(1)$(exeext)
65 '$(TEST_HC)' $(TEST_HC_OPTS) -optc-D$(HostOS)_HOST_OS -v0 -c T5435_$(1).c -o T5435_load_v_$(1).o
66 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_v_$(1)_o -o T5435_v_$(1)$(exeext)
67 ./T5435_v_$(1) v ./T5435_load_v_$(1).o
68 endef
69
70 define run_T5435_dyn
71 $(RM) T5435_load_dyn_$(1) T5435_dyn_$(1)$(exeext)
72 '$(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)
73 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_dyn_$(1)_o -o T5435_dyn_$(1)$(exeext)
74 ./T5435_dyn_$(1) dyn ./T5435_load_dyn_$(1)$(dllext)
75 endef
76
77 .PHONY: T5435_v_gcc
78 T5435_v_gcc :
79 $(call run_T5435_v,gcc)
80
81 .PHONY: T5435_v_asm
82 T5435_v_asm :
83 $(call run_T5435_v,asm)
84
85 .PHONY: T5435_dyn_gcc
86 T5435_dyn_gcc :
87 $(call run_T5435_dyn,gcc)
88
89 .PHONY: T5435_dyn_asm
90 T5435_dyn_asm :
91 $(call run_T5435_dyn,asm)
92
93 T6006_setup :
94 '$(TEST_HC)' $(TEST_HC_OPTS) -c T6006.hs
95
96 T8124_setup :
97 '$(TEST_HC)' $(TEST_HC_OPTS) -c T8124.hs
98
99 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
100 T7037_CONST = const
101 else
102 T7037_CONST =
103 endif
104 .PHONY: T7037
105 T7037:
106 $(RM) 7037.o 7037.hi 7037$(exeext)
107 "$(TEST_HC)" $(TEST_HC_OPTS) T7037.hs -v0
108 "$(TEST_HC)" -optc-DT7037_CONST=$(T7037_CONST) $(filter-out -rtsopts, $(TEST_HC_OPTS)) T7037_main.c -v0 -o T7037_main -no-hs-main
109 ./T7037_main
110
111 T7040_ghci_setup :
112 '$(TEST_HC)' $(TEST_HC_OPTS) $(ghciWayFlags) -c T7040_ghci_c.c
113
114 .PHONY: T10296a
115 T10296a:
116 $(RM) T10296a_c.o T10296a.o T10296a.hi T10296a_stub.h
117 '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -threaded T10296a.hs T10296a_c.c -o T10296a
118 ./T10296a +RTS -N2
119
120 .PHONY: linker_unload
121 linker_unload:
122 $(RM) Test.o Test.hi
123 "$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0
124 # -rtsopts causes a warning
125 "$(TEST_HC)" LinkerUnload.hs -package ghc $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror
126 ./linker_unload "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
127
128 # -----------------------------------------------------------------------------
129 # Testing failures in the RTS linker. We should be able to repeatedly
130 # load bogus object files of various kinds without crashing and
131 # without any memory leaks.
132 #
133 # Check for memory leaks manually by running e.g.
134 #
135 # make linker_error1
136 # valgrind --leak-check=full --show-reachable=yes ./linker_error1 linker_error1_o.o
137
138 # linker_error1: not a valid object file
139
140 .PHONY: linker_error1
141 linker_error1:
142 "$(TEST_HC)" -c linker_error.c -o linker_error1.o
143 "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug -threaded
144 ./linker_error1 linker_error.c
145
146 # linker_error2: the object file has an unknown symbol (fails in
147 # resolveObjs())
148
149 .PHONY: linker_error2
150 linker_error2:
151 "$(TEST_HC)" -c linker_error.c -o linker_error2.o
152 "$(TEST_HC)" -c linker_error2.c -o linker_error2_o.o
153 "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug -threaded
154 ./linker_error2 linker_error2_o.o
155
156 # linker_error3: the object file duplicates an existing symbol (fails
157 # in loadObj())
158
159 .PHONY: linker_error3
160 linker_error3:
161 "$(TEST_HC)" -c linker_error.c -o linker_error3.o
162 "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o
163 "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded
164 ./linker_error3 linker_error3_o.o