]> git.saurik.com Git - apple/xnu.git/blob - tests/Makefile
xnu-4903.241.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 /usr/local/lib/libdarwintest_utils.dylib, \
15 /usr/lib/libapple_crypto.dylib,
16
17 DEVELOPER_DIR ?= $(shell xcode-select -p)
18
19 # the xnu build system will only ever call us with the default target
20 .DEFAULT_GOAL := install
21
22 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
23
24 OTHER_CFLAGS = -Weverything -Wno-gnu-union-cast -Wno-missing-field-initializers -Wno-partial-availability
25 OTHER_CFLAGS += -Wno-missing-noreturn -Wno-vla -Wno-reserved-id-macro -Wno-documentation-unknown-command
26 OTHER_CFLAGS += -Wno-padded -Wno-used-but-marked-unused -Wno-covered-switch-default -Wno-nullability-extension
27 OTHER_CFLAGS += -Wno-gnu-empty-initializer -Wno-unused-macros
28 OTHER_CFLAGS += --std=gnu11 -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
29 OTHER_CFLAGS += -UT_NAMESPACE_PREFIX -DT_NAMESPACE_PREFIX=xnu
30 OTHER_CFLAGS += -F $(SDKROOT)/System/Library/PrivateFrameworks
31
32 CODESIGN:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign)
33 CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign_allocate)
34
35 # to have custom compiler flags to
36 # target: OTHER_CFLAGS += <my flags>
37
38 atm_diagnostic_flag: OTHER_CFLAGS += drop_priv.c
39
40 avx: INVALID_ARCHS = i386
41 avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
42 avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
43 avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
44 # Level 2 optimization must be used to prevent compiler from generating
45 # invalid instructions when compiling with AVX-512 flags.
46 avx: CONFIG_FLAGS += -O2
47 # Disable vzeroupper insertion to work around rdar://problem/35035096
48 avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
49 ifneq (osx,$(TARGET_NAME))
50 EXCLUDED_SOURCES += avx.c
51 endif
52
53 backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
54
55 data_protection: OTHER_LDFLAGS += -ldarwintest_utils -framework IOKit
56
57 kdebug: INVALID_ARCHS = i386
58 kdebug: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils -framework kperf
59
60 EXCLUDED_SOURCES += drop_priv.c kperf_helpers.c xnu_quick_test_helpers.c
61
62 ifeq ($(PLATFORM),iPhoneOS)
63 CONFIG_FREEZE_DEFINE:= -DCONFIG_FREEZE
64 else
65 CONFIG_FREEZE_DEFINE:=
66 EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c
67 endif
68
69 perf_compressor: OTHER_CFLAGS += $(CONFIG_FREEZE_DEFINE)
70 perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
71 perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
72
73 memorystatus_freeze_test: OTHER_CFLAGS += $(CONFIG_FREEZE_DEFINE)
74 memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
75
76 stackshot: OTHER_CFLAGS += -Wno-objc-messaging-id
77 stackshot: OTHER_LDFLAGS += -lkdd -framework Foundation
78 stackshot: INVALID_ARCHS = i386
79
80 telemetry: OTHER_LDFLAGS = -framework ktrace
81 telemetry: INVALID_ARCHS = i386
82
83 memorystatus_zone_test: INVALID_ARCHS = i386
84 memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
85 memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
86 memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
87
88 kpc: OTHER_LDFLAGS += -framework kperf
89
90 kperf: INVALID_ARCHS = i386
91 kperf: OTHER_CFLAGS += kperf_helpers.c
92 kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
93
94 kperf_backtracing: INVALID_ARCHS = i386
95 kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
96 kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
97 kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
98
99 kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
100 kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
101
102 mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
103
104 monotonic_core: OTHER_LDFLAGS += -framework ktrace
105 monotonic_core: INVALID_ARCHS = i386
106
107 perf_exit: perf_exit_proc
108 perf_exit: OTHER_LDFLAGS = -framework ktrace
109 perf_exit: INVALID_ARCHS = i386
110 perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
111
112 perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
113
114 os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
115 os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
116
117 task_inspect: CODE_SIGN_ENTITLEMENTS = task_inspect.entitlements
118 task_inspect: OTHER_CFLAGS += -DENTITLED=1
119
120 turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
121 turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
122
123 CUSTOM_TARGETS += perf_exit_proc
124
125 perf_exit_proc:
126 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
127
128 install-perf_exit_proc: perf_exit_proc
129 mkdir -p $(INSTALLDIR)
130 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
131
132 perf_kdebug: INVALID_ARCHS = i386
133
134 stackshot_idle_25570396: INVALID_ARCHS = i386
135 stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
136
137 stackshot_block_owner_14362384: INVALID_ARCHS = i386
138 stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
139 ifeq ($(PLATFORM),MacOSX)
140 stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
141 endif
142
143 all: $(DSTROOT)/usr/local/bin/kcdata
144
145 $(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
146 mkdir -p $(dir $@)
147 cp $< $@
148 chmod a+x $@
149
150 xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
151
152 xnu_quick_test_entitled: CODE_SIGN_ENTITLEMENTS = xnu_quick_test.entitlements
153
154 CUSTOM_TARGETS += vm_set_max_addr_helper
155
156 vm_set_max_addr_helper: vm_set_max_addr_helper.c
157 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
158 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
159 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
160
161 install-vm_set_max_addr_helper: vm_set_max_addr_helper
162 mkdir -p $(INSTALLDIR)
163 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
164
165 ifeq ($(PLATFORM),iPhoneOS)
166 OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled
167 jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
168 jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1
169 jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
170
171 jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
172 jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
173 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
174 endif
175
176 task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
177
178 proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
179 proc_info: OTHER_LDFLAGS += -ldarwintest_utils
180
181 proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
182
183 disk_mount_conditioner: disk_mount_conditioner*
184 disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
185 disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
186
187 OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
188 disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
189 disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
190 disk_mount_conditioner_unentitled: disk_mount_conditioner.c
191 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
192
193 work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
194 work_interval_test: OTHER_CFLAGS += -DENTITLED=1
195
196 settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
197
198 settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
199 settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
200
201 thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
202 thread_group_set_32261625: INVALID_ARCHS = i386
203
204 task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
205
206 socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
207 socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
208
209 net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
210
211 ifneq (osx,$(TARGET_NAME))
212 EXCLUDED_SOURCES += no32exec_35914211.c no32exec_35914211_helper.c
213 endif
214
215 no32exec_35914211_helper: INVALID_ARCHS = x86_64
216 no32exec_35914211: INVALID_ARCHS = i386
217
218 MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
219
220 CUSTOM_TARGETS += excserver
221
222 excserver:
223 $(MIG) $(CFLAGS) \
224 -sheader $(OBJROOT)/excserver.h \
225 -server $(OBJROOT)/excserver.c \
226 -header /dev/null -user /dev/null \
227 excserver.defs
228 install-excserver: ;
229
230 exc_resource_threads: excserver
231 exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
232
233 ifneq ($(PLATFORM),BridgeOS)
234 EXCLUDED_SOURCES += remote_time.c
235 else
236 remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
237 endif
238
239 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets