]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/xnu_quick_test/makefile
xnu-2782.40.9.tar.gz
[apple/xnu.git] / tools / tests / xnu_quick_test / makefile
CommitLineData
b0d623f7 1SDKROOT ?= /
39236c6e 2
fe8ab488
A
3PLATFORMPATH := $(shell xcrun -sdk $(SDKROOT) -show-sdk-platform-path)
4PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
39236c6e 5SDKVERSION:=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
39236c6e 6SDKPATH := $(shell xcodebuild -sdk $(SDKROOT) -version Path)
fe8ab488
A
7
8ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
316670eb
A
9CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
10LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
cf7d32b8 11else
316670eb
A
12CFLAGS += -mmacosx-version-min=$(SDKVERSION)
13LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
cf7d32b8
A
14endif
15
fe8ab488 16CC := $(shell xcrun -sdk "$(SDKROOT)" -find cc)
39236c6e 17HOSTCC := cc
cf7d32b8 18
fe8ab488
A
19CODESIGN := $(shell xcrun -sdk "$(SDKROOT)" -find codesign)
20
39236c6e
A
21SRCROOT?=$(shell /bin/pwd)
22OBJROOT?=$(SRCROOT)/BUILD/obj
23DSTROOT?=$(SRCROOT)/BUILD/dst
24SYMROOT?=$(SRCROOT)/BUILD/sym
2d21ac55 25
39236c6e
A
26SRCSUBPATH := $(SRCROOT)
27OBJSUBPATH := $(OBJROOT)
2d21ac55 28
39236c6e
A
29ifdef RC_ARCHS
30 ARCH:=$(RC_ARCHS)
2d21ac55 31else
fe8ab488 32 ifeq ($(PLATFORM),MacOSX)
39236c6e 33 ARCH:=i386 x86_64
fe8ab488
A
34 else ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
35 ARCH:=arm64 armv7s armv7
39236c6e 36endif
2d21ac55
A
37endif
38
39236c6e
A
39MY_ARCH := $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
40ARCH_32 := $(filter-out %64, $(ARCH))
41ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
42ARCH_64 := $(filter %64, $(ARCH))
43ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
6d2010ae 44
316670eb 45CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
39236c6e
A
46
47LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/
2d21ac55 48
316670eb 49# The current implementation of the content protection test requires IOKit.
fe8ab488 50ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
316670eb
A
51LIBFLAGS += -framework IOKit
52endif
53
39236c6e
A
54MY_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
2d21ac55 61
fe8ab488 62ifeq ($(PLATFORM),MacOSX)
39236c6e 63MY_OBJECTS += $(OBJSUBPATH)/32bit_inode_tests.o
fe8ab488
A
64endif
65
66ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
39236c6e 67MY_OBJECTS += $(OBJSUBPATH)/content_protection_test.o
b0d623f7 68endif
2d21ac55 69
39236c6e
A
70
71xnu_quick_test : $(OBJSUBPATH) $(DSTROOT) $(SYMROOT) $(MY_OBJECTS) helpers
72ifndef RC_ProjectName
73 rm -rf $(DSTROOT)/xnu_quick_test
74endif
75 $(CC) -g $(MY_ARCH) $(LIBFLAGS) -o $(SYMROOT)/xnu_quick_test $(MY_OBJECTS)
76 /usr/bin/dsymutil $(SYMROOT)/xnu_quick_test
fe8ab488
A
77ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
78 $(CODESIGN) -f -s - --entitlements $(SRCSUBPATH)/xnu_quick_test.entitlements $(SYMROOT)/xnu_quick_test
79endif
39236c6e 80 /usr/bin/ditto $(SYMROOT)/xnu_quick_test $(DSTROOT)/xnu_quick_test
2d21ac55 81
6d2010ae
A
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
87testbots: xnu_quick_test
39236c6e 88 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
6d2010ae 89
2d21ac55
A
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.
39236c6e 94helpers : $(SRCSUBPATH)/helpers/sleep.c $(SRCSUBPATH)/helpers/launch.c $(SRCSUBPATH)/helpers/arch.c $(SRCSUBPATH)/helpers/data_exec.c helperdir $(OBJSUBPATH)/misc.o
fe8ab488 95ifeq ($(PLATFORM),MacOSX)
39236c6e
A
96ifneq "$(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/
99endif
cf7d32b8 100endif
fe8ab488 101ifeq ($(PLATFORM),MacOSX)
39236c6e
A
102ifneq "$(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/
cf7d32b8 106endif
39236c6e
A
107ifneq "$(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/
cf7d32b8 112endif
39236c6e
A
113 $(CC) -g $(MY_ARCH) $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec
114 /usr/bin/ditto $(SYMROOT)/data_exec $(DSTROOT)/helpers/
cf7d32b8 115endif
fe8ab488 116ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
39236c6e
A
117ifneq "$(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/
cf7d32b8 121endif
fe8ab488
A
122ifneq "$(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/
125endif
39236c6e
A
126endif
127 $(CC) -g $(MY_ARCH) $(CFLAGS) $(SRCSUBPATH)/helpers/arch.c -o $(SYMROOT)/arch
128 /usr/bin/ditto $(SYMROOT)/arch $(DSTROOT)/helpers/
fe8ab488 129
2d21ac55
A
130helperdir :
131 mkdir -p $(DSTROOT)/helpers
132
39236c6e
A
133$(OBJSUBPATH) :
134 mkdir -p $(OBJSUBPATH);
fe8ab488 135
2d21ac55
A
136$(DSTROOT) :
137 mkdir -p $(DSTROOT);
138
39236c6e
A
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 $@
fe8ab488 144
39236c6e
A
145$(OBJSUBPATH)/memory_tests.o : $(SRCSUBPATH)/memory_tests.c $(SRCSUBPATH)/tests.h
146 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/memory_tests.c -o $@
2d21ac55 147
b0d623f7 148# misc.o has to be built 3-way for the helpers to link
39236c6e 149$(OBJSUBPATH)/misc.o : $(SRCSUBPATH)/misc.c $(SRCSUBPATH)/tests.h
fe8ab488 150ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
39236c6e 151 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
cf7d32b8 152else
39236c6e 153 $(CC) -arch i386 -arch x86_64 $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
cf7d32b8 154endif
fe8ab488 155
39236c6e
A
156$(OBJSUBPATH)/sema_tests.o : $(SRCSUBPATH)/sema_tests.c $(SRCSUBPATH)/tests.h
157 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sema_tests.c -o $@
fe8ab488 158
39236c6e
A
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 $@
2d21ac55 161
39236c6e
A
162$(OBJSUBPATH)/socket_tests.o : $(SRCSUBPATH)/socket_tests.c $(SRCSUBPATH)/tests.h
163 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/socket_tests.c -o $@
2d21ac55 164
39236c6e
A
165$(OBJSUBPATH)/tests.o : $(SRCSUBPATH)/tests.c $(SRCSUBPATH)/tests.h
166 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/tests.c -o $@
2d21ac55 167
39236c6e
A
168$(OBJSUBPATH)/xattr_tests.o : $(SRCSUBPATH)/xattr_tests.c $(SRCSUBPATH)/tests.h
169 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/xattr_tests.c -o $@
2d21ac55 170
39236c6e
A
171$(OBJSUBPATH)/machvm_tests.o : $(SRCSUBPATH)/machvm_tests.c $(SRCSUBPATH)/tests.h
172 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/machvm_tests.c -o $@
b0d623f7 173
39236c6e
A
174$(OBJSUBPATH)/sched_tests.o : $(SRCSUBPATH)/sched_tests.c $(SRCSUBPATH)/tests.h
175 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sched_tests.c -o $@
6d2010ae 176
39236c6e
A
177$(OBJSUBPATH)/kqueue_tests.o : $(SRCSUBPATH)/kqueue_tests.c $(SRCSUBPATH)/tests.h
178 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/kqueue_tests.c -o $@
b0d623f7 179
39236c6e
A
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 $@
2d21ac55 182
39236c6e
A
183$(OBJSUBPATH)/commpage_tests.o : $(SRCSUBPATH)/commpage_tests.c $(SRCSUBPATH)/tests.h
184 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/commpage_tests.c -o $@
fe8ab488 185
39236c6e
A
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 $@
6d2010ae 188
39236c6e
A
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 $@
316670eb 191
39236c6e
A
192$(OBJSUBPATH)/pipes_tests.o : $(SRCSUBPATH)/pipes_tests.c $(SRCSUBPATH)/tests.h
193 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/pipes_tests.c -o $@
6d2010ae 194
2d21ac55
A
195.PHONY : clean
196clean :
39236c6e
A
197 rm -Rf $(DSTROOT)/xnu_quick_test
198 rm -Rf $(DSTROOT)/helpers/*
199 rm -Rf $(OBJSUBPATH)/*.o