]> git.saurik.com Git - apple/xnu.git/blob - tests/Makefile
xnu-6153.61.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 testposixshm: INVALID_ARCHS = i386
42
43 avx: INVALID_ARCHS = i386
44 avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
45 avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
46 avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
47 # Level 2 optimization must be used to prevent compiler from generating
48 # invalid instructions when compiling with AVX-512 flags.
49 avx: CONFIG_FLAGS += -O2
50 # Disable vzeroupper insertion to work around rdar://problem/35035096
51 avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
52 ifneq (osx,$(TARGET_NAME))
53 EXCLUDED_SOURCES += avx.c
54 endif
55
56 backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
57
58 data_protection: OTHER_LDFLAGS += -ldarwintest_utils -framework IOKit
59
60 immovable_send: excserver
61 immovable_send: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
62 immovable_send: OTHER_LDFLAGS += -ldarwintest_utils -lpthread -framework IOKit
63
64 CUSTOM_TARGETS += immovable_send_client
65 immovable_send: immovable_send_client
66
67 immovable_send_client: immovable_send_client.c
68 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) immovable_send_client.c -o $(SYMROOT)/immovable_send_client
69
70 install-immovable_send_client: immovable_send_client
71 mkdir -p $(INSTALLDIR)
72 cp $(SYMROOT)/immovable_send_client $(INSTALLDIR)/
73
74 kdebug: INVALID_ARCHS = i386
75 kdebug: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils -framework kperf
76
77 EXCLUDED_SOURCES += drop_priv.c kperf_helpers.c xnu_quick_test_helpers.c memorystatus_assertion_helpers.c
78
79 ifneq ($(PLATFORM),iPhoneOS)
80 EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c perf_compressor.c memorystatus_freeze_test.c
81 endif
82
83 perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
84 perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
85
86 memorystatus_freeze_test: CODE_SIGN_ENTITLEMENTS=./task_for_pid_entitlement.plist
87 memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
88 memorystatus_freeze_test: OTHER_CFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
89
90 memorystatus_is_assertion: OTHER_LDFLAGS += -ldarwintest_utils
91 memorystatus_is_assertion: OTHER_CFLAGS += memorystatus_assertion_helpers.c
92
93 shared_cache_tests: INVALID_ARCHS = i386
94 shared_cache_tests: OTHER_LDFLAGS += -ldarwintest_utils
95
96 stackshot_tests: OTHER_CFLAGS += -Wno-objc-messaging-id
97 stackshot_tests: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
98 stackshot_tests: INVALID_ARCHS = i386
99
100 stackshot_accuracy: OTHER_CFLAGS += -ldarwintest_utils -Wno-objc-messaging-id
101 stackshot_accuracy: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
102 stackshot_accuracy: INVALID_ARCHS = i386
103
104 telemetry: OTHER_LDFLAGS = -framework ktrace -framework CoreFoundation
105 telemetry: INVALID_ARCHS = i386
106
107 memorystatus_zone_test: INVALID_ARCHS = i386
108 memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
109 memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
110 memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
111
112 kpc: OTHER_LDFLAGS += -framework kperf
113
114 kperf: INVALID_ARCHS = i386
115 kperf: OTHER_CFLAGS += kperf_helpers.c
116 kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
117
118 kperf_backtracing: INVALID_ARCHS = i386
119 kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
120 kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
121 kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
122
123 kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
124 kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
125
126 mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
127
128 monotonic_core: OTHER_LDFLAGS += -framework ktrace
129 monotonic_core: INVALID_ARCHS = i386
130
131 perf_exit: perf_exit_proc
132 perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
133 perf_exit: INVALID_ARCHS = i386
134 perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
135
136 CUSTOM_TARGETS += prioritize_process_launch_helper
137 prioritize_process_launch: prioritize_process_launch_helper
138
139 prioritize_process_launch_helper: prioritize_process_launch_helper.c
140 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) prioritize_process_launch_helper.c -o $(SYMROOT)/prioritize_process_launch_helper
141 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
142 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
143
144 install-prioritize_process_launch_helper: prioritize_process_launch_helper
145 mkdir -p $(INSTALLDIR)
146 cp $(SYMROOT)/prioritize_process_launch_helper $(INSTALLDIR)/
147
148
149 perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
150
151 mach_exception_reply: OTHER_CFLAGS += -Wno-cast-align
152
153 os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
154 os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
155
156 osptr: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++98
157 osptr: OTHER_CXXFLAGS += osptr_helper.cpp
158
159 osptr_dumb: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
160
161 osptr_11: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++11
162 osptr_11: OTHER_CXXFLAGS += osptr_helper.cpp
163 osptr_11: osptr.cpp
164 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
165
166 osptr_17: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
167 osptr_17: OTHER_CXXFLAGS += osptr_helper.cpp
168 osptr_17: osptr.cpp
169 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
170
171 EXCLUDED_SOURCES += osptr_helper.cpp
172
173 os_refcnt: OTHER_CFLAGS += -I$(SRCROOT)/../libkern/ -Wno-gcc-compat -Wno-undef -O3 -flto
174
175 task_inspect: CODE_SIGN_ENTITLEMENTS = task_inspect.entitlements
176 task_inspect: OTHER_CFLAGS += -DENTITLED=1
177
178 turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
179 turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
180
181 CUSTOM_TARGETS += perf_exit_proc
182
183 perf_exit_proc:
184 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
185
186 install-perf_exit_proc: perf_exit_proc
187 mkdir -p $(INSTALLDIR)
188 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
189
190 stackshot_idle_25570396: INVALID_ARCHS = i386
191 stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
192
193 stackshot_block_owner_14362384: INVALID_ARCHS = i386
194 stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
195 ifeq ($(PLATFORM),MacOSX)
196 stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
197 endif
198
199 all: $(DSTROOT)/usr/local/bin/kcdata
200
201 $(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
202 mkdir -p $(dir $@)
203 cp $< $@
204 chmod a+x $@
205
206 xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
207
208 xnu_quick_test_entitled: CODE_SIGN_ENTITLEMENTS = xnu_quick_test.entitlements
209
210 CUSTOM_TARGETS += vm_set_max_addr_helper
211
212 vm_set_max_addr_helper: vm_set_max_addr_helper.c
213 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
214 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
215 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
216
217 install-vm_set_max_addr_helper: vm_set_max_addr_helper
218 mkdir -p $(INSTALLDIR)
219 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
220
221 ifeq ($(PLATFORM),iPhoneOS)
222 OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled vm_phys_footprint_legacy
223 jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
224 jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1
225 jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
226
227 jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
228 jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
229 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
230
231 vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
232 vm_phys_footprint_legacy: OTHER_CFLAGS += -DLEGACY_FOOTPRINT_ENTITLED=1
233 vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
234 vm_phys_footprint_legacy: vm_phys_footprint.c
235 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
236
237 endif
238
239 task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
240
241 proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
242 proc_info: OTHER_LDFLAGS += -ldarwintest_utils
243
244 proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
245
246 proc_info_44873309: CODE_SIGN_ENTITLEMENTS = ./proc_info_44873309.entitlements
247
248 disk_mount_conditioner: disk_mount_conditioner*
249 disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
250 disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
251
252 disk_mount_conditioner: OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
253 disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
254 disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
255 disk_mount_conditioner_unentitled: disk_mount_conditioner.c
256 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
257
258 work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
259 work_interval_test: OTHER_CFLAGS += -DENTITLED=1
260
261 settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
262
263 settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
264 settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
265
266 thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
267 thread_group_set_32261625: INVALID_ARCHS = i386
268
269 task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
270
271 task_vm_info_decompressions: INVALID_ARCHS = x86_64 i386
272
273 socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
274 socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
275
276 net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
277
278 ifneq (osx,$(TARGET_NAME))
279 EXCLUDED_SOURCES += no32exec_35914211.c no32exec_35914211_helper.c
280 else # target = osx
281 CUSTOM_TARGETS += no32exec_35914211_helper no32exec_35914211_helper_binprefs
282
283 no32exec_35914211_helper: INVALID_ARCHS = x86_64 i386
284 no32exec_35914211_helper:
285 $(CC) $(LDFLAGS) $(CFLAGS) -arch i386 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
286 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
287
288 install-no32exec_35914211_helper:
289 mkdir -p $(INSTALLDIR)
290 cp $(SYMROOT)/no32exec_35914211_helper $(INSTALLDIR)/
291
292 no32exec_35914211_helper_binprefs: INVALID_ARCHS = x86_64 i386
293 no32exec_35914211_helper_binprefs:
294 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) -arch i386 -arch x86_64 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
295 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
296
297 install-no32exec_35914211_helper_binprefs:
298 mkdir -p $(INSTALLDIR)
299 cp $(SYMROOT)/no32exec_35914211_helper_binprefs $(INSTALLDIR)/
300
301 no32exec_35914211: INVALID_ARCHS = i386
302 no32exec_35914211: no32exec_35914211_helper
303 no32exec_35914211: no32exec_35914211_helper_binprefs
304 endif # (osx,$(TARGET_NAME)))
305
306 MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
307
308 CUSTOM_TARGETS += excserver
309
310 excserver:
311 $(MIG) $(CFLAGS) \
312 -sheader $(OBJROOT)/excserver.h \
313 -server $(OBJROOT)/excserver.c \
314 -header /dev/null -user /dev/null \
315 excserver.defs
316 install-excserver: ;
317
318 exc_resource_threads: excserver
319 exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
320
321 fp_exception: excserver
322 fp_exception: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
323
324 ifneq (osx,$(TARGET_NAME))
325 EXCLUDED_SOURCES += ldt_code32.s ldt.c
326 else
327 $(OBJROOT)/ldt_mach_exc_server.c:
328 $(MIG) $(CFLAGS) \
329 -user /dev/null \
330 -server $(OBJROOT)/ldt_mach_exc_server.c \
331 -header $(OBJROOT)/ldt_mach_exc.h \
332 mach_exc.defs
333
334 ldt: INVALID_ARCHS = i386
335 ldt: $(OBJROOT)/ldt_mach_exc_server.c
336 ldt: OTHER_CFLAGS += -I $(OBJROOT) $(SRCROOT)/ldt_code32.s -Wl,-pagezero_size,0x1000 -Wno-missing-variable-declarations
337 ldt: CODE_SIGN_ENTITLEMENTS=ldt_entitlement.plist
338 endif
339
340 ifneq ($(PLATFORM),BridgeOS)
341 EXCLUDED_SOURCES += remote_time.c
342 else
343 remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
344 endif
345
346 vm_phys_footprint: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
347
348 debug_control_port_for_pid: CODE_SIGN_ENTITLEMENTS = ./debug_control_port_for_pid_entitlement.plist
349
350 prng: OTHER_LDFLAGS += -ldarwintest_utils
351
352 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets