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