]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - tests/Android.mk
Merge "Ignore multiple symbol definition errors."
[android-sdk/platform-bionic.git] / tests / Android.mk
1 #
2 # Copyright (C) 2012 The Android Open Source Project
3 #
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
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
17 ifneq ($(BUILD_TINY_ANDROID),true)
19 LOCAL_PATH := $(call my-dir)
21 # -----------------------------------------------------------------------------
22 # Unit tests.
23 # -----------------------------------------------------------------------------
25 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
26 build_host := true
27 else
28 build_host := false
29 endif
31 # -----------------------------------------------------------------------------
32 # All standard tests.
33 # -----------------------------------------------------------------------------
34 test_cflags = \
35     -fstack-protector-all \
36     -g \
37     -Wall -Wextra -Wunused \
38     -Werror \
39     -fno-builtin \
41 test_cflags += -D__STDC_LIMIT_MACROS  # For glibc.
43 ifeq ($(MALLOC_IMPL),dlmalloc)
44 test_cflags += -DUSE_DLMALLOC
45 else
46 test_cflags += -DUSE_JEMALLOC
47 endif
49 test_cppflags = \
50     -std=gnu++11 \
52 libBionicStandardTests_src_files := \
53     arpa_inet_test.cpp \
54     buffer_tests.cpp \
55     ctype_test.cpp \
56     dirent_test.cpp \
57     eventfd_test.cpp \
58     fcntl_test.cpp \
59     fenv_test.cpp \
60     ftw_test.cpp \
61     getauxval_test.cpp \
62     getcwd_test.cpp \
63     inttypes_test.cpp \
64     libc_logging_test.cpp \
65     libgen_test.cpp \
66     locale_test.cpp \
67     malloc_test.cpp \
68     math_cos_test.cpp \
69     math_cosf_test.cpp \
70     math_exp_test.cpp \
71     math_expf_test.cpp \
72     math_log_test.cpp \
73     math_logf_test.cpp \
74     math_pow_test.cpp \
75     math_powf_test.cpp \
76     math_sin_test.cpp \
77     math_sinf_test.cpp \
78     math_sincos_test.cpp \
79     math_sincosf_test.cpp \
80     math_tan_test.cpp \
81     math_tanf_test.cpp \
82     math_test.cpp \
83     mntent_test.cpp \
84     netdb_test.cpp \
85     pthread_test.cpp \
86     regex_test.cpp \
87     sched_test.cpp \
88     search_test.cpp \
89     semaphore_test.cpp \
90     signal_test.cpp \
91     stack_protector_test.cpp \
92     stdatomic_test.cpp \
93     stdint_test.cpp \
94     stdio_test.cpp \
95     stdio_ext_test.cpp \
96     stdlib_test.cpp \
97     string_test.cpp \
98     string_posix_strerror_r_test.cpp \
99     strings_test.cpp \
100     stubs_test.cpp \
101     sstream_test.cpp \
102     sys_epoll_test.cpp \
103     sys_mman_test.cpp \
104     sys_resource_test.cpp \
105     sys_select_test.cpp \
106     sys_sendfile_test.cpp \
107     sys_socket_test.cpp \
108     sys_stat_test.cpp \
109     sys_statvfs_test.cpp \
110     sys_syscall_test.cpp \
111     sys_time_test.cpp \
112     sys_types_test.cpp \
113     sys_vfs_test.cpp \
114     system_properties_test.cpp \
115     time_test.cpp \
116     uchar_test.cpp \
117     uniqueptr_test.cpp \
118     unistd_test.cpp \
119     wchar_test.cpp \
121 libBionicStandardTests_cflags := \
122     $(test_cflags) \
124 ifeq ($(MALLOC_IMPL),dlmalloc)
125   libBionicStandardTests_cflags += -DUSE_DLMALLOC
126 else
127   libBionicStandardTests_cflags += -DUSE_JEMALLOC
128 endif
130 libBionicStandardTests_cppflags := \
131     $(test_cppflags) \
133 libBionicStandardTests_c_includes := \
134     bionic/libc \
135     external/tinyxml2 \
137 libBionicStandardTests_ldlibs_host := \
138     -lrt \
140 module := libBionicStandardTests
141 module_tag := optional
142 build_type := target
143 build_target := STATIC_TEST_LIBRARY
144 include $(LOCAL_PATH)/Android.build.mk
145 build_type := host
146 include $(LOCAL_PATH)/Android.build.mk
148 # -----------------------------------------------------------------------------
149 # Fortify tests.
150 # -----------------------------------------------------------------------------
151 $(foreach compiler,gcc clang, \
152   $(foreach test,1 2, \
153     $(eval fortify$(test)-tests-$(compiler)_cflags := \
154       $(test_cflags) \
155       -U_FORTIFY_SOURCE \
156       -D_FORTIFY_SOURCE=$(test) \
157       -DTEST_NAME=Fortify$(test)_$(compiler)); \
158     $(eval fortify$(test)-tests-$(compiler)_cflags_host := \
159       -Wno-error); \
160     $(eval fortify$(test)-tests-$(compiler)_src_files := \
161       fortify_test.cpp); \
162     $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \
163   ) \
166 module := fortify1-tests-gcc
167 module_tag := optional
168 build_type := target
169 build_target := STATIC_TEST_LIBRARY
170 include $(LOCAL_PATH)/Android.build.mk
171 build_type := host
172 include $(LOCAL_PATH)/Android.build.mk
174 module := fortify2-tests-gcc
175 module_tag := optional
176 build_type := target
177 build_target := STATIC_TEST_LIBRARY
178 include $(LOCAL_PATH)/Android.build.mk
179 build_type := host
180 include $(LOCAL_PATH)/Android.build.mk
182 fortify1-tests-clang_clang_target := true
183 fortify1-tests-clang_cflags_host := -D__clang__
185 module := fortify1-tests-clang
186 module_tag := optional
187 build_type := target
188 build_target := STATIC_TEST_LIBRARY
189 include $(LOCAL_PATH)/Android.build.mk
190 build_type := host
191 include $(LOCAL_PATH)/Android.build.mk
193 fortify2-tests-clang_clang_target := true
195 fortify2-tests-clang_cflags_host := -D__clang__
197 module := fortify2-tests-clang
198 module_tag := optional
199 build_type := target
200 build_target := STATIC_TEST_LIBRARY
201 include $(LOCAL_PATH)/Android.build.mk
202 build_type := host
203 include $(LOCAL_PATH)/Android.build.mk
205 # -----------------------------------------------------------------------------
206 # Library of all tests (excluding the dynamic linker tests).
207 # -----------------------------------------------------------------------------
208 libBionicTests_whole_static_libraries := \
209     libBionicStandardTests \
210     $(fortify_libs) \
212 module := libBionicTests
213 module_tag := optional
214 build_type := target
215 build_target := STATIC_TEST_LIBRARY
216 include $(LOCAL_PATH)/Android.build.mk
217 build_type := host
218 include $(LOCAL_PATH)/Android.build.mk
220 # -----------------------------------------------------------------------------
221 # Tests for the device using bionic's .so. Run with:
222 #   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
223 #   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
224 # -----------------------------------------------------------------------------
225 bionic-unit-tests_whole_static_libraries := \
226     libBionicTests \
228 bionic-unit-tests_static_libraries := \
229     libtinyxml2 \
230     liblog \
232 bionic-unit-tests_src_files := \
233     atexit_test.cpp \
234     dlext_test.cpp \
235     dlfcn_test.cpp \
236     stack_unwinding_test.cpp \
237     stack_unwinding_test_impl.c \
239 bionic-unit-tests_cflags := $(test_cflags)
241 bionic-unit-tests_conlyflags := \
242     -fexceptions \
243     -fnon-call-exceptions \
245 bionic-unit-tests_cppflags := $(test_cppflags)
247 bionic-unit-tests_ldflags := \
248     -Wl,--export-dynamic \
249     -Wl,-u,DlSymTestFunction \
251 bionic-unit-tests_c_includes := \
252     bionic/libc \
253     $(call include-path-for, libpagemap) \
255 bionic-unit-tests_shared_libraries_target := \
256     libdl \
257     libpagemap \
259 module := bionic-unit-tests
260 module_tag := optional
261 build_type := target
262 build_target := NATIVE_TEST
263 include $(LOCAL_PATH)/Android.build.mk
265 # -----------------------------------------------------------------------------
266 # Tests for the device linked against bionic's static library. Run with:
267 #   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
268 #   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
269 # -----------------------------------------------------------------------------
270 bionic-unit-tests-static_whole_static_libraries := \
271     libBionicTests \
273 bionic-unit-tests-static_static_libraries := \
274     libstlport_static \
275     libm \
276     libc \
277     libstdc++ \
278     libtinyxml2 \
279     liblog \
281 bionic-unit-tests-static_force_static_executable := true
283 # libc and libc++ both define std::nothrow. libc's is a private symbol, but this
284 # still causes issues when linking libc.a and libc++.a, since private isn't
285 # effective until it has been linked. To fix this, just allow multiple symbol
286 # definitions for the static tests.
287 bionic-unit-tests-static_ldflags := -Wl,--allow-multiple-definition
289 module := bionic-unit-tests-static
290 module_tag := optional
291 build_type := target
292 build_target := NATIVE_TEST
293 include $(LOCAL_PATH)/Android.build.mk
295 # -----------------------------------------------------------------------------
296 # Tests to run on the host and linked against glibc. Run with:
297 #   cd bionic/tests; mm bionic-unit-tests-glibc-run
298 # -----------------------------------------------------------------------------
300 ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
302 bionic-unit-tests-glibc_src_files := \
303     atexit_test.cpp \
304     dlfcn_test.cpp \
306 bionic-unit-tests-glibc_whole_static_libraries := \
307     libBionicStandardTests \
309 bionic-unit-tests-glibc_ldlibs := \
310     -lrt -ldl \
312 bionic-unit-tests-glibc_c_includes := \
313     bionic/libc \
315 bionic-unit-tests-glibc_cflags := $(test_cflags)
316 bionic-unit-tests-glibc_cppflags := $(test_cppflags)
317 bionic-unit-tests-glibc_ldflags := -Wl,--export-dynamic
319 module := bionic-unit-tests-glibc
320 module_tag := optional
321 build_type := host
322 build_target := NATIVE_TEST
323 include $(LOCAL_PATH)/Android.build.mk
325 ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
326 LINKER = linker64
327 NATIVE_TEST_SUFFIX=64
328 else
329 LINKER = linker
330 NATIVE_TEST_SUFFIX=32
331 endif
333 # gtest needs ANDROID_DATA/local/tmp for death test output.
334 # Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
335 # Use the current target out directory as ANDROID_DATA.
336 # BIONIC_TEST_FLAGS is either empty or it comes from the user.
337 bionic-unit-tests-glibc-run: bionic-unit-tests-glibc
338         mkdir -p $(TARGET_OUT_DATA)/local/tmp
339         ANDROID_DATA=$(TARGET_OUT_DATA) \
340         ANDROID_ROOT=$(TARGET_OUT) \
341                 $(HOST_OUT_EXECUTABLES)/bionic-unit-tests-glibc$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS)
343 # -----------------------------------------------------------------------------
344 # Run the unit tests built against x86 bionic on an x86 host.
345 # -----------------------------------------------------------------------------
347 ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
348 # gtest needs ANDROID_DATA/local/tmp for death test output.
349 # Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
350 # bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT.
351 # BIONIC_TEST_FLAGS is either empty or it comes from the user.
352 bionic-unit-tests-run-on-host: bionic-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
353         if [ ! -d /system -o ! -d /system/bin ]; then \
354           echo "Attempting to create /system/bin"; \
355           sudo mkdir -p -m 0777 /system/bin; \
356         fi
357         mkdir -p $(TARGET_OUT_DATA)/local/tmp
358         cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
359         cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
360         ANDROID_DATA=$(TARGET_OUT_DATA) \
361         ANDROID_ROOT=$(TARGET_OUT) \
362         LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
363                 $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS)
364 endif
366 ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86_64))
367 # add target to run lp32 tests
368 bionic-unit-tests-run-on-host32: bionic-unit-tests_32 $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
369         if [ ! -d /system -o ! -d /system/bin ]; then \
370           echo "Attempting to create /system/bin"; \
371           sudo mkdir -p -m 0777 /system/bin; \
372         fi
373         mkdir -p $(TARGET_OUT_DATA)/local/tmp
374         cp $(TARGET_OUT_EXECUTABLES)/linker /system/bin
375         cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
376         ANDROID_DATA=$(TARGET_OUT_DATA) \
377         ANDROID_ROOT=$(TARGET_OUT) \
378         LD_LIBRARY_PATH=$(2ND_TARGET_OUT_SHARED_LIBRARIES) \
379                 $(2ND_TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests32 $(BIONIC_TEST_FLAGS)
380 endif
382 endif # linux-x86
384 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/Android.build.mk
386 include $(call first-makefiles-under,$(LOCAL_PATH))
387 endif # !BUILD_TINY_ANDROID