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