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