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