]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/xnu_quick_test/makefile
xnu-2050.7.9.tar.gz
[apple/xnu.git] / tools / tests / xnu_quick_test / makefile
CommitLineData
b0d623f7 1SDKROOT ?= /
cf7d32b8
A
2Product=$(shell tconf --product)
3Embedded=$(shell tconf --test TARGET_OS_EMBEDDED)
4
316670eb
A
5SDKVERSION=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
6
cf7d32b8
A
7ifeq "$(Embedded)" "YES"
8XILogFLAG =
6d2010ae 9SDKPATH = $(shell xcodebuild -sdk $(SDKROOT) -version Path)
316670eb
A
10CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
11LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
cf7d32b8
A
12else
13XILogFLAG = -framework XILog
316670eb
A
14CFLAGS += -mmacosx-version-min=$(SDKVERSION)
15LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
cf7d32b8
A
16endif
17
316670eb
A
18HOSTCC = cc
19CC = xcrun -sdk $(SDKROOT) cc
cf7d32b8 20
2d21ac55
A
21ifdef RC_BUILDIT
22DOING_BUILDIT=yes
23endif
24
25ifdef RC_OS
26DOING_BUILDIT=yes
27endif
28
29ifdef DOING_BUILDIT
30include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make
31MY_ARCH = $(patsubst %, -arch %, $(RC_ARCHS))
32install:: xnu_quick_test
33else
34 ifndef SRCROOT
35 SRCROOT=$(shell /bin/pwd)
36 endif
37 ifndef OBJROOT
38 OBJROOT=$(SRCROOT)/BUILD/obj
39 endif
40 ifndef DSTROOT
41 DSTROOT=$(SRCROOT)/BUILD/dst
42 endif
43
44 ifndef ARCH
6d2010ae 45 ARCH=i386 x86_64
cf7d32b8 46 # this hack should be removed once tconf gets
b0d623f7 47 # <rdar://problem/6618734>
cf7d32b8 48 ifeq "$(Product)" "iPhone"
316670eb 49 ARCH=armv7
cf7d32b8
A
50 endif
51 ifeq "$(Product)" "AppleTV"
52 ARCH=i386
53 endif
2d21ac55
A
54 endif
55
56 ifdef ARCH
57 MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
58 endif
59
60 CFLAGS += $(MY_ARCH)
61endif
62
6d2010ae 63
316670eb 64CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
b0d623f7 65LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/ $(XILogFLAG)
2d21ac55 66
316670eb
A
67# The current implementation of the content protection test requires IOKit.
68ifeq "$(Product)" "iPhone"
69LIBFLAGS += -framework IOKit
70endif
71
2d21ac55
A
72MY_OBJECTS = $(OBJROOT)/main.o $(OBJROOT)/memory_tests.o $(OBJROOT)/misc.o \
73 $(OBJROOT)/sema_tests.o $(OBJROOT)/shared_memory_tests.o \
b0d623f7
A
74 $(OBJROOT)/socket_tests.o $(OBJROOT)/tests.o \
75 $(OBJROOT)/xattr_tests.o $(OBJROOT)/kqueue_tests.o \
6d2010ae 76 $(OBJROOT)/machvm_tests.o $(OBJROOT)/commpage_tests.o \
316670eb
A
77 $(OBJROOT)/atomic_fifo_queue_test.o $(OBJROOT)/sched_tests.o \
78 $(OBJROOT)/pipes_tests.o
2d21ac55 79
b0d623f7
A
80ifneq "$(Product)" "iPhone"
81MY_OBJECTS += $(OBJROOT)/32bit_inode_tests.o
316670eb
A
82else
83MY_OBJECTS += $(OBJROOT)/content_protection_test.o
b0d623f7 84endif
2d21ac55 85
b0d623f7
A
86# In networked home directories, the chown will fail; we notice and print a helpful message
87CHOWN_COMMAND=sudo chown root $(DSTROOT)/xnu_quick_test
88PERM_ADVICE="\tYou'll have to set the executable's permissions yourself: chown to root and chmod to 4755. You may need to move to a local volume to do that."
2d21ac55
A
89xnu_quick_test : $(OBJROOT) $(DSTROOT) $(MY_OBJECTS) helpers
90 sudo rm -rf $(DSTROOT)/xnu_quick_test
cf7d32b8 91 $(CC) $(MY_ARCH) $(LIBFLAGS) -o $(DSTROOT)/xnu_quick_test $(MY_OBJECTS)
b0d623f7
A
92 @echo $(CHOWN_COMMAND) # Hack so we don't echo help-message echo
93 @$(CHOWN_COMMAND) || echo $(PERM_ADVICE)
2d21ac55
A
94 sudo chmod 4755 $(DSTROOT)/xnu_quick_test
95
6d2010ae
A
96# This target is defined for testbots.
97# Before compiling this target, MORECFLAGS must be set to "-D RUN_UNDER_TESTBOTS=1", check README file for more details
98# NOTE: -f[ailures] MAX_FAILS_ALLOWED option is set to 100 to make sure we completely run the test suite and
99# report all the failures.
100
101testbots: xnu_quick_test
102 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
103
2d21ac55
A
104# The helper binaries are used to test exec()'ing between 64bit and 32bit.
105# Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit
106# helper processes for the 64-bit version of xnu_quick_test to test the conversion
107# from a 32-bit process to a 64-bit process.
b0d623f7 108helpers : helpers/sleep.c helpers/launch.c helpers/arch.c helpers/data_exec.c helperdir $(OBJROOT)/misc.o
cf7d32b8
A
109ifneq "$(Product)" "iPhone"
110 $(CC) -arch i386 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-i386
111endif
112ifeq "$(Product)" "MacOSX"
113 $(CC) -arch x86_64 -pagezero_size 0x100000000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4G
114 $(CC) -arch x86_64 -pagezero_size 0x1000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4K
cf7d32b8
A
115endif
116ifneq "$(Product)" "iPhone"
117 $(CC) $(LIBFLAGS) -arch i386 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-i386
118endif
b0d623f7 119ifeq "$(Product)" "MacOSX"
cf7d32b8 120 $(CC) $(LIBFLAGS) -arch x86_64 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-x86_64
cf7d32b8 121 $(CC) $(MY_ARCH) helpers/arch.c -o $(DSTROOT)/helpers/arch
b0d623f7 122 $(CC) $(MY_ARCH) helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec
6d2010ae 123 $(CC) -arch i386 -DNXDATA32TESTNONX helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec32nonxspawn
b0d623f7 124
cf7d32b8
A
125endif
126ifeq "$(Product)" "iPhone"
316670eb
A
127 $(CC) $(CFLAGS) helpers/sleep.c -o $(DSTROOT)/helpers/sleep-arm
128 $(CC) $(LIBFLAGS) $(CFLAGS) $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-arm
129 $(CC) $(MY_ARCH) $(CFLAGS) helpers/arch.c -o $(DSTROOT)/helpers/arch
cf7d32b8
A
130endif
131
2d21ac55
A
132
133helperdir :
134 mkdir -p $(DSTROOT)/helpers
135
136$(OBJROOT) :
137 mkdir -p $(OBJROOT);
138
139$(DSTROOT) :
140 mkdir -p $(DSTROOT);
141
2d21ac55 142$(OBJROOT)/main.o : main.c tests.h
cf7d32b8 143 $(CC) $(CFLAGS) -c main.c -o $@
2d21ac55
A
144
145$(OBJROOT)/memory_tests.o : memory_tests.c tests.h
cf7d32b8 146 $(CC) $(CFLAGS) -c memory_tests.c -o $@
2d21ac55 147
b0d623f7 148# misc.o has to be built 3-way for the helpers to link
2d21ac55 149$(OBJROOT)/misc.o : misc.c tests.h
cf7d32b8 150ifeq "$(Product)" "iPhone"
316670eb 151 $(CC) -arch armv7 $(CFLAGS) -c misc.c -o $@
cf7d32b8 152else
6d2010ae 153 $(CC) -arch i386 -arch x86_64 $(CFLAGS) -c misc.c -o $@
cf7d32b8 154endif
2d21ac55
A
155
156$(OBJROOT)/sema_tests.o : sema_tests.c tests.h
cf7d32b8 157 $(CC) $(CFLAGS) -c sema_tests.c -o $@
2d21ac55
A
158
159$(OBJROOT)/shared_memory_tests.o : shared_memory_tests.c tests.h
cf7d32b8 160 $(CC) $(CFLAGS) -c shared_memory_tests.c -o $@
2d21ac55
A
161
162$(OBJROOT)/socket_tests.o : socket_tests.c tests.h
cf7d32b8 163 $(CC) $(CFLAGS) -c socket_tests.c -o $@
2d21ac55
A
164
165$(OBJROOT)/tests.o : tests.c tests.h
cf7d32b8 166 $(CC) $(CFLAGS) -c tests.c -o $@
2d21ac55
A
167
168$(OBJROOT)/xattr_tests.o : xattr_tests.c tests.h
cf7d32b8 169 $(CC) $(CFLAGS) -c xattr_tests.c -o $@
2d21ac55 170
b0d623f7
A
171$(OBJROOT)/machvm_tests.o : machvm_tests.c tests.h
172 $(CC) $(CFLAGS) -c machvm_tests.c -o $@
173
6d2010ae
A
174$(OBJROOT)/sched_tests.o : sched_tests.c tests.h
175 $(CC) $(CFLAGS) -c sched_tests.c -o $@
176
b0d623f7
A
177$(OBJROOT)/kqueue_tests.o : kqueue_tests.c tests.h
178 $(CC) $(CFLAGS) -c kqueue_tests.c -o $@
179
180$(OBJROOT)/32bit_inode_tests.o : 32bit_inode_tests.c tests.h
181 $(CC) $(CFLAGS) -c 32bit_inode_tests.c -o $@
2d21ac55 182
6d2010ae
A
183$(OBJROOT)/commpage_tests.o : commpage_tests.c tests.h
184 $(CC) $(CFLAGS) -c commpage_tests.c -o $@
185
186$(OBJROOT)/atomic_fifo_queue_test.o : atomic_fifo_queue_test.c tests.h
187 $(CC) $(CFLAGS) -c atomic_fifo_queue_test.c -o $@
188
316670eb
A
189$(OBJROOT)/content_protection_test.o : content_protection_test.c tests.h
190 $(CC) $(CFLAGS) -c content_protection_test.c -o $@
191
192$(OBJROOT)/pipes_tests.o : pipes_tests.c tests.h
193 $(CC) $(CFLAGS) -c pipes_tests.c -o $@
6d2010ae 194
2d21ac55
A
195ifndef DOING_BUILDIT
196.PHONY : clean
197clean :
b0d623f7
A
198 sudo rm -Rf $(DSTROOT)/xnu_quick_test
199 sudo rm -Rf $(DSTROOT)/helpers/*
200 rm -Rf $(OBJROOT)/*.o
2d21ac55 201endif