1 PROJECT := xnu/darwintests
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.
6 override DSTROOT = $(BASEDSTROOT)
12 OTHER_LTE_INCLUDE_FILES += \
13 /System/Library/PrivateFrameworks/LoggingSupport.framework, \
14 /System/Library/PrivateFrameworks/MobileKeyBag.framework, \
15 /System/Library/Frameworks/IOSurface.framework, \
16 /usr/local/lib/libdarwintest_utils.dylib, \
17 /usr/lib/libapple_crypto.dylib,
19 DEVELOPER_DIR ?= $(shell xcode-select -p)
21 # the xnu build system will only ever call us with the default target
22 .DEFAULT_GOAL := install
24 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
26 OTHER_CFLAGS = -Weverything -Wno-gnu-union-cast -Wno-missing-field-initializers -Wno-partial-availability
27 OTHER_CFLAGS += -Wno-missing-noreturn -Wno-vla -Wno-reserved-id-macro -Wno-documentation-unknown-command
28 OTHER_CFLAGS += -Wno-padded -Wno-used-but-marked-unused -Wno-covered-switch-default -Wno-nullability-extension
29 OTHER_CFLAGS += -Wno-gnu-empty-initializer -Wno-unused-macros -Wno-undef -Wno-fixed-enum-extension
30 OTHER_CFLAGS += -Wno-gnu-auto-type -Wno-switch-enum -Wno-variadic-macros
31 OTHER_CFLAGS += --std=gnu11 -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
32 OTHER_CFLAGS += -UT_NAMESPACE_PREFIX -DT_NAMESPACE_PREFIX=xnu
33 OTHER_CFLAGS += -F $(SDKROOT)/System/Library/PrivateFrameworks
35 OTHER_CFLAGS += -Wl,-sectcreate,__INFO_FILTER,__disable,/dev/null
38 CODESIGN:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign)
39 CODESIGN_HARDENED_RUNTIME:=$(CODESIGN) -o runtime
40 CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign_allocate)
42 # to have custom compiler flags to
43 # target: OTHER_CFLAGS += <my flags>
45 atm_diagnostic_flag: OTHER_CFLAGS += drop_priv.c
47 atm_diagnostic_flag_entitled: CODE_SIGN_ENTITLEMENTS = atm_diagnostic_flag.entitlements
48 atm_diagnostic_flag_entitled: OTHER_CFLAGS += drop_priv.c
50 avx: INVALID_ARCHS = $(filter arm%,$(ARCH_CONFIGS))
51 avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
52 avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
53 avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
54 # Level 2 optimization must be used to prevent compiler from generating
55 # invalid instructions when compiling with AVX-512 flags.
56 avx: CONFIG_FLAGS += -O2
57 # Disable vzeroupper insertion to work around rdar://problem/35035096
58 avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
59 ifneq (osx,$(TARGET_NAME))
60 EXCLUDED_SOURCES += avx.c
63 CUSTOM_TARGETS = sr_entitlement_helper
65 sr_entitlement_helper: sr_entitlement_helper.c
67 $(CC) -I $(OBJROOT) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) sr_entitlement_helper.c -o $(SYMROOT)/$@
68 echo $(CODESIGN) --force --sign - --timestamp=none --entitlements sr_entitlement.entitlements $(SYMROOT)/$@; \
69 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements sr_entitlement.entitlements $(SYMROOT)/$@;
71 install-sr_entitlement_helper: sr_entitlement_helper
72 mkdir -p $(INSTALLDIR)
73 cp $(SYMROOT)/sr_entitlement_helper $(INSTALLDIR)
75 sr_entitlement: OTHER_LDFLAGS += -ldarwintest_utils
77 restrict_jit: CODE_SIGN_ENTITLEMENTS = restrict_jit.entitlements
79 backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
80 backtracing: CODE_SIGN_ENTITLEMENTS = kernel_symbolication_entitlements.plist
82 data_protection: OTHER_LDFLAGS += -ldarwintest_utils -framework IOKit
84 CUSTOM_TARGETS += immovable_send_client vm_spawn_tool
86 exception_tests: excserver exc_helpers.c
87 exception_tests: CODE_SIGN_ENTITLEMENTS = exception_tests.entitlements
88 exception_tests: OTHER_CFLAGS += $(OBJROOT)/excserver.c
89 exception_tests: OTHER_CFLAGS += -I $(OBJROOT)
90 exception_tests: OTHER_CFLAGS += -DENTITLED=1
92 immovable_send: excserver
93 immovable_send: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
94 immovable_send: OTHER_LDFLAGS += -ldarwintest_utils -lpthread -framework IOKit
95 immovable_send: immovable_send_client
97 immovable_send_client: immovable_send_client.c
98 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) immovable_send_client.c -o $(SYMROOT)/immovable_send_client
100 install-immovable_send_client: immovable_send_client
101 mkdir -p $(INSTALLDIR)
102 cp $(SYMROOT)/immovable_send_client $(INSTALLDIR)/
104 vm_spawn_tool: INVALID_ARCHS = i386
105 vm_spawn_tool: vm_spawn_tool.c
106 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_spawn_tool.c -o $(SYMROOT)/vm_spawn_tool
108 install-vm_spawn_tool: vm_spawn_tool
109 mkdir -p $(INSTALLDIR)/tools
110 cp $(SYMROOT)/vm_spawn_tool $(INSTALLDIR)/tools/
112 CUSTOM_TARGETS += imm_pinned_control_port_crasher
114 imm_pinned_control_port: excserver
115 imm_pinned_control_port: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
116 imm_pinned_control_port: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
117 imm_pinned_control_port: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
118 imm_pinned_control_port: imm_pinned_control_port_crasher
120 imm_pinned_control_port_crasher: imm_pinned_control_port_crasher.c
121 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) imm_pinned_control_port_crasher.c -o $(SYMROOT)/imm_pinned_control_port_crasher
122 $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
124 install-imm_pinned_control_port_crasher: imm_pinned_control_port_crasher
125 mkdir -p $(INSTALLDIR)
126 cp $(SYMROOT)/imm_pinned_control_port_crasher $(INSTALLDIR)/
128 kas_info: OTHER_LDFLAGS += -framework CoreSymbolication
129 kas_info: CODE_SIGN_ENTITLEMENTS = kernel_symbolication_entitlements.plist
131 kdebug: INVALID_ARCHS = i386
132 kdebug: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils -framework kperf
133 kdebug: OTHER_CFLAGS += test_utils.c
135 EXCLUDED_SOURCES += drop_priv.c kperf_helpers.c xnu_quick_test_helpers.c memorystatus_assertion_helpers.c bpflib.c in_cksum.c test_utils.c
137 ifneq ($(PLATFORM),iPhoneOS)
138 EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c perf_compressor.c memorystatus_freeze_test.c vm/entitlement_increased_memory_limit.c
141 perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
142 perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
145 memorystatus_freeze_test: CODE_SIGN_ENTITLEMENTS=./task_for_pid_entitlement.plist
146 memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
147 memorystatus_freeze_test: OTHER_CFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
149 memorystatus_is_assertion: OTHER_LDFLAGS += -ldarwintest_utils
150 memorystatus_is_assertion: OTHER_CFLAGS += memorystatus_assertion_helpers.c
152 memorystatus_vm_map_fork: OTHER_CFLAGS += test_utils.c
154 shared_cache_tests: OTHER_LDFLAGS += -ldarwintest_utils
156 stackshot_tests: OTHER_CFLAGS += -Wno-objc-messaging-id
157 stackshot_tests: OTHER_LDFLAGS += -lkdd -lz -ldarwintest_utils -framework Foundation
159 stackshot_accuracy: OTHER_CFLAGS += -ldarwintest_utils -Wno-objc-messaging-id
160 stackshot_accuracy: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
161 stackshot_accuracy: INVALID_ARCHS = i386
163 ifeq ($(PLATFORM),MacOSX)
164 CUSTOM_TARGETS += stackshot_translated_child
166 stackshot_translated_child: INVALID_ARCHS = arm64 arm64e
167 stackshot_translated_child: stackshot_translated_child.c
168 $(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) stackshot_translated_child.c -o $(SYMROOT)/stackshot_translated_child
170 install-stackshot_translated_child: stackshot_translated_child
171 mkdir -p $(INSTALLDIR)
172 cp $(SYMROOT)/stackshot_translated_child $(INSTALLDIR)/
174 EXCLUDED_SOURCES += stackshot_translated_child.c
177 telemetry: OTHER_LDFLAGS = -framework ktrace -framework kperf -framework CoreFoundation
179 memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
180 memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
181 memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
183 ifeq ($(PLATFORM),BridgeOS)
184 EXCLUDED_SOURCES += dirtiness_tracking.c
187 dirtiness_tracking: OTHER_CFLAGS += -Wno-cast-align
189 kpc: OTHER_LDFLAGS += -framework kperf -framework ktrace
190 kpc: INVALID_ARCHS = i386
192 kperf: OTHER_CFLAGS += kperf_helpers.c
193 kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
195 memcmp_zero: OTHER_CFLAGS += ../osfmk/arm64/memcmp_zero.s
197 kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
198 kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
199 kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
200 kperf_backtracing: CODE_SIGN_ENTITLEMENTS = kernel_symbolication_entitlements.plist
202 text_corruption: OTHER_LDFLAGS += -ldarwintest_utils
203 CUSTOM_TARGETS += text_corruption_helper
205 text_corruption_helper:
206 $(CC) $(LDFLAGS) $(CFLAGS) text_corruption_helper.c -lm -o $(SYMROOT)/$@;
207 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
209 install-text_corruption_helper:
210 mkdir -p $(INSTALLDIR)
211 cp $(SYMROOT)/text_corruption_helper $(INSTALLDIR)/
213 kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
214 kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
216 mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
218 monotonic_core: OTHER_LDFLAGS += -framework ktrace
220 perf_exit: perf_exit_proc
221 perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
222 perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
224 CUSTOM_TARGETS += prioritize_process_launch_helper
225 prioritize_process_launch: prioritize_process_launch_helper
227 prioritize_process_launch_helper: prioritize_process_launch_helper.c
228 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) prioritize_process_launch_helper.c -o $(SYMROOT)/prioritize_process_launch_helper
229 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
230 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
232 install-prioritize_process_launch_helper: prioritize_process_launch_helper
233 mkdir -p $(INSTALLDIR)
234 cp $(SYMROOT)/prioritize_process_launch_helper $(INSTALLDIR)/
237 perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
239 mach_exception_reply: OTHER_CFLAGS += -Wno-cast-align
241 os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
242 os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
244 subsystem_root_path: subsystem_root_path.c subsystem_root_path-entitlements.plist
245 subsystem_root_path: CODE_SIGN_ENTITLEMENTS=subsystem_root_path-entitlements.plist
247 EXCLUDED_SOURCES += $(wildcard bounded_ptr_src/*.cpp)
248 bounded_ptr: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
249 bounded_ptr: $(wildcard bounded_ptr_src/*.cpp) bounded_ptr.cpp
251 EXCLUDED_SOURCES += bounded_ptr_03.cpp
252 bounded_ptr_03: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++03
253 bounded_ptr_03: bounded_ptr_03.cpp
255 EXCLUDED_SOURCES += $(wildcard bounded_array_src/*.cpp)
256 bounded_array: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
257 bounded_array: $(wildcard bounded_array_src/*.cpp) bounded_array.cpp
259 EXCLUDED_SOURCES += $(wildcard bounded_array_ref_src/*.cpp)
260 bounded_array_ref: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
261 bounded_array_ref: $(wildcard bounded_array_ref_src/*.cpp) bounded_array_ref.cpp
263 EXCLUDED_SOURCES += $(wildcard intrusive_shared_ptr_src/*.cpp)
264 intrusive_shared_ptr: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
265 intrusive_shared_ptr: $(wildcard intrusive_shared_ptr_src/*.cpp) intrusive_shared_ptr.cpp
267 EXCLUDED_SOURCES += $(wildcard safe_allocation_src/*.cpp)
268 safe_allocation: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
269 safe_allocation: $(wildcard safe_allocation_src/*.cpp) safe_allocation.cpp
271 EXCLUDED_SOURCES += osptr_compat.cpp
272 osptr_98: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++98 -DOSPTR_STD="98"
273 osptr_98: osptr_compat.cpp
274 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
275 osptr_11: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++11 -DOSPTR_STD="11"
276 osptr_11: osptr_compat.cpp
277 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
278 osptr_14: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++14 -DOSPTR_STD="14"
279 osptr_14: osptr_compat.cpp
280 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
281 osptr_17: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17 -DOSPTR_STD="17"
282 osptr_17: osptr_compat.cpp
283 $(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
285 priority_queue: OTHER_CXXFLAGS += -std=c++17
286 zalloc_buddy: OTHER_CFLAGS += -Wno-format-pedantic
288 os_refcnt: OTHER_CFLAGS += -I$(SRCROOT)/../libkern/ -Wno-gcc-compat -Wno-undef -O3 -flto
290 kernel_inspection: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
291 kernel_inspection: OTHER_CFLAGS += -DENTITLED=1
293 turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
294 turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
296 CUSTOM_TARGETS += perf_exit_proc
299 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
301 install-perf_exit_proc: perf_exit_proc
302 mkdir -p $(INSTALLDIR)
303 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
305 stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
307 stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
308 ifeq ($(PLATFORM),MacOSX)
309 stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
312 all: $(DSTROOT)/usr/local/bin/kcdata
314 $(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
319 xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
321 CUSTOM_TARGETS += vm_set_max_addr_helper
323 vm_set_max_addr_helper: vm_set_max_addr_helper.c
324 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
325 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
326 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
328 install-vm_set_max_addr_helper: vm_set_max_addr_helper
329 mkdir -p $(INSTALLDIR)
330 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
332 CUSTOM_TARGETS += subsystem_root_path_helper_entitled
333 CUSTOM_TARGETS += subsystem_root_path_helper
335 subsystem_root_path_helper_entitled: subsystem_root_path_helper.c subsystem_root_path-entitlements.plist
336 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) subsystem_root_path_helper.c -o $(SYMROOT)/subsystem_root_path_helper_entitled; \
337 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
338 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements subsystem_root_path-entitlements.plist $(SYMROOT)/$@;
340 install-subsystem_root_path_helper_entitled: subsystem_root_path_helper_entitled
341 mkdir -p $(INSTALLDIR)
342 cp $(SYMROOT)/subsystem_root_path_helper_entitled $(INSTALLDIR)/
344 subsystem_root_path_helper: subsystem_root_path_helper.c
345 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) subsystem_root_path_helper.c -o $(SYMROOT)/subsystem_root_path_helper; \
346 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
347 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
349 install-subsystem_root_path_helper: subsystem_root_path_helper
350 mkdir -p $(INSTALLDIR)
351 cp $(SYMROOT)/subsystem_root_path_helper $(INSTALLDIR)/
353 CUSTOM_TARGETS += vm_test_code_signing_helper
355 vm_test_code_signing_helper: vm_test_code_signing_helper.c
356 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_test_code_signing_helper.c -o $(SYMROOT)/vm_test_code_signing_helper; \
357 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
358 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
360 install-vm_test_code_signing_helper: vm_test_code_signing_helper
361 mkdir -p $(INSTALLDIR)
362 cp $(SYMROOT)/vm_test_code_signing_helper $(INSTALLDIR)/
364 vm_test_code_signing: OTHER_LDFLAGS += -ldarwintest_utils
366 INCLUDED_TEST_SOURCE_DIRS += vm
368 # Revert to legacy vm_test suite until <rdar://problem/56675212> gets solved
369 EXCLUDED_SOURCES += vm/vm_allocation.c
371 ifeq ($(PLATFORM),iPhoneOS)
372 OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled jumbo_va_spaces_52551256 vm_phys_footprint_legacy vm/entitlement_increased_memory_limit vm/entitlement_increased_memory_limit_unentitled
373 jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
374 jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1 -DTESTNAME=jumbo_va_spaces_28530648
375 jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
377 jumbo_va_spaces_52551256: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_52551256.entitlements
378 jumbo_va_spaces_52551256: OTHER_CFLAGS += -DENTITLED=1 -DTESTNAME=jumbo_va_spaces_52551256
379 jumbo_va_spaces_52551256: OTHER_LDFLAGS += -ldarwintest_utils
380 jumbo_va_spaces_52551256: jumbo_va_spaces_28530648.c
381 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
382 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
384 jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
385 jumbo_va_spaces_28530648_unentitled: OTHER_CFLAGS += -DTESTNAME=jumbo_va_spaces_28530648_unentitled
386 jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
387 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
389 vm/entitlement_increased_memory_limit: CODE_SIGN_ENTITLEMENTS = vm/entitlement_increased_memory_limit.entitlements
390 vm/entitlement_increased_memory_limit: OTHER_CFLAGS += -DENTITLED=1
391 vm/entitlement_increased_memory_limit: OTHER_LDFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
392 vm/entitlement_increased_memory_limit: vm/entitlement_increased_memory_limit.c
393 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
394 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
396 vm/entitlement_increased_memory_limit_unentitled: OTHER_LDFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
397 vm/entitlement_increased_memory_limit_unentitled: vm/entitlement_increased_memory_limit.c
398 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
400 vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
401 vm_phys_footprint_legacy: OTHER_CFLAGS += -DLEGACY_FOOTPRINT_ENTITLED=1
402 vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
403 vm_phys_footprint_legacy: vm_phys_footprint.c
404 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
408 task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
410 read_inspect: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
412 proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
413 proc_info: OTHER_LDFLAGS += -ldarwintest_utils
415 proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
417 proc_info_44873309: CODE_SIGN_ENTITLEMENTS = ./proc_info_44873309.entitlements
419 disk_mount_conditioner: disk_mount_conditioner*
420 disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
421 disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
423 disk_mount_conditioner: OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
424 disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
425 disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
426 disk_mount_conditioner_unentitled: disk_mount_conditioner.c
427 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
429 work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
430 work_interval_test: OTHER_CFLAGS += -DENTITLED=1
432 settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
434 settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
435 settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
437 thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
439 task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
440 task_info: OTHER_CFLAGS += test_utils.c
442 extract_right_soft_fail: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
444 ifneq ($(PLATFORM),iPhoneOS)
445 EXCLUDED_SOURCES += task_vm_info_decompressions.c
448 socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
449 socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
451 net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
453 net_bridge: OTHER_CFLAGS += bpflib.c in_cksum.c
454 net_bridge: OTHER_LDFLAGS += -ldarwintest_utils
456 CUSTOM_TARGETS += posix_spawn_archpref_helper
458 posix_spawn_archpref_helper:
459 $(CC) $(LDFLAGS) $(CFLAGS) posix_spawn_archpref_helper.c -o $(SYMROOT)/$@;
460 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
462 install-posix_spawn_archpref_helper:
463 mkdir -p $(INSTALLDIR)
464 cp $(SYMROOT)/posix_spawn_archpref_helper $(INSTALLDIR)/
466 MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
468 CUSTOM_TARGETS += excserver
472 -sheader $(OBJROOT)/excserver.h \
473 -server $(OBJROOT)/excserver.c \
474 -header /dev/null -user /dev/null \
478 EXCLUDED_SOURCES += exc_helpers.c
481 x18: OTHER_CFLAGS += -Wno-language-extension-token
483 exc_resource_threads: excserver
484 exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
486 fp_exception: excserver exc_helpers.c
487 fp_exception: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
489 ptrauth_failure: excserver exc_helpers.c
490 ptrauth_failure: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT) -Wno-language-extension-token
491 ptrauth_failure: CODESIGN = $(CODESIGN_HARDENED_RUNTIME)
493 # This test currently relies on pid_hibernate(), which is only available on embedded platforms.
494 ifeq ($(PLATFORM),MacOSX)
495 EXCLUDED_SOURCES += decompression_failure.c
497 decompression_failure: excserver exc_helpers.c
498 decompression_failure: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
501 ifeq ($(findstring x86_64,$(ARCH_CONFIGS)),)
502 EXCLUDED_SOURCES += ldt_code32.s ldt.c
504 $(OBJROOT)/ldt_mach_exc_server.c:
507 -server $(OBJROOT)/ldt_mach_exc_server.c \
508 -header $(OBJROOT)/ldt_mach_exc.h \
511 ldt: INVALID_ARCHS = $(ARCH_CONFIGS)
512 ldt: $(OBJROOT)/ldt_mach_exc_server.c
513 ldt: OTHER_CFLAGS += -arch x86_64 -I $(OBJROOT) $(SRCROOT)/ldt_code32.s -Wl,-pagezero_size,0x1000 -Wno-missing-variable-declarations
514 ldt: CODE_SIGN_ENTITLEMENTS=ldt_entitlement.plist
517 ifneq ($(PLATFORM),BridgeOS)
518 EXCLUDED_SOURCES += remote_time.c
520 remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
523 vm_phys_footprint: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
525 vm_kern_count_wired_kernelcache: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders/mach
527 debug_control_port_for_pid: CODE_SIGN_ENTITLEMENTS = ./debug_control_port_for_pid_entitlement.plist
529 prng: OTHER_LDFLAGS += -ldarwintest_utils
531 preoslog: OTHER_LDFLAGS += -ldarwintest_utils
532 preoslog: OTHER_CFLAGS += test_utils.c
534 task_policy: CODE_SIGN_ENTITLEMENTS = ./task_policy_entitlement.plist
536 OTHER_TEST_TARGETS += task_policy_unentitled
537 task_policy_unentitled: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
538 task_policy_unentitled: OTHER_CFLAGS += -DUNENTITLED
539 task_policy_unentitled: task_policy.c
540 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
541 $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@
544 EXCLUDED_SOURCES += get_shared_cache_address.c
545 ifeq ($(PLATFORM),iPhoneOS)
546 CUSTOM_TARGETS += get_shared_cache_address
547 get_shared_cache_address: INVALID_ARCHS = arm64
548 get_shared_cache_address: get_shared_cache_address.c
549 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/get_shared_cache_address
551 install-get_shared_cache_address: get_shared_cache_address
552 $(CODESIGN) --force --sign - --timestamp=none --identifier=com.apple.get_shared_cache_address $(SYMROOT)/get_shared_cache_address
553 mkdir -p $(INSTALLDIR)
554 cp $(SYMROOT)/get_shared_cache_address $(INSTALLDIR)/
557 ifneq ($(PLATFORM),MacOSX)
558 EXCLUDED_SOURCES += hvtest_x86.m hvtest_x86_guest.c hvtest_x86_asm.s
560 EXCLUDED_SOURCES += hvtest_x86_guest.c hvtest_x86_asm.s
561 hvtest_x86: CODE_SIGN_ENTITLEMENTS = hv_public.entitlements
562 hvtest_x86: INVALID_ARCHS += arm64e arm64 i386
563 hvtest_x86: OTHER_CFLAGS += hvtest_x86_guest.c hvtest_x86_asm.s -framework Hypervisor -framework Foundation
566 OTHER_TEST_TARGETS += io_catalog_send_data vm_memory_share_tests
568 vm_memory_share_tests: INVALID_ARCHS = i386
569 vm_memory_share_tests: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
570 vm_memory_share_tests: vm_memory_tests_src/main.c vm_memory_tests_src/common.c vm_memory_tests_src/vm_tests.c
571 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
572 echo $(CODESIGN) --force --sign - --timestamp=none --entitlements $(SRCROOT)/$(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
573 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements "$(SRCROOT)/$(CODE_SIGN_ENTITLEMENTS)" $(SYMROOT)/$@;
575 # build the mach server as individual helper which does not use libdarwintest
576 CUSTOM_TARGETS += vm_memory_share_tests_server
577 vm_memory_share_tests_server: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
578 vm_memory_share_tests_server: vm_memory_tests_src/server.c vm_memory_tests_src/common.c vm_memory_tests_src/vm_tests.c
579 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/vm_memory_share_tests_server
580 echo $(CODESIGN) --force --sign - --timestamp=none --entitlements $(SRCROOT)/$(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
581 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements "$(SRCROOT)/$(CODE_SIGN_ENTITLEMENTS)" $(SYMROOT)/$@;
583 install-vm_memory_share_tests_server: vm_memory_share_tests_server
584 mkdir -p $(INSTALLDIR)
585 cp $(SYMROOT)/vm_memory_share_tests_server $(INSTALLDIR)/
587 io_catalog_send_data: INVALID_ARCHS = i386
588 io_catalog_send_data: OTHER_CFLAGS += -DTEST_UNENTITLED -framework IOKit -framework CoreFoundation -framework Foundation
590 io_catalog_send_data: iokit/io_catalog_send_data.m
591 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
593 ifeq ($(PLATFORM),MacOSX)
594 EXCLUDED_SOURCES += vm/kern_max_task_pmem.c
597 EXCLUDED_SOURCES += benchmark/helpers.c
599 perf_vmfault: OTHER_CFLAGS += benchmark/helpers.c
601 fault_throughput: vm/fault_throughput.c
602 mkdir -p $(SYMROOT)/vm
603 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/vm/$@
604 fault_throughput: OTHER_CFLAGS += benchmark/helpers.c
606 install-fault_throughput: fault_throughput
607 mkdir -p $(INSTALLDIR)/vm
608 cp $(SYMROOT)/vm/fault_throughput $(INSTALLDIR)/vm/
610 BATS_PLISTS += $(SRCROOT)/vm/fault_throughput.plist
612 fault_throughput_benchrun:
613 mkdir -p $(SYMROOT)/vm
614 cp $(SRCROOT)/vm/fault_throughput.lua $(SYMROOT)/vm/fault_throughput.lua
615 chmod +x $(SYMROOT)/vm/fault_throughput.lua
617 install-fault_throughput_benchrun: fault_throughput_benchrun
618 mkdir -p $(INSTALLDIR)/vm
619 cp $(SYMROOT)/vm/fault_throughput.lua $(INSTALLDIR)/vm
620 chmod +x $(INSTALLDIR)/vm/fault_throughput.lua
622 CUSTOM_TARGETS += fault_throughput fault_throughput_benchrun
623 EXCLUDED_SOURCES += vm/fault_throughput.plist vm/fault_throughput.c
625 perf_madvise: vm/perf_madvise.c
626 mkdir -p $(SYMROOT)/vm
627 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/vm/$@
628 perf_madvise: OTHER_CFLAGS += benchmark/helpers.c
629 install-perf_madvise: perf_madvise
630 mkdir -p $(INSTALLDIR)/vm
631 cp $(SYMROOT)/vm/perf_madvise $(INSTALLDIR)/vm/
632 perf_madvise_benchrun:
633 mkdir -p $(SYMROOT)/vm
634 cp $(SRCROOT)/vm/perf_madvise.lua $(SYMROOT)/vm/perf_madvise.lua
635 chmod +x $(SYMROOT)/vm/perf_madvise.lua
636 install-perf_madvise_benchrun: perf_madvise_benchrun
637 mkdir -p $(INSTALLDIR)/vm
638 cp $(SYMROOT)/vm/perf_madvise.lua $(INSTALLDIR)/vm
639 chmod +x $(INSTALLDIR)/vm/perf_madvise.lua
641 CUSTOM_TARGETS += perf_madvise perf_madvise_benchrun
642 EXCLUDED_SOURCES += vm/perf_madvise.c
644 task_create_suid_cred: CODE_SIGN_ENTITLEMENTS = ./task_create_suid_cred_entitlement.plist
646 OTHER_TEST_TARGETS += task_create_suid_cred_unentitled
647 task_create_suid_cred_unentitled: OTHER_CFLAGS += -DUNENTITLED
648 task_create_suid_cred_unentitled: task_create_suid_cred.c
649 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
651 ioconnectasyncmethod_57641955: OTHER_LDFLAGS += -framework IOKit
653 ifeq ($(PLATFORM),BridgeOS)
654 EXCLUDED_SOURCES += ipsec.m
656 ipsec: OTHER_LDFLAGS += -framework Foundation -framework CoreFoundation -framework NetworkExtension
657 ipsec: CODE_SIGN_ENTITLEMENTS = ipsec.entitlements
660 test_sysctl_kern_procargs_25397314: OTHER_LDFLAGS += -framework Foundation -ldarwintest_utils
662 INCLUDED_TEST_SOURCE_DIRS += counter
664 EXCLUDED_SOURCES += counter/common.c
665 counter/counter: OTHER_CFLAGS += counter/common.c test_utils.c
666 counter/counter: OTHER_LDFLAGS += -ldarwintest_utils -ldarwintest
668 counter/benchmark: counter/benchmark.c
669 mkdir -p $(SYMROOT)/counter
670 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
671 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
673 counter/benchmark: OTHER_CFLAGS += counter/common.c benchmark/helpers.c
675 install-counter/benchmark: counter/benchmark
676 mkdir -p $(INSTALLDIR)/counter
677 cp $(SYMROOT)/counter/benchmark $(INSTALLDIR)/counter/
679 counter/benchmark_benchrun:
680 mkdir -p $(SYMROOT)/counter
681 cp $(SRCROOT)/counter/benchmark.lua $(SYMROOT)/counter/benchmark.lua
682 chmod +x $(SYMROOT)/counter/benchmark.lua
684 install-counter/benchmark_benchrun: counter/benchmark_benchrun
685 mkdir -p $(INSTALLDIR)/counter
686 cp $(SYMROOT)/counter/benchmark.lua $(INSTALLDIR)/counter/
687 chmod +x $(INSTALLDIR)/counter/benchmark.lua
689 CUSTOM_TARGETS += counter/benchmark counter/benchmark_benchrun
690 EXCLUDED_SOURCES += counter/benchmark.c
692 ifneq ($(PLATFORM),MacOSX)
693 EXCLUDED_SOURCES += vm/page_size_globals.c
695 vm/page_size_globals: INVALID_ARCHS = arm64 arm64e
698 INCLUDED_TEST_SOURCE_DIRS += lockf_uaf_poc
700 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets
702 trial_experiments: CODE_SIGN_ENTITLEMENTS = trial_experiments.entitlements
703 trial_experiments: OTHER_CFLAGS += -DENTITLED=1 test_utils.c drop_priv.c
704 trial_experiments: trial_experiments.c
705 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
706 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
708 trial_experiments_unentitled: OTHER_CFLAGS += drop_priv.c test_utils.c
709 trial_experiments_unentitled: trial_experiments.c
710 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@