]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/xnu_quick_test/makefile
8f397832dca4f4897fe752c205cd5d1bf0f1d4a2
[apple/xnu.git] / tools / tests / xnu_quick_test / makefile
1 SDKROOT ?= /
2
3 PLATFORMPATH := $(shell xcrun -sdk $(SDKROOT) -show-sdk-platform-path)
4 PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
5 SDKVERSION:=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
6 SDKPATH := $(shell xcodebuild -sdk $(SDKROOT) -version Path)
7
8 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
9 CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
10 LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
11 else
12 CFLAGS += -mmacosx-version-min=$(SDKVERSION)
13 LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
14 endif
15
16 CC := $(shell xcrun -sdk "$(SDKROOT)" -find cc)
17 HOSTCC := cc
18
19 CODESIGN := $(shell xcrun -sdk "$(SDKROOT)" -find codesign)
20
21 SRCROOT?=$(shell /bin/pwd)
22 OBJROOT?=$(SRCROOT)/BUILD/obj
23 DSTROOT?=$(SRCROOT)/BUILD/dst
24 SYMROOT?=$(SRCROOT)/BUILD/sym
25
26 SRCSUBPATH := $(SRCROOT)
27 OBJSUBPATH := $(OBJROOT)
28
29 ifdef RC_ARCHS
30 ARCH:=$(RC_ARCHS)
31 else
32 ifeq ($(PLATFORM),MacOSX)
33 ARCH:=i386 x86_64
34 else ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
35 ARCH:=arm64 armv7s armv7
36 endif
37 endif
38
39 MY_ARCH := $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
40 ARCH_32 := $(filter-out %64, $(ARCH))
41 ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
42 ARCH_64 := $(filter %64, $(ARCH))
43 ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
44
45 CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
46
47 LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/
48
49 # The current implementation of the content protection test requires IOKit.
50 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
51 LIBFLAGS += -framework IOKit
52 endif
53
54 MY_OBJECTS := $(OBJSUBPATH)/main.o $(OBJSUBPATH)/memory_tests.o $(OBJSUBPATH)/misc.o \
55 $(OBJSUBPATH)/sema_tests.o $(OBJSUBPATH)/shared_memory_tests.o \
56 $(OBJSUBPATH)/socket_tests.o $(OBJSUBPATH)/tests.o \
57 $(OBJSUBPATH)/xattr_tests.o $(OBJSUBPATH)/kqueue_tests.o \
58 $(OBJSUBPATH)/machvm_tests.o $(OBJSUBPATH)/commpage_tests.o \
59 $(OBJSUBPATH)/atomic_fifo_queue_test.o $(OBJSUBPATH)/sched_tests.o \
60 $(OBJSUBPATH)/pipes_tests.o
61
62 ifeq ($(PLATFORM),MacOSX)
63 MY_OBJECTS += $(OBJSUBPATH)/32bit_inode_tests.o
64 endif
65
66 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
67 MY_OBJECTS += $(OBJSUBPATH)/content_protection_test.o
68 endif
69
70
71 xnu_quick_test : $(OBJSUBPATH) $(DSTROOT) $(SYMROOT) $(MY_OBJECTS) helpers
72 ifndef RC_ProjectName
73 rm -rf $(DSTROOT)/xnu_quick_test
74 endif
75 $(CC) -g $(MY_ARCH) $(LIBFLAGS) -o $(SYMROOT)/xnu_quick_test $(MY_OBJECTS)
76 /usr/bin/dsymutil $(SYMROOT)/xnu_quick_test
77 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
78 $(CODESIGN) -f -s - --entitlements $(SRCSUBPATH)/xnu_quick_test.entitlements $(SYMROOT)/xnu_quick_test
79 endif
80 /usr/bin/ditto $(SYMROOT)/xnu_quick_test $(DSTROOT)/xnu_quick_test
81
82 # This target is defined for testbots.
83 # Before compiling this target, MORECFLAGS must be set to "-D RUN_UNDER_TESTBOTS=1", check README file for more details
84 # NOTE: -f[ailures] MAX_FAILS_ALLOWED option is set to 100 to make sure we completely run the test suite and
85 # report all the failures.
86
87 testbots: xnu_quick_test
88 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
89
90 # The helper binaries are used to test exec()'ing between 64bit and 32bit.
91 # Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit
92 # helper processes for the 64-bit version of xnu_quick_test to test the conversion
93 # from a 32-bit process to a 64-bit process.
94 helpers : $(SRCSUBPATH)/helpers/sleep.c $(SRCSUBPATH)/helpers/launch.c $(SRCSUBPATH)/helpers/arch.c $(SRCSUBPATH)/helpers/data_exec.c helperdir $(OBJSUBPATH)/misc.o
95 ifeq ($(PLATFORM),MacOSX)
96 ifneq "$(ARCH_32)" ""
97 $(CC) -g $(ARCH_32_FLAGS) $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-i386
98 /usr/bin/ditto $(SYMROOT)/sleep-i386 $(DSTROOT)/helpers/
99 endif
100 endif
101 ifeq ($(PLATFORM),MacOSX)
102 ifneq "$(ARCH_32)" ""
103 $(CC) -g $(LIBFLAGS) $(ARCH_32_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-i386
104 $(CC) -g $(ARCH_32_FLAGS) -DNXDATA32TESTNONX $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec32nonxspawn
105 /usr/bin/ditto $(SYMROOT)/launch-i386 $(SYMROOT)/data_exec32nonxspawn $(DSTROOT)/helpers/
106 endif
107 ifneq "$(ARCH_64)" ""
108 $(CC) -g $(ARCH_64_FLAGS) -pagezero_size 0x100000000 $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-x86_64-4G
109 $(CC) -g $(ARCH_64_FLAGS) -pagezero_size 0x1000 $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-x86_64-4K
110 $(CC) -g $(LIBFLAGS) $(ARCH_64_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-x86_64
111 /usr/bin/ditto $(SYMROOT)/sleep-x86_64-4G $(SYMROOT)/sleep-x86_64-4K $(SYMROOT)/launch-x86_64 $(DSTROOT)/helpers/
112 endif
113 $(CC) -g $(MY_ARCH) $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec
114 /usr/bin/ditto $(SYMROOT)/data_exec $(DSTROOT)/helpers/
115 endif
116 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
117 ifneq "$(ARCH_32)" ""
118 $(CC) $(CFLAGS) $(ARCH_32_FLAGS) $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-arm
119 $(CC) $(LIBFLAGS) $(CFLAGS) $(ARCH_32_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-arm
120 /usr/bin/ditto $(SYMROOT)/sleep-arm $(SYMROOT)/launch-arm $(DSTROOT)/helpers/
121 endif
122 ifneq "$(ARCH_64)" ""
123 $(CC) $(CFLAGS) $(ARCH_64_FLAGS) $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-arm64
124 /usr/bin/ditto $(SYMROOT)/sleep-arm64 $(DSTROOT)/helpers/
125 endif
126 endif
127 $(CC) -g $(MY_ARCH) $(CFLAGS) $(SRCSUBPATH)/helpers/arch.c -o $(SYMROOT)/arch
128 /usr/bin/ditto $(SYMROOT)/arch $(DSTROOT)/helpers/
129
130 helperdir :
131 mkdir -p $(DSTROOT)/helpers
132
133 $(OBJSUBPATH) :
134 mkdir -p $(OBJSUBPATH);
135
136 $(DSTROOT) :
137 mkdir -p $(DSTROOT);
138
139 $(SYMROOT) :
140 mkdir -p $(SYMROOT)
141
142 $(OBJSUBPATH)/main.o : $(SRCSUBPATH)/main.c $(SRCSUBPATH)/tests.h
143 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/main.c -o $@
144
145 $(OBJSUBPATH)/memory_tests.o : $(SRCSUBPATH)/memory_tests.c $(SRCSUBPATH)/tests.h
146 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/memory_tests.c -o $@
147
148 # misc.o has to be built 3-way for the helpers to link
149 $(OBJSUBPATH)/misc.o : $(SRCSUBPATH)/misc.c $(SRCSUBPATH)/tests.h
150 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
151 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
152 else
153 $(CC) -arch i386 -arch x86_64 $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
154 endif
155
156 $(OBJSUBPATH)/sema_tests.o : $(SRCSUBPATH)/sema_tests.c $(SRCSUBPATH)/tests.h
157 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sema_tests.c -o $@
158
159 $(OBJSUBPATH)/shared_memory_tests.o : $(SRCSUBPATH)/shared_memory_tests.c $(SRCSUBPATH)/tests.h
160 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/shared_memory_tests.c -o $@
161
162 $(OBJSUBPATH)/socket_tests.o : $(SRCSUBPATH)/socket_tests.c $(SRCSUBPATH)/tests.h
163 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/socket_tests.c -o $@
164
165 $(OBJSUBPATH)/tests.o : $(SRCSUBPATH)/tests.c $(SRCSUBPATH)/tests.h
166 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/tests.c -o $@
167
168 $(OBJSUBPATH)/xattr_tests.o : $(SRCSUBPATH)/xattr_tests.c $(SRCSUBPATH)/tests.h
169 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/xattr_tests.c -o $@
170
171 $(OBJSUBPATH)/machvm_tests.o : $(SRCSUBPATH)/machvm_tests.c $(SRCSUBPATH)/tests.h
172 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/machvm_tests.c -o $@
173
174 $(OBJSUBPATH)/sched_tests.o : $(SRCSUBPATH)/sched_tests.c $(SRCSUBPATH)/tests.h
175 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sched_tests.c -o $@
176
177 $(OBJSUBPATH)/kqueue_tests.o : $(SRCSUBPATH)/kqueue_tests.c $(SRCSUBPATH)/tests.h
178 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/kqueue_tests.c -o $@
179
180 $(OBJSUBPATH)/32bit_inode_tests.o : $(SRCSUBPATH)/32bit_inode_tests.c $(SRCSUBPATH)/tests.h
181 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/32bit_inode_tests.c -o $@
182
183 $(OBJSUBPATH)/commpage_tests.o : $(SRCSUBPATH)/commpage_tests.c $(SRCSUBPATH)/tests.h
184 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/commpage_tests.c -o $@
185
186 $(OBJSUBPATH)/atomic_fifo_queue_test.o : $(SRCSUBPATH)/atomic_fifo_queue_test.c $(SRCSUBPATH)/tests.h
187 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/atomic_fifo_queue_test.c -o $@
188
189 $(OBJSUBPATH)/content_protection_test.o : $(SRCSUBPATH)/content_protection_test.c $(SRCSUBPATH)/tests.h
190 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/content_protection_test.c -o $@
191
192 $(OBJSUBPATH)/pipes_tests.o : $(SRCSUBPATH)/pipes_tests.c $(SRCSUBPATH)/tests.h
193 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/pipes_tests.c -o $@
194
195 .PHONY : clean
196 clean :
197 rm -Rf $(DSTROOT)/xnu_quick_test
198 rm -Rf $(DSTROOT)/helpers/*
199 rm -Rf $(OBJSUBPATH)/*.o