]> git.saurik.com Git - apple/objc4.git/blob - test/Makefile
objc4-437.3.tar.gz
[apple/objc4.git] / test / Makefile
1 # a "simple test" contains a single .m file
2 # and optionally an expected-stderr file
3 SIMPLE_TESTS = category classname classpair classversion copyIvarList \
4 copyMethodList copyPropertyList createInstance \
5 definitions duplicateClass exc exchangeImp \
6 forward gdb getMethod layout ignoredSelector initialize \
7 instanceSize ismeta ivar load \
8 msgSend property protocol protocol_copyMethodList addMethod \
9 protocol_copyPropertyList protocol_cw sel super setSuper methodArgs \
10 nilAPIArgs resolve runtime zone weakcopy
11
12 # a "simple foundation test" is a simple test with -framework Foundation
13 SIMPLE_FOUNDATION_TESTS = nsobject foreach accessors \
14 classgetclass gdb-lock unwind method_getName \
15 synchronized synchronized-counter synchronized-grid
16
17 # a "simple CF test" is a simple test with -framework CoreFoundation
18 SIMPLE_CF_TESTS = association-cf
19
20 # a "complex build test" has a dedicated testname.out build rule below
21 COMPLEX_BUILD_TESTS = cacheflush future unload ivarSlide ivarSlidexx \
22 gcenforcer imageorder nsexc concurrentcat load-parallel load-order \
23 load-reentrant
24
25 # a "complex test" has a dedicated testname run rule below
26 COMPLEX_RUN_TESTS = gcenforcer_noobjc gcenforcer_nogc gcenforcer_supportsgc \
27 gcenforcer_requiresgc weak-missing weak-not-missing
28
29 # `make fail` just fails
30 FAIL_TESTS = fail
31
32 # Test-specific flags
33 CFLAGS_gdb = -Wno-deprecated-declarations -Wno-\#warnings
34 CFLAGS_setSuper = -Wno-deprecated-declarations
35 CFLAGS_duplicateClass = -Wno-deprecated-declarations
36 CFLAGS_protocol = -Wno-deprecated-declarations
37 CFLAGS_protocol_cw = -Wno-deprecated-declarations
38 CFLAGS_methodArgs = -Wno-deprecated-declarations
39 CFLAGS_ignoredSelector = -Wno-deprecated-declarations
40 CFLAGS_method_getName = -Wno-deprecated-declarations
41
42 # `make OBJC_LIB=/path/to/libobjc.A.dylib` tests a specific objc build
43 ifndef OBJC_LIB
44 OBJC_LIB = -lobjc
45 endif
46 ifneq "$(OBJC_LIB)" "-lobjc"
47 ENV_PREFIX += DYLD_LIBRARY_PATH=$(dir $(OBJC_LIB))
48 endif
49
50 # `make ARCHS=cpu` tests with the specified architecture (only one allowed)
51 ifndef ARCHS
52 ARCHS=$(shell /usr/bin/arch)
53 endif
54
55 # `make ARCH` is unsupported
56 ifdef ARCH
57 echo "*** use ARCHS not ARCH!"
58 exit 1
59 endif
60
61 # `make OTHER_CFLAGS=x` tests with specified flags
62 CFLAGS = -W -Wall -Wshorten-64-to-32 -g -O0 -fobjc-new-property
63 CFLAGS += $(OTHER_CFLAGS) -arch $(ARCHS)
64 LIBS = $(OBJC_LIB) -lauto
65
66 # `make GC=YES` tests with GC on
67 GC_state = nogc
68 ifdef GC
69 ifneq "$(GC)" "no"
70 ifneq "$(GC)" "NO"
71 GC_state = gc
72 CFLAGS += -fobjc-gc
73 endif
74 endif
75 endif
76
77 # `make LEAK_CHECK=NO` disables leak checking
78 # `make VALGRIND=YES` runs tests under Valgrind
79 ifdef VALGRIND
80 ifneq "$(VALGRIND)" "NO"
81 VALGRIND_PREFIX = ~public/bin/valgrind --db-listen=no --track-origins=yes
82 ifeq "$(LEAK_CHECK)" "NO"
83 VALGRIND_PREFIX += --leak-check=no
84 else
85 VALGRIND_PREFIX += --leak-check=full --leak-resolution=high
86 endif
87 endif
88 endif
89
90 # `make GUARDMALLOC=YES` runs tests with libgmalloc
91 ifdef GUARDMALLOC
92 ifneq "$(GUARDMALLOC)" "NO"
93 ENV_PREFIX += DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
94 endif
95 endif
96
97
98 RUN = $(ENV_PREFIX) $(VALGRIND_PREFIX)
99 ERR_CHECK = 2>&1 | perl errcheck.pl
100
101 # `make HALT=YES` halts on the first test to fail, this is easier for automated harnesses to detect and report
102 ifneq "$(HALT)" "YES"
103 # if we are supposed to continue after error (the default), do something successful if errcheck.pl failed
104 EAT_ERR = || sh -c ""
105 endif
106
107 FOUNDATION = -framework Foundation
108 CF = -framework CoreFoundation
109
110 # Rebuild executables every time in case arch or cflags changed
111 .PHONY: $(wildcard *.out) $(wildcard *.dylib)
112
113 CC=cc $(CFLAGS)
114 CXX=c++ $(CFLAGS) -fobjc-call-cxx-cdtors
115 CC_C=$(filter-out -fobjc-gc,$(CC))
116
117 all: print $(SIMPLE_TESTS) $(COMPLEX_BUILD_TESTS) $(COMPLEX_RUN_TESTS) $(SIMPLE_CF_TESTS) $(SIMPLE_FOUNDATION_TESTS)
118
119 print:
120 @echo "Testing library $(OBJC_LIB) ..."
121 @echo "CFLAGS = $(CFLAGS)"
122
123 debug:
124 @ make OBJC_LIB=`pwd`/../build/Debug/libobjc.A.dylib
125 release:
126 @ make OBJC_LIB=`pwd`/../build/Release/libobjc.A.dylib
127 buildit:
128 @ make OBJC_LIB=/tmp/objc.roots/objc~sym/libobjc.A.dylib
129 buildit-%:
130 @ make OBJC_LIB=/tmp/objc-$*.roots/objc-$*~sym/libobjc.A.dylib
131 clean:
132 rm -f *.out *.o *.dylib
133 rm -rf *.dSYM
134
135 reallyclean: clean
136 rm -f *~
137
138 $(SIMPLE_TESTS) $(FAIL_TESTS) $(COMPLEX_BUILD_TESTS) $(SIMPLE_FOUNDATION_TESTS) $(SIMPLE_CF_TESTS) : % : %.out
139 @ $(RUN) ./$@.out $(ERR_CHECK) $@ $(EAT_ERR)
140
141 $(addsuffix .out,$(SIMPLE_TESTS) $(FAIL_TESTS)) : %.out : %.m test.h Makefile
142 @ $(CC) $(CFLAGS_$*) $< -o $@ $(LIBS)
143
144 $(addsuffix .out,$(SIMPLE_FOUNDATION_TESTS)) : %.out : %.m test.h Makefile
145 @ $(CC) $(CFLAGS_$*) $(FOUNDATION) $< -o $@ $(LIBS)
146
147 $(addsuffix .out,$(SIMPLE_CF_TESTS)) : %.out : %.m test.h Makefile
148 @ $(CC) $(CFLAGS_$*) $(CF) $< -o $@ $(LIBS)
149
150 nsexc.out: exc.m test.h Makefile
151 @ $(CC) $(FOUNDATION) exc.m -o nsexc.out $(LIBS) -DUSE_FOUNDATION=1
152
153 imageorder.out: imageorder.m imageorder.h imageorder3.out test.h Makefile
154 @ $(CC) imageorder.m imageorder3.out imageorder2.out imageorder1.out -o imageorder.out $(LIBS)
155 imageorder3.out: imageorder3.m imageorder.h imageorder2.out test.h Makefile
156 @ $(CC) -dynamiclib imageorder3.m imageorder2.out imageorder1.out -o imageorder3.out $(LIBS)
157 imageorder2.out: imageorder2.m imageorder.h imageorder1.out test.h Makefile
158 @ $(CC) -dynamiclib imageorder2.m imageorder1.out -o imageorder2.out $(LIBS)
159 imageorder1.out: imageorder1.m imageorder.h test.h Makefile
160 @ $(CC) -dynamiclib imageorder1.m -o imageorder1.out $(LIBS)
161
162 ivarSlide.out: ivarSlide1.m ivarSlide2.m ivarSlide.h test.h Makefile
163 @ $(CC) ivarSlide1.m ivarSlide2.m -o ivarSlide.out $(LIBS)
164
165 ivarSlidexx.out: ivarSlide1.m ivarSlide2.m ivarSlide.h test.h Makefile
166 @ $(CXX) -x objective-c++ ivarSlide1.m ivarSlide2.m -x none -o ivarSlidexx.out $(LIBS)
167
168 future.out: future1.m future.h future0.out future2.out test.h Makefile
169 @ $(CC) future1.m future0.out -o future.out $(LIBS)
170 future0.out: future0.m future.h test.h Makefile
171 @ $(CC) -dynamiclib future0.m -o future0.out $(LIBS)
172 future2.out: future2.m future.h future0.out test.h Makefile
173 @ $(CC) -dynamiclib future2.m future0.out -o future2.out $(LIBS)
174
175 weak.out: weak.m weak2.m weak.h test.h Makefile
176 @ $(CC) weak2.m -dynamiclib -o libweak.dylib $(LIBS)
177 @ $(CC) weak2.m -DEMPTY= -dynamiclib -o libweak_empty.dylib $(LIBS)
178 @ $(CC) weak.m -L. -weak-lweak -o weak.out $(LIBS)
179
180 weak-not-missing: weak.out
181 @ $(RUN) ./weak.out $(ERR_CHECK) weak-not-missing $(EAT_ERR)
182 weak-missing: weak.out
183 @ DYLD_IMAGE_SUFFIX=_empty $(RUN) ./weak.out $(ERR_CHECK) weak-missing $(EAT_ERR)
184
185 CONCURRENT_IN=cc1 cc2 cc3 cc4 cc5 cc6 cc7 cc8 cc9 cc10 cc11 cc12 cc13 cc14 cc15
186 CONCURRENT_DYLIBS=$(addsuffix .out,$(CONCURRENT_IN))
187
188 $(CONCURRENT_DYLIBS) : %.out : concurrentcat_category.m test.h Makefile
189 @ $(CC) -undefined dynamic_lookup -dynamiclib -DTN=$* $< -o $@ $(LIBS)
190
191 concurrentcat.out: concurrentcat.m $(CONCURRENT_DYLIBS)
192 @ $(CC) concurrentcat.m -o concurrentcat.out $(LIBS) $(FOUNDATION)
193
194 cacheflush.out: cacheflush.m cacheflush.h cacheflush0.out cacheflush2.out cacheflush3.out test.h Makefile
195 @ $(CC) cacheflush.m cacheflush0.out -o cacheflush.out $(LIBS)
196 cacheflush0.out: cacheflush0.m cacheflush.h test.h Makefile
197 @ $(CC) -dynamiclib cacheflush0.m -o cacheflush0.out $(LIBS)
198 cacheflush2.out: cacheflush2.m cacheflush.h cacheflush0.out test.h Makefile
199 @ $(CC) -dynamiclib cacheflush2.m cacheflush0.out -o cacheflush2.out $(LIBS)
200 cacheflush3.out: cacheflush3.m cacheflush.h cacheflush0.out test.h Makefile
201 @ $(CC) -dynamiclib cacheflush3.m cacheflush0.out -o cacheflush3.out $(LIBS)
202
203
204 unload.out: unload.m unload.h unload2.out unload3.out unload4.out test.h Makefile
205 @ $(CC) unload.m -o unload.out $(LIBS)
206 unload2.out: unload2.m unload.h test.h Makefile
207 @ $(CC) -bundle unload2.m -o unload2.out $(LIBS)
208 unload3.out: unload3.m Makefile
209 @ $(CC) -dynamiclib unload3.m -o unload3.out $(LIBS)
210 unload4.out: unload4.m Makefile
211 @ $(CC) -dynamiclib unload4.m -o unload4.out $(LIBS)
212
213 load-reentrant.out: load-reentrant.m load-reentrant2.m
214 @ $(CC) load-reentrant.m -o load-reentrant.out $(LIBS)
215 @ $(CC) -bundle load-reentrant2.m -o libload-reentrant2.dylib -bundle_loader load-reentrant.out $(LIBS)
216
217 load-order.out: load-order.m libload-order1.dylib
218 @ $(CC) load-order.m -o load-order.out -L. -lload-order1 -lload-order2 -lload-order3 $(LIBS)
219 libload-order1.dylib: load-order1.m libload-order2.dylib
220 @ $(CC) -dynamiclib load-order1.m -o libload-order1.dylib -L. -lload-order2 -lload-order3 $(LIBS)
221 libload-order2.dylib: load-order2.m libload-order3.dylib
222 @ $(CC) -dynamiclib load-order2.m -o libload-order2.dylib -L. -lload-order3 $(LIBS)
223 libload-order3.dylib: load-order3.m
224 @ $(CC) -dynamiclib load-order3.m -o libload-order3.dylib $(LIBS)
225
226 load-parallel.out: load-parallel.m libload-parallel00.dylib load-parallel0.out load-parallel1.out load-parallel2.out load-parallel3.out load-parallel4.out load-parallel5.out load-parallel6.out load-parallel7.out load-parallel8.out load-parallel9.out
227 @ $(CC) -DCOUNT=10 load-parallel.m -o load-parallel.out -L. -lload-parallel00 $(LIBS)
228 libload-parallel00.dylib: load-parallel00.m Makefile
229 @ $(CC) -dynamiclib load-parallel00.m -o libload-parallel00.dylib $(LIBS)
230 load-parallel0.out: load-parallel0.m Makefile libload-parallel00.dylib
231 @ $(CC) -dynamiclib load-parallel0.m -DN=0 -o load-parallel0.out -L. -lload-parallel00 $(LIBS)
232 load-parallel1.out: load-parallel0.m Makefile libload-parallel00.dylib
233 @ $(CC) -dynamiclib load-parallel0.m -DN=1 -o load-parallel1.out -L. -lload-parallel00 $(LIBS)
234 load-parallel2.out: load-parallel0.m Makefile libload-parallel00.dylib
235 @ $(CC) -dynamiclib load-parallel0.m -DN=2 -o load-parallel2.out -L. -lload-parallel00 $(LIBS)
236 load-parallel3.out: load-parallel0.m Makefile libload-parallel00.dylib
237 @ $(CC) -dynamiclib load-parallel0.m -DN=3 -o load-parallel3.out -L. -lload-parallel00 $(LIBS)
238 load-parallel4.out: load-parallel0.m Makefile libload-parallel00.dylib
239 @ $(CC) -dynamiclib load-parallel0.m -DN=4 -o load-parallel4.out -L. -lload-parallel00 $(LIBS)
240 load-parallel5.out: load-parallel0.m Makefile libload-parallel00.dylib
241 @ $(CC) -dynamiclib load-parallel0.m -DN=5 -o load-parallel5.out -L. -lload-parallel00 $(LIBS)
242 load-parallel6.out: load-parallel0.m Makefile libload-parallel00.dylib
243 @ $(CC) -dynamiclib load-parallel0.m -DN=6 -o load-parallel6.out -L. -lload-parallel00 $(LIBS)
244 load-parallel7.out: load-parallel0.m Makefile libload-parallel00.dylib
245 @ $(CC) -dynamiclib load-parallel0.m -DN=7 -o load-parallel7.out -L. -lload-parallel00 $(LIBS)
246 load-parallel8.out: load-parallel0.m Makefile libload-parallel00.dylib
247 @ $(CC) -dynamiclib load-parallel0.m -DN=8 -o load-parallel8.out -L. -lload-parallel00 $(LIBS)
248 load-parallel9.out: load-parallel0.m Makefile libload-parallel00.dylib
249 @ $(CC) -dynamiclib load-parallel0.m -DN=9 -o load-parallel9.out -L. -lload-parallel00 $(LIBS)
250
251 libnoobjc.dylib: gc.c Makefile
252 @ $(CC_C) gc.c -dynamiclib -o libnoobjc.dylib
253 libnogc.dylib: gc.m Makefile
254 @ $(CC) gc.m -dynamiclib -o libnogc.dylib -fno-objc-gc $(LIBS)
255 libsupportsgc.dylib: gc.m Makefile
256 @ $(CC) gc.m -dynamiclib -o libsupportsgc.dylib -fobjc-gc $(LIBS)
257 librequiresgc.real.dylib: gc.m Makefile
258 @ $(CC) gc.m -dynamiclib -o librequiresgc.real.dylib -install_name librequiresgc.dylib -fobjc-gc-only $(LIBS)
259 librequiresgc.fake.dylib: gc.m Makefile
260 @ $(CC) gc.m -dynamiclib -o librequiresgc.fake.dylib -install_name librequiresgc.dylib -fobjc-gc $(LIBS)
261 librequiresgc.dylib: librequiresgc.real.dylib librequiresgc.fake.dylib
262 @ cp -f librequiresgc.real.dylib librequiresgc.dylib
263
264 gcenforcer.out: gcenforcer.m libsupportsgc.dylib librequiresgc.dylib libnogc.dylib libnoobjc.dylib test.h Makefile
265 @ $(CC) gcenforcer.m -o gcenforcer.out $(LIBS)
266
267 gcenforcer_noobjc.out: main.m libnoobjc.dylib test.h Makefile
268 @ $(CC) main.m libnoobjc.dylib -o gcenforcer_noobjc.out $(LIBS)
269 gcenforcer_noobjc: gcenforcer_noobjc.out Makefile
270 @ $(RUN) ./gcenforcer_noobjc.out $(ERR_CHECK) $@ $(EAT_ERR)
271
272 gcenforcer_nogc.out: main.m libnogc.dylib test.h Makefile
273 @ $(CC) main.m libnogc.dylib -o gcenforcer_nogc.out $(LIBS)
274 gcenforcer_nogc: gcenforcer_nogc.out Makefile
275 @ $(RUN) ./gcenforcer_nogc.out $(ERR_CHECK) $@ gcenforcer_nogc.$(GC_state).expected-stderr $(EAT_ERR)
276
277 gcenforcer_supportsgc.out: main.m libsupportsgc.dylib test.h Makefile
278 @ $(CC) main.m libsupportsgc.dylib -o gcenforcer_supportsgc.out $(LIBS)
279 gcenforcer_supportsgc: gcenforcer_supportsgc.out Makefile
280 @ $(RUN) ./gcenforcer_supportsgc.out $(ERR_CHECK) $@ $(EAT_ERR)
281
282 # Linker sees librequiresgc.fake.dylib, runtime uses librequiresgc.real.dylib
283 gcenforcer_requiresgc.out: main.m librequiresgc.dylib libsupportsgc.dylib test.h Makefile
284 @ $(CC) main.m librequiresgc.fake.dylib -o gcenforcer_requiresgc.out $(LIBS)
285
286 gcenforcer_requiresgc: gcenforcer_requiresgc.out Makefile
287 @ $(RUN) ./gcenforcer_requiresgc.out $(ERR_CHECK) $@ gcenforcer_requiresgc.$(GC_state).expected-stderr $(EAT_ERR)
288