]> git.saurik.com Git - apple/xnu.git/blob - tests/Makefile
xnu-6153.141.1.tar.gz
[apple/xnu.git] / tests / Makefile
1 PROJECT := xnu/darwintests
2
3 # When building as part of xnu_tests, we get passed a DSTROOT that's got the
4 # unit test path in it already. But, BASEDSTROOT doesn't, so use that instead.
5 ifdef BASEDSTROOT
6 override DSTROOT = $(BASEDSTROOT)
7 endif
8
9 ENABLE_LTE_TESTS=YES
10
11 OTHER_LTE_INCLUDE_FILES += \
12 /System/Library/PrivateFrameworks/LoggingSupport.framework, \
13 /System/Library/PrivateFrameworks/MobileKeyBag.framework, \
14 /System/Library/Frameworks/IOSurface.framework, \
15 /usr/local/lib/libdarwintest_utils.dylib, \
16 /usr/lib/libapple_crypto.dylib,
17
18 DEVELOPER_DIR ?= $(shell xcode-select -p)
19
20 # the xnu build system will only ever call us with the default target
21 .DEFAULT_GOAL := install
22
23 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
24
25 OTHER_CFLAGS = -Weverything -Wno-gnu-union-cast -Wno-missing-field-initializers -Wno-partial-availability
26 OTHER_CFLAGS += -Wno-missing-noreturn -Wno-vla -Wno-reserved-id-macro -Wno-documentation-unknown-command
27 OTHER_CFLAGS += -Wno-padded -Wno-used-but-marked-unused -Wno-covered-switch-default -Wno-nullability-extension
28 OTHER_CFLAGS += -Wno-gnu-empty-initializer -Wno-unused-macros -Wno-undef -Wno-fixed-enum-extension
29 OTHER_CFLAGS += --std=gnu11 -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
30 OTHER_CFLAGS += -UT_NAMESPACE_PREFIX -DT_NAMESPACE_PREFIX=xnu
31 OTHER_CFLAGS += -F $(SDKROOT)/System/Library/PrivateFrameworks
32
33 CODESIGN:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign)
34 CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign_allocate)
35
36 # to have custom compiler flags to
37 # target: OTHER_CFLAGS += <my flags>
38
39 atm_diagnostic_flag: OTHER_CFLAGS += drop_priv.c
40
41 atm_diagnostic_flag_entitled: CODE_SIGN_ENTITLEMENTS = atm_diagnostic_flag.entitlements
42 atm_diagnostic_flag_entitled: OTHER_CFLAGS += drop_priv.c
43
44 testposixshm: INVALID_ARCHS = i386
45
46 avx: INVALID_ARCHS = i386
47 avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
48 avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
49 avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
50 # Level 2 optimization must be used to prevent compiler from generating
51 # invalid instructions when compiling with AVX-512 flags.
52 avx: CONFIG_FLAGS += -O2
53 # Disable vzeroupper insertion to work around rdar://problem/35035096
54 avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
55 ifneq (osx,$(TARGET_NAME))
56 EXCLUDED_SOURCES += avx.c
57 endif
58
59 backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
60
61 data_protection: OTHER_LDFLAGS += -ldarwintest_utils -framework IOKit
62
63 immovable_send: excserver
64 immovable_send: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
65 immovable_send: OTHER_LDFLAGS += -ldarwintest_utils -lpthread -framework IOKit
66
67 CUSTOM_TARGETS += immovable_send_client
68 immovable_send: immovable_send_client
69
70 immovable_send_client: immovable_send_client.c
71 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) immovable_send_client.c -o $(SYMROOT)/immovable_send_client
72
73 install-immovable_send_client: immovable_send_client
74 mkdir -p $(INSTALLDIR)
75 cp $(SYMROOT)/immovable_send_client $(INSTALLDIR)/
76
77 kdebug: INVALID_ARCHS = i386
78 kdebug: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils -framework kperf
79
80 EXCLUDED_SOURCES += drop_priv.c kperf_helpers.c xnu_quick_test_helpers.c memorystatus_assertion_helpers.c bpflib.c in_cksum.c
81
82 ifneq ($(PLATFORM),iPhoneOS)
83 EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c perf_compressor.c memorystatus_freeze_test.c
84 endif
85
86 perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
87 perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
88
89 memorystatus_freeze_test: CODE_SIGN_ENTITLEMENTS=./task_for_pid_entitlement.plist
90 memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
91 memorystatus_freeze_test: OTHER_CFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
92
93 memorystatus_is_assertion: OTHER_LDFLAGS += -ldarwintest_utils
94 memorystatus_is_assertion: OTHER_CFLAGS += memorystatus_assertion_helpers.c
95
96 shared_cache_tests: INVALID_ARCHS = i386
97 shared_cache_tests: OTHER_LDFLAGS += -ldarwintest_utils
98
99 stackshot_tests: OTHER_CFLAGS += -Wno-objc-messaging-id
100 stackshot_tests: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
101 stackshot_tests: INVALID_ARCHS = i386
102
103 stackshot_accuracy: OTHER_CFLAGS += -ldarwintest_utils -Wno-objc-messaging-id
104 stackshot_accuracy: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
105 stackshot_accuracy: INVALID_ARCHS = i386
106
107 telemetry: OTHER_LDFLAGS = -framework ktrace -framework CoreFoundation
108 telemetry: INVALID_ARCHS = i386
109
110 memorystatus_zone_test: INVALID_ARCHS = i386
111 memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
112 memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
113 memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
114
115 kpc: OTHER_LDFLAGS += -framework kperf -framework ktrace
116 kpc: INVALID_ARCHS = i386
117
118 kperf: INVALID_ARCHS = i386
119 kperf: OTHER_CFLAGS += kperf_helpers.c
120 kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
121
122 kperf_backtracing: INVALID_ARCHS = i386
123 kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
124 kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
125 kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
126
127 kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
128 kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
129
130 mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
131
132 monotonic_core: OTHER_LDFLAGS += -framework ktrace
133 monotonic_core: INVALID_ARCHS = i386
134
135 perf_exit: perf_exit_proc
136 perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
137 perf_exit: INVALID_ARCHS = i386
138 perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
139
140 CUSTOM_TARGETS += prioritize_process_launch_helper
141 prioritize_process_launch: prioritize_process_launch_helper
142
143 prioritize_process_launch_helper: prioritize_process_launch_helper.c
144 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) prioritize_process_launch_helper.c -o $(SYMROOT)/prioritize_process_launch_helper
145 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
146 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
147
148 install-prioritize_process_launch_helper: prioritize_process_launch_helper
149 mkdir -p $(INSTALLDIR)
150 cp $(SYMROOT)/prioritize_process_launch_helper $(INSTALLDIR)/
151
152
153 perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
154
155 mach_exception_reply: OTHER_CFLAGS += -Wno-cast-align
156
157 os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
158 os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
159
160 osptr: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++98
161 osptr: OTHER_CXXFLAGS += osptr_helper.cpp
162
163 osptr_dumb: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
164
165 osptr_11: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++11
166 osptr_11: OTHER_CXXFLAGS += osptr_helper.cpp
167 osptr_11: osptr.cpp
168 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
169
170 osptr_17: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
171 osptr_17: OTHER_CXXFLAGS += osptr_helper.cpp
172 osptr_17: osptr.cpp
173 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
174
175 EXCLUDED_SOURCES += osptr_helper.cpp
176
177 os_refcnt: OTHER_CFLAGS += -I$(SRCROOT)/../libkern/ -Wno-gcc-compat -Wno-undef -O3 -flto
178
179 task_inspect: CODE_SIGN_ENTITLEMENTS = task_inspect.entitlements
180 task_inspect: OTHER_CFLAGS += -DENTITLED=1
181
182 turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
183 turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
184
185 CUSTOM_TARGETS += perf_exit_proc
186
187 perf_exit_proc:
188 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
189
190 install-perf_exit_proc: perf_exit_proc
191 mkdir -p $(INSTALLDIR)
192 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
193
194 stackshot_idle_25570396: INVALID_ARCHS = i386
195 stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
196
197 stackshot_block_owner_14362384: INVALID_ARCHS = i386
198 stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
199 ifeq ($(PLATFORM),MacOSX)
200 stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
201 endif
202
203 all: $(DSTROOT)/usr/local/bin/kcdata
204
205 $(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
206 mkdir -p $(dir $@)
207 cp $< $@
208 chmod a+x $@
209
210 xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
211
212 xnu_quick_test_entitled: CODE_SIGN_ENTITLEMENTS = xnu_quick_test.entitlements
213
214 CUSTOM_TARGETS += vm_set_max_addr_helper
215
216 vm_set_max_addr_helper: vm_set_max_addr_helper.c
217 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
218 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
219 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
220
221 install-vm_set_max_addr_helper: vm_set_max_addr_helper
222 mkdir -p $(INSTALLDIR)
223 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
224
225 ifeq ($(PLATFORM),iPhoneOS)
226 OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled vm_phys_footprint_legacy
227 jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
228 jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1
229 jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
230
231 jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
232 jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
233 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
234
235 vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
236 vm_phys_footprint_legacy: OTHER_CFLAGS += -DLEGACY_FOOTPRINT_ENTITLED=1
237 vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
238 vm_phys_footprint_legacy: vm_phys_footprint.c
239 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
240
241 endif
242
243 task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
244
245 proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
246 proc_info: OTHER_LDFLAGS += -ldarwintest_utils
247
248 proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
249
250 proc_info_44873309: CODE_SIGN_ENTITLEMENTS = ./proc_info_44873309.entitlements
251
252 disk_mount_conditioner: disk_mount_conditioner*
253 disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
254 disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
255
256 disk_mount_conditioner: OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
257 disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
258 disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
259 disk_mount_conditioner_unentitled: disk_mount_conditioner.c
260 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
261
262 work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
263 work_interval_test: OTHER_CFLAGS += -DENTITLED=1
264
265 settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
266
267 settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
268 settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
269
270 thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
271 thread_group_set_32261625: INVALID_ARCHS = i386
272
273 task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
274
275 task_vm_info_decompressions: INVALID_ARCHS = x86_64 i386
276
277 socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
278 socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
279
280 sioc-if-addr-bounds: sioc-if-addr-bounds.c
281
282 net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
283
284 net_bridge: OTHER_CFLAGS += bpflib.c in_cksum.c
285 net_bridge: OTHER_LDFLAGS += -ldarwintest_utils
286
287 ifneq (osx,$(TARGET_NAME))
288 EXCLUDED_SOURCES += no32exec_35914211.c no32exec_35914211_helper.c
289 else # target = osx
290 CUSTOM_TARGETS += no32exec_35914211_helper no32exec_35914211_helper_binprefs
291
292 no32exec_35914211_helper: INVALID_ARCHS = x86_64 i386
293 no32exec_35914211_helper:
294 $(CC) $(LDFLAGS) $(CFLAGS) -arch i386 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
295 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
296
297 install-no32exec_35914211_helper:
298 mkdir -p $(INSTALLDIR)
299 cp $(SYMROOT)/no32exec_35914211_helper $(INSTALLDIR)/
300
301 no32exec_35914211_helper_binprefs: INVALID_ARCHS = x86_64 i386
302 no32exec_35914211_helper_binprefs:
303 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) -arch i386 -arch x86_64 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
304 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
305
306 install-no32exec_35914211_helper_binprefs:
307 mkdir -p $(INSTALLDIR)
308 cp $(SYMROOT)/no32exec_35914211_helper_binprefs $(INSTALLDIR)/
309
310 no32exec_35914211: INVALID_ARCHS = i386
311 no32exec_35914211: no32exec_35914211_helper
312 no32exec_35914211: no32exec_35914211_helper_binprefs
313 endif # (osx,$(TARGET_NAME)))
314
315 MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
316
317 CUSTOM_TARGETS += excserver
318
319 excserver:
320 $(MIG) $(CFLAGS) \
321 -sheader $(OBJROOT)/excserver.h \
322 -server $(OBJROOT)/excserver.c \
323 -header /dev/null -user /dev/null \
324 excserver.defs
325 install-excserver: ;
326
327 exc_resource_threads: excserver
328 exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
329
330 fp_exception: excserver
331 fp_exception: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
332
333 ifneq (osx,$(TARGET_NAME))
334 EXCLUDED_SOURCES += ldt_code32.s ldt.c
335 else
336 $(OBJROOT)/ldt_mach_exc_server.c:
337 $(MIG) $(CFLAGS) \
338 -user /dev/null \
339 -server $(OBJROOT)/ldt_mach_exc_server.c \
340 -header $(OBJROOT)/ldt_mach_exc.h \
341 mach_exc.defs
342
343 ldt: INVALID_ARCHS = i386
344 ldt: $(OBJROOT)/ldt_mach_exc_server.c
345 ldt: OTHER_CFLAGS += -I $(OBJROOT) $(SRCROOT)/ldt_code32.s -Wl,-pagezero_size,0x1000 -Wno-missing-variable-declarations
346 ldt: CODE_SIGN_ENTITLEMENTS=ldt_entitlement.plist
347 endif
348
349 ifneq ($(PLATFORM),BridgeOS)
350 EXCLUDED_SOURCES += remote_time.c
351 else
352 remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
353 endif
354
355 vm_phys_footprint: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
356
357 debug_control_port_for_pid: CODE_SIGN_ENTITLEMENTS = ./debug_control_port_for_pid_entitlement.plist
358
359 prng: OTHER_LDFLAGS += -ldarwintest_utils
360
361 OTHER_TEST_TARGETS += io_catalog_send_data
362
363 io_catalog_send_data: INVALID_ARCHS = i386
364 io_catalog_send_data: OTHER_CFLAGS += -DTEST_UNENTITLED -framework IOKit -framework CoreFoundation -framework Foundation
365 io_catalog_send_data: iokit/io_catalog_send_data.m
366 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
367
368 task_create_suid_cred: CODE_SIGN_ENTITLEMENTS = ./task_create_suid_cred_entitlement.plist
369
370 OTHER_TEST_TARGETS += task_create_suid_cred_unentitled
371 task_create_suid_cred_unentitled: OTHER_CFLAGS += -DUNENTITLED
372 task_create_suid_cred_unentitled: task_create_suid_cred.c
373 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
374
375 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets