2 # Copyright (C) 2012 The Android Open Source Project
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 ifneq ($(BUILD_TINY_ANDROID),true)
19 LOCAL_PATH := $(call my-dir)
21 # -----------------------------------------------------------------------------
23 # -----------------------------------------------------------------------------
25 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
31 # -----------------------------------------------------------------------------
33 # -----------------------------------------------------------------------------
35 -fstack-protector-all \
37 -Wall -Wextra -Wunused \
41 test_cflags += -D__STDC_LIMIT_MACROS # For glibc.
43 ifeq ($(MALLOC_IMPL),dlmalloc)
44 test_cflags += -DUSE_DLMALLOC
46 test_cflags += -DUSE_JEMALLOC
52 libBionicStandardTests_src_files := \
64 libc_logging_test.cpp \
78 math_sincos_test.cpp \
79 math_sincosf_test.cpp \
90 stack_protector_test.cpp \
101 sys_resource_test.cpp \
102 sys_select_test.cpp \
103 sys_sendfile_test.cpp \
104 sys_socket_test.cpp \
106 sys_statvfs_test.cpp \
107 sys_syscall_test.cpp \
111 system_properties_test.cpp \
118 libBionicStandardTests_cflags := \
121 ifeq ($(MALLOC_IMPL),dlmalloc)
122 libBionicStandardTests_cflags += -DUSE_DLMALLOC
124 libBionicStandardTests_cflags += -DUSE_JEMALLOC
127 libBionicStandardTests_cppflags := \
130 libBionicStandardTests_c_includes := \
133 libBionicStandardTests_ldlibs_host := \
136 module := libBionicStandardTests
137 module_tag := optional
139 build_target := STATIC_TEST_LIBRARY
140 include $(LOCAL_PATH)/Android.build.mk
142 include $(LOCAL_PATH)/Android.build.mk
144 # -----------------------------------------------------------------------------
146 # -----------------------------------------------------------------------------
147 $(foreach compiler,gcc clang, \
148 $(foreach test,1 2, \
149 $(eval fortify$(test)-tests-$(compiler)_cflags := \
153 -D_FORTIFY_SOURCE=$(test) \
154 -DTEST_NAME=Fortify$(test)_$(compiler)); \
155 $(eval fortify$(test)-tests-$(compiler)_src_files := \
157 $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \
161 module := fortify1-tests-gcc
162 module_tag := optional
164 build_target := STATIC_TEST_LIBRARY
165 include $(LOCAL_PATH)/Android.build.mk
167 include $(LOCAL_PATH)/Android.build.mk
169 module := fortify2-tests-gcc
170 module_tag := optional
172 build_target := STATIC_TEST_LIBRARY
173 include $(LOCAL_PATH)/Android.build.mk
175 include $(LOCAL_PATH)/Android.build.mk
177 fortify1-tests-clang_clang_target := true
178 fortify1-tests-clang_cflags_host := -D__clang__
180 module := fortify1-tests-clang
181 module_tag := optional
183 build_target := STATIC_TEST_LIBRARY
184 include $(LOCAL_PATH)/Android.build.mk
186 include $(LOCAL_PATH)/Android.build.mk
188 fortify2-tests-clang_clang_target := true
190 fortify2-tests-clang_cflags_host := -D__clang__
192 module := fortify2-tests-clang
193 module_tag := optional
195 build_target := STATIC_TEST_LIBRARY
196 include $(LOCAL_PATH)/Android.build.mk
198 include $(LOCAL_PATH)/Android.build.mk
200 # -----------------------------------------------------------------------------
201 # Library of all tests (excluding the dynamic linker tests).
202 # -----------------------------------------------------------------------------
203 libBionicTests_whole_static_libraries := \
204 libBionicStandardTests \
207 module := libBionicTests
208 module_tag := optional
210 build_target := STATIC_TEST_LIBRARY
211 include $(LOCAL_PATH)/Android.build.mk
213 include $(LOCAL_PATH)/Android.build.mk
215 # -----------------------------------------------------------------------------
216 # Tests for the device using bionic's .so. Run with:
217 # adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
218 # adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
219 # -----------------------------------------------------------------------------
220 bionic-unit-tests_whole_static_libraries := \
223 bionic-unit-tests_src_files := \
227 stack_unwinding_test.cpp \
228 stack_unwinding_test_impl.c \
230 bionic-unit-tests_cflags := $(test_cflags)
232 bionic-unit-tests_conlyflags := \
234 -fnon-call-exceptions \
236 bionic-unit-tests_cppflags := $(test_cppflags)
238 bionic-unit-tests_ldflags := \
239 -Wl,--export-dynamic \
240 -Wl,-u,DlSymTestFunction \
242 bionic-unit-tests_c_includes := \
244 $(call include-path-for, libpagemap) \
246 bionic-unit-tests_shared_libraries_target := \
250 module := bionic-unit-tests
251 module_tag := optional
253 build_target := NATIVE_TEST
254 include $(LOCAL_PATH)/Android.build.mk
256 # -----------------------------------------------------------------------------
257 # Tests for the device linked against bionic's static library. Run with:
258 # adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
259 # adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
260 # -----------------------------------------------------------------------------
261 bionic-unit-tests-static_whole_static_libraries := \
264 bionic-unit-tests-static_static_libraries := \
270 bionic-unit-tests-static_force_static_executable := true
272 module := bionic-unit-tests-static
273 module_tag := optional
275 build_target := NATIVE_TEST
276 include $(LOCAL_PATH)/Android.build.mk
278 # -----------------------------------------------------------------------------
279 # Tests to run on the host and linked against glibc. Run with:
280 # cd bionic/tests; mm bionic-unit-tests-glibc-run
281 # -----------------------------------------------------------------------------
283 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
285 bionic-unit-tests-glibc_src_files := \
288 bionic-unit-tests-glibc_whole_static_libraries := \
289 libBionicStandardTests \
291 bionic-unit-tests-glibc_ldlibs := \
294 bionic-unit-tests-glibc_cflags := $(test_cflags)
295 bionic-unit-tests-glibc_cppflags := $(test_cppflags)
297 module := bionic-unit-tests-glibc
298 module_tag := optional
300 build_target := NATIVE_TEST
301 include $(LOCAL_PATH)/Android.build.mk
303 ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
305 NATIVE_TEST_SUFFIX=64
308 NATIVE_TEST_SUFFIX=32
311 # gtest needs ANDROID_DATA/local/tmp for death test output.
312 # Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
313 # Use the current target out directory as ANDROID_DATA.
314 # BIONIC_TEST_FLAGS is either empty or it comes from the user.
315 bionic-unit-tests-glibc-run: bionic-unit-tests-glibc
316 mkdir -p $(TARGET_OUT_DATA)/local/tmp
317 ANDROID_DATA=$(TARGET_OUT_DATA) \
318 ANDROID_ROOT=$(TARGET_OUT) \
319 $(HOST_OUT_EXECUTABLES)/bionic-unit-tests-glibc$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS)
321 # -----------------------------------------------------------------------------
322 # Run the unit tests built against x86 bionic on an x86 host.
323 # -----------------------------------------------------------------------------
325 ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
326 # gtest needs ANDROID_DATA/local/tmp for death test output.
327 # Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
328 # bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT.
329 # BIONIC_TEST_FLAGS is either empty or it comes from the user.
330 bionic-unit-tests-run-on-host: bionic-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
331 if [ ! -d /system -o ! -d /system/bin ]; then \
332 echo "Attempting to create /system/bin"; \
333 sudo mkdir -p -m 0777 /system/bin; \
335 mkdir -p $(TARGET_OUT_DATA)/local/tmp
336 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
337 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
338 ANDROID_DATA=$(TARGET_OUT_DATA) \
339 ANDROID_ROOT=$(TARGET_OUT) \
340 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
341 $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS)
344 ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86_64))
345 # add target to run lp32 tests
346 bionic-unit-tests-run-on-host32: bionic-unit-tests_32 $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
347 if [ ! -d /system -o ! -d /system/bin ]; then \
348 echo "Attempting to create /system/bin"; \
349 sudo mkdir -p -m 0777 /system/bin; \
351 mkdir -p $(TARGET_OUT_DATA)/local/tmp
352 cp $(TARGET_OUT_EXECUTABLES)/linker /system/bin
353 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
354 ANDROID_DATA=$(TARGET_OUT_DATA) \
355 ANDROID_ROOT=$(TARGET_OUT) \
356 LD_LIBRARY_PATH=$(2ND_TARGET_OUT_SHARED_LIBRARIES) \
357 $(2ND_TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests32 $(BIONIC_TEST_FLAGS)
362 include $(call first-makefiles-under,$(LOCAL_PATH))
363 endif # !BUILD_TINY_ANDROID