]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/xnu_quick_test/makefile
xnu-2422.1.72.tar.gz
[apple/xnu.git] / tools / tests / xnu_quick_test / makefile
CommitLineData
b0d623f7 1SDKROOT ?= /
39236c6e 2Product ?= $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
cf7d32b8 3
39236c6e
A
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
8ifeq "$(RC_TARGET_CONFIG)" "iPhone"
9Embedded?=YES
10else
11Embedded?=$(shell echo $(SDKROOT) | grep -iq iphoneos && echo YES || echo NO)
12endif
316670eb 13
cf7d32b8 14ifeq "$(Embedded)" "YES"
39236c6e
A
15Product?=iPhone
16else
17Product?=MacOSX
18endif
19
20SDKVERSION:=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
21
22ifeq "$(Product)" "iPhoneOS"
23SDKPATH := $(shell xcodebuild -sdk $(SDKROOT) -version Path)
316670eb
A
24CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
25LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
cf7d32b8 26else
316670eb
A
27CFLAGS += -mmacosx-version-min=$(SDKVERSION)
28LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
39236c6e 29Product ?= MacOSX
cf7d32b8
A
30endif
31
39236c6e
A
32CC := xcrun -sdk $(SDKROOT) cc
33HOSTCC := cc
cf7d32b8 34
39236c6e
A
35SRCROOT?=$(shell /bin/pwd)
36OBJROOT?=$(SRCROOT)/BUILD/obj
37DSTROOT?=$(SRCROOT)/BUILD/dst
38SYMROOT?=$(SRCROOT)/BUILD/sym
2d21ac55 39
39236c6e
A
40SRCSUBPATH := $(SRCROOT)
41OBJSUBPATH := $(OBJROOT)
2d21ac55 42
39236c6e
A
43ifdef RC_ARCHS
44 ARCH:=$(RC_ARCHS)
2d21ac55 45else
39236c6e
A
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
52endif
2d21ac55
A
53endif
54
39236c6e
A
55MY_ARCH := $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
56ARCH_32 := $(filter-out %64, $(ARCH))
57ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
58ARCH_64 := $(filter %64, $(ARCH))
59ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
6d2010ae 60
316670eb 61CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
39236c6e
A
62
63LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/
2d21ac55 64
316670eb 65# The current implementation of the content protection test requires IOKit.
39236c6e 66ifeq "$(Product)" "iPhoneOS"
316670eb
A
67LIBFLAGS += -framework IOKit
68endif
69
39236c6e
A
70MY_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
2d21ac55 77
39236c6e
A
78ifneq "$(Product)" "iPhoneOS"
79MY_OBJECTS += $(OBJSUBPATH)/32bit_inode_tests.o
316670eb 80else
39236c6e 81MY_OBJECTS += $(OBJSUBPATH)/content_protection_test.o
b0d623f7 82endif
2d21ac55 83
39236c6e
A
84
85xnu_quick_test : $(OBJSUBPATH) $(DSTROOT) $(SYMROOT) $(MY_OBJECTS) helpers
86ifndef RC_ProjectName
87 rm -rf $(DSTROOT)/xnu_quick_test
88endif
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
2d21ac55 92
6d2010ae
A
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
98testbots: xnu_quick_test
39236c6e 99 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
6d2010ae 100
2d21ac55
A
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.
39236c6e
A
105helpers : $(SRCSUBPATH)/helpers/sleep.c $(SRCSUBPATH)/helpers/launch.c $(SRCSUBPATH)/helpers/arch.c $(SRCSUBPATH)/helpers/data_exec.c helperdir $(OBJSUBPATH)/misc.o
106ifneq "$(Product)" "iPhoneOS"
107ifneq "$(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/
110endif
cf7d32b8
A
111endif
112ifeq "$(Product)" "MacOSX"
39236c6e
A
113ifneq "$(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/
cf7d32b8 117endif
39236c6e
A
118ifneq "$(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/
cf7d32b8 123endif
39236c6e
A
124 $(CC) -g $(MY_ARCH) $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec
125 /usr/bin/ditto $(SYMROOT)/data_exec $(DSTROOT)/helpers/
cf7d32b8 126endif
39236c6e
A
127ifeq "$(Product)" "iPhoneOS"
128ifneq "$(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/
cf7d32b8 132endif
39236c6e
A
133endif
134 $(CC) -g $(MY_ARCH) $(CFLAGS) $(SRCSUBPATH)/helpers/arch.c -o $(SYMROOT)/arch
135 /usr/bin/ditto $(SYMROOT)/arch $(DSTROOT)/helpers/
2d21ac55
A
136
137helperdir :
138 mkdir -p $(DSTROOT)/helpers
139
39236c6e
A
140$(OBJSUBPATH) :
141 mkdir -p $(OBJSUBPATH);
2d21ac55
A
142
143$(DSTROOT) :
144 mkdir -p $(DSTROOT);
145
39236c6e
A
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 $@
2d21ac55 151
39236c6e
A
152$(OBJSUBPATH)/memory_tests.o : $(SRCSUBPATH)/memory_tests.c $(SRCSUBPATH)/tests.h
153 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/memory_tests.c -o $@
2d21ac55 154
b0d623f7 155# misc.o has to be built 3-way for the helpers to link
39236c6e
A
156$(OBJSUBPATH)/misc.o : $(SRCSUBPATH)/misc.c $(SRCSUBPATH)/tests.h
157ifeq "$(Product)" "iPhoneOS"
158 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
cf7d32b8 159else
39236c6e 160 $(CC) -arch i386 -arch x86_64 $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
cf7d32b8 161endif
2d21ac55 162
39236c6e
A
163$(OBJSUBPATH)/sema_tests.o : $(SRCSUBPATH)/sema_tests.c $(SRCSUBPATH)/tests.h
164 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sema_tests.c -o $@
2d21ac55 165
39236c6e
A
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 $@
2d21ac55 168
39236c6e
A
169$(OBJSUBPATH)/socket_tests.o : $(SRCSUBPATH)/socket_tests.c $(SRCSUBPATH)/tests.h
170 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/socket_tests.c -o $@
2d21ac55 171
39236c6e
A
172$(OBJSUBPATH)/tests.o : $(SRCSUBPATH)/tests.c $(SRCSUBPATH)/tests.h
173 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/tests.c -o $@
2d21ac55 174
39236c6e
A
175$(OBJSUBPATH)/xattr_tests.o : $(SRCSUBPATH)/xattr_tests.c $(SRCSUBPATH)/tests.h
176 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/xattr_tests.c -o $@
2d21ac55 177
39236c6e
A
178$(OBJSUBPATH)/machvm_tests.o : $(SRCSUBPATH)/machvm_tests.c $(SRCSUBPATH)/tests.h
179 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/machvm_tests.c -o $@
b0d623f7 180
39236c6e
A
181$(OBJSUBPATH)/sched_tests.o : $(SRCSUBPATH)/sched_tests.c $(SRCSUBPATH)/tests.h
182 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sched_tests.c -o $@
6d2010ae 183
39236c6e
A
184$(OBJSUBPATH)/kqueue_tests.o : $(SRCSUBPATH)/kqueue_tests.c $(SRCSUBPATH)/tests.h
185 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/kqueue_tests.c -o $@
b0d623f7 186
39236c6e
A
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 $@
2d21ac55 189
39236c6e
A
190$(OBJSUBPATH)/commpage_tests.o : $(SRCSUBPATH)/commpage_tests.c $(SRCSUBPATH)/tests.h
191 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/commpage_tests.c -o $@
6d2010ae 192
39236c6e
A
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 $@
6d2010ae 195
39236c6e
A
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 $@
316670eb 198
39236c6e
A
199$(OBJSUBPATH)/pipes_tests.o : $(SRCSUBPATH)/pipes_tests.c $(SRCSUBPATH)/tests.h
200 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/pipes_tests.c -o $@
6d2010ae 201
2d21ac55
A
202.PHONY : clean
203clean :
39236c6e
A
204 rm -Rf $(DSTROOT)/xnu_quick_test
205 rm -Rf $(DSTROOT)/helpers/*
206 rm -Rf $(OBJSUBPATH)/*.o