]> git.saurik.com Git - apple/xnu.git/blame - tests/Makefile
xnu-6153.41.3.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
0a7de745 100telemetry: OTHER_LDFLAGS = -framework ktrace -framework CoreFoundation
d9a64523
A
101telemetry: INVALID_ARCHS = i386
102
5ba3f43e
A
103memorystatus_zone_test: INVALID_ARCHS = i386
104memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
105memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
106memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
107
108kpc: OTHER_LDFLAGS += -framework kperf
813fb2f6 109
39037602
A
110kperf: INVALID_ARCHS = i386
111kperf: OTHER_CFLAGS += kperf_helpers.c
5ba3f43e 112kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
39037602
A
113
114kperf_backtracing: INVALID_ARCHS = i386
115kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
5ba3f43e 116kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
39037602
A
117kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
118
5ba3f43e
A
119kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
120kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
121
39037602
A
122mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
123
5ba3f43e
A
124monotonic_core: OTHER_LDFLAGS += -framework ktrace
125monotonic_core: INVALID_ARCHS = i386
126
d9a64523 127perf_exit: perf_exit_proc
0a7de745 128perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
39037602 129perf_exit: INVALID_ARCHS = i386
5ba3f43e
A
130perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
131
cb323159
A
132CUSTOM_TARGETS += prioritize_process_launch_helper
133prioritize_process_launch: prioritize_process_launch_helper
134
135prioritize_process_launch_helper: prioritize_process_launch_helper.c
136 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) prioritize_process_launch_helper.c -o $(SYMROOT)/prioritize_process_launch_helper
137 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
138 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
139
140install-prioritize_process_launch_helper: prioritize_process_launch_helper
141 mkdir -p $(INSTALLDIR)
142 cp $(SYMROOT)/prioritize_process_launch_helper $(INSTALLDIR)/
143
144
5ba3f43e
A
145perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
146
cb323159
A
147mach_exception_reply: OTHER_CFLAGS += -Wno-cast-align
148
5ba3f43e
A
149os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
150os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
39037602 151
cb323159
A
152osptr: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++98
153osptr: OTHER_CXXFLAGS += osptr_helper.cpp
154
155osptr_dumb: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
156
157osptr_11: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++11
158osptr_11: OTHER_CXXFLAGS += osptr_helper.cpp
159osptr_11: osptr.cpp
160 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
161
162osptr_17: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17
163osptr_17: OTHER_CXXFLAGS += osptr_helper.cpp
164osptr_17: osptr.cpp
165 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
166
167EXCLUDED_SOURCES += osptr_helper.cpp
168
169os_refcnt: OTHER_CFLAGS += -I$(SRCROOT)/../libkern/ -Wno-gcc-compat -Wno-undef -O3 -flto
170
813fb2f6
A
171task_inspect: CODE_SIGN_ENTITLEMENTS = task_inspect.entitlements
172task_inspect: OTHER_CFLAGS += -DENTITLED=1
173
d9a64523
A
174turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
175turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
176
813fb2f6
A
177CUSTOM_TARGETS += perf_exit_proc
178
179perf_exit_proc:
180 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
181
182install-perf_exit_proc: perf_exit_proc
183 mkdir -p $(INSTALLDIR)
184 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
185
39037602
A
186stackshot_idle_25570396: INVALID_ARCHS = i386
187stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
188
813fb2f6
A
189stackshot_block_owner_14362384: INVALID_ARCHS = i386
190stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
a39ff7e2
A
191ifeq ($(PLATFORM),MacOSX)
192stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
193endif
194
195all: $(DSTROOT)/usr/local/bin/kcdata
196
d9a64523 197$(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
a39ff7e2
A
198 mkdir -p $(dir $@)
199 cp $< $@
200 chmod a+x $@
813fb2f6 201
5ba3f43e 202xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
a39ff7e2 203
d9a64523
A
204xnu_quick_test_entitled: CODE_SIGN_ENTITLEMENTS = xnu_quick_test.entitlements
205
206CUSTOM_TARGETS += vm_set_max_addr_helper
207
208vm_set_max_addr_helper: vm_set_max_addr_helper.c
209 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
210 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
211 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
212
213install-vm_set_max_addr_helper: vm_set_max_addr_helper
214 mkdir -p $(INSTALLDIR)
215 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
216
813fb2f6 217ifeq ($(PLATFORM),iPhoneOS)
cb323159 218OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled vm_phys_footprint_legacy
813fb2f6
A
219jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
220jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1
221jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
222
223jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
224jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
225 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
cb323159
A
226
227vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
228vm_phys_footprint_legacy: OTHER_CFLAGS += -DLEGACY_FOOTPRINT_ENTITLED=1
229vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
230vm_phys_footprint_legacy: vm_phys_footprint.c
231 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
232
813fb2f6
A
233endif
234
5ba3f43e
A
235task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
236
a39ff7e2
A
237proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
238proc_info: OTHER_LDFLAGS += -ldarwintest_utils
239
d9a64523
A
240proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
241
cb323159
A
242proc_info_44873309: CODE_SIGN_ENTITLEMENTS = ./proc_info_44873309.entitlements
243
5ba3f43e
A
244disk_mount_conditioner: disk_mount_conditioner*
245disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
246disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
247
cb323159 248disk_mount_conditioner: OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
5ba3f43e
A
249disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
250disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
251disk_mount_conditioner_unentitled: disk_mount_conditioner.c
252 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
253
254work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
255work_interval_test: OTHER_CFLAGS += -DENTITLED=1
256
a39ff7e2
A
257settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
258
5ba3f43e 259settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
a39ff7e2
A
260settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
261
5ba3f43e
A
262thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
263thread_group_set_32261625: INVALID_ARCHS = i386
264
265task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
266
cb323159
A
267task_vm_info_decompressions: INVALID_ARCHS = x86_64 i386
268
a39ff7e2
A
269socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
270socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
271
d9a64523
A
272net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
273
a39ff7e2
A
274ifneq (osx,$(TARGET_NAME))
275EXCLUDED_SOURCES += no32exec_35914211.c no32exec_35914211_helper.c
94ff46dc
A
276else # target = osx
277CUSTOM_TARGETS += no32exec_35914211_helper no32exec_35914211_helper_binprefs
278
279no32exec_35914211_helper: INVALID_ARCHS = x86_64 i386
280no32exec_35914211_helper:
281 $(CC) $(LDFLAGS) $(CFLAGS) -arch i386 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
282 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
283
284install-no32exec_35914211_helper:
285 mkdir -p $(INSTALLDIR)
286 cp $(SYMROOT)/no32exec_35914211_helper $(INSTALLDIR)/
a39ff7e2 287
94ff46dc 288no32exec_35914211_helper_binprefs: INVALID_ARCHS = x86_64 i386
cb323159 289no32exec_35914211_helper_binprefs:
94ff46dc
A
290 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) -arch i386 -arch x86_64 no32exec_35914211_helper.c -o $(SYMROOT)/$@;
291 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
292
293install-no32exec_35914211_helper_binprefs:
294 mkdir -p $(INSTALLDIR)
295 cp $(SYMROOT)/no32exec_35914211_helper_binprefs $(INSTALLDIR)/
cb323159
A
296
297no32exec_35914211: INVALID_ARCHS = i386
298no32exec_35914211: no32exec_35914211_helper
299no32exec_35914211: no32exec_35914211_helper_binprefs
94ff46dc 300endif # (osx,$(TARGET_NAME)))
a39ff7e2 301
d9a64523
A
302MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
303
304CUSTOM_TARGETS += excserver
305
306excserver:
307 $(MIG) $(CFLAGS) \
308 -sheader $(OBJROOT)/excserver.h \
309 -server $(OBJROOT)/excserver.c \
310 -header /dev/null -user /dev/null \
311 excserver.defs
312install-excserver: ;
313
314exc_resource_threads: excserver
315exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
316
cb323159
A
317fp_exception: excserver
318fp_exception: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
319
0a7de745
A
320ifneq (osx,$(TARGET_NAME))
321EXCLUDED_SOURCES += ldt_code32.s ldt.c
322else
323$(OBJROOT)/ldt_mach_exc_server.c:
324 $(MIG) $(CFLAGS) \
325 -user /dev/null \
326 -server $(OBJROOT)/ldt_mach_exc_server.c \
327 -header $(OBJROOT)/ldt_mach_exc.h \
328 mach_exc.defs
329
330ldt: INVALID_ARCHS = i386
331ldt: $(OBJROOT)/ldt_mach_exc_server.c
cb323159
A
332ldt: OTHER_CFLAGS += -I $(OBJROOT) $(SRCROOT)/ldt_code32.s -Wl,-pagezero_size,0x1000 -Wno-missing-variable-declarations
333ldt: CODE_SIGN_ENTITLEMENTS=ldt_entitlement.plist
0a7de745
A
334endif
335
d26ffc64
A
336ifneq ($(PLATFORM),BridgeOS)
337EXCLUDED_SOURCES += remote_time.c
338else
339remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
340endif
341
0a7de745 342vm_phys_footprint: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
cb323159
A
343
344debug_control_port_for_pid: CODE_SIGN_ENTITLEMENTS = ./debug_control_port_for_pid_entitlement.plist
345
346prng: OTHER_LDFLAGS += -ldarwintest_utils
0a7de745 347
39037602 348include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets