Android.mk revision 26ec9679ff01fb155ae21015f31cc95bed24f670
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# 16 17ifneq ($(BUILD_TINY_ANDROID),true) 18 19LOCAL_PATH := $(call my-dir) 20 21# ----------------------------------------------------------------------------- 22# Unit tests. 23# ----------------------------------------------------------------------------- 24 25ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64)) 26build_host := true 27else 28build_host := false 29endif 30 31# ----------------------------------------------------------------------------- 32# All standard tests. 33# ----------------------------------------------------------------------------- 34test_cflags = \ 35 -fstack-protector-all \ 36 -g \ 37 -Wall -Wextra \ 38 -Werror \ 39 -fno-builtin \ 40 41libBionicStandardTests_src_files := \ 42 buffer_tests.cpp \ 43 ctype_test.cpp \ 44 dirent_test.cpp \ 45 eventfd_test.cpp \ 46 fcntl_test.cpp \ 47 fenv_test.cpp \ 48 ftw_test.cpp \ 49 getauxval_test.cpp \ 50 getcwd_test.cpp \ 51 inttypes_test.cpp \ 52 libc_logging_test.cpp \ 53 libgen_test.cpp \ 54 locale_test.cpp \ 55 malloc_test.cpp \ 56 math_test.cpp \ 57 netdb_test.cpp \ 58 pthread_test.cpp \ 59 regex_test.cpp \ 60 sched_test.cpp \ 61 signal_test.cpp \ 62 stack_protector_test.cpp \ 63 stack_unwinding_test.cpp \ 64 stack_unwinding_test_impl.c \ 65 stdint_test.cpp \ 66 stdio_test.cpp \ 67 stdlib_test.cpp \ 68 string_test.cpp \ 69 strings_test.cpp \ 70 stubs_test.cpp \ 71 sstream_test.cpp \ 72 sys_epoll_test.cpp \ 73 sys_mman_test.cpp \ 74 sys_resource_test.cpp \ 75 sys_select_test.cpp \ 76 sys_sendfile_test.cpp \ 77 sys_socket_test.cpp \ 78 sys_stat_test.cpp \ 79 sys_statvfs_test.cpp \ 80 sys_syscall_test.cpp \ 81 sys_time_test.cpp \ 82 sys_types_test.cpp \ 83 sys_vfs_test.cpp \ 84 system_properties_test.cpp \ 85 time_test.cpp \ 86 unistd_test.cpp \ 87 wchar_test.cpp \ 88 89libBionicStandardTests_cflags := \ 90 $(test_cflags) \ 91 92libBionicStandardTests_ldlibs_host := \ 93 -lrt \ 94 95module := libBionicStandardTests 96module_tag := optional 97build_type := target 98build_target := STATIC_TEST_LIBRARY 99include $(LOCAL_PATH)/Android.build.mk 100build_type := host 101include $(LOCAL_PATH)/Android.build.mk 102 103# ----------------------------------------------------------------------------- 104# Fortify tests. 105# ----------------------------------------------------------------------------- 106$(foreach compiler,gcc clang, \ 107 $(foreach test,1 2, \ 108 $(eval fortify$(test)-tests-$(compiler)_cflags := \ 109 $(test_cflags) \ 110 -U_FORTIFY_SOURCE \ 111 -D_FORTIFY_SOURCE=$(test) \ 112 -DTEST_NAME=Fortify$(test)_$(compiler)); \ 113 $(eval fortify$(test)-tests-$(compiler)_cflags_host := \ 114 -Wno-error); \ 115 $(eval fortify$(test)-tests-$(compiler)_src_files := \ 116 fortify_test.cpp); \ 117 $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \ 118 ) \ 119) 120 121module := fortify1-tests-gcc 122module_tag := optional 123build_type := target 124build_target := STATIC_TEST_LIBRARY 125include $(LOCAL_PATH)/Android.build.mk 126build_type := host 127include $(LOCAL_PATH)/Android.build.mk 128 129module := fortify2-tests-gcc 130module_tag := optional 131build_type := target 132build_target := STATIC_TEST_LIBRARY 133include $(LOCAL_PATH)/Android.build.mk 134build_type := host 135include $(LOCAL_PATH)/Android.build.mk 136 137fortify1-tests-clang_clang_target := true 138fortify1-tests-clang_cflags_host := -D__clang__ 139 140module := fortify1-tests-clang 141module_tag := optional 142build_type := target 143build_target := STATIC_TEST_LIBRARY 144include $(LOCAL_PATH)/Android.build.mk 145build_type := host 146include $(LOCAL_PATH)/Android.build.mk 147 148fortify2-tests-clang_clang_target := true 149 150fortify2-tests-clang_cflags_host := -D__clang__ 151 152module := fortify2-tests-clang 153module_tag := optional 154build_type := target 155build_target := STATIC_TEST_LIBRARY 156include $(LOCAL_PATH)/Android.build.mk 157build_type := host 158include $(LOCAL_PATH)/Android.build.mk 159 160# ----------------------------------------------------------------------------- 161# Library of all tests (excluding the dynamic linker tests). 162# ----------------------------------------------------------------------------- 163libBionicTests_whole_static_libraries := \ 164 libBionicStandardTests \ 165 $(fortify_libs) \ 166 167module := libBionicTests 168module_tag := optional 169build_type := target 170build_target := STATIC_TEST_LIBRARY 171include $(LOCAL_PATH)/Android.build.mk 172build_type := host 173include $(LOCAL_PATH)/Android.build.mk 174 175# ----------------------------------------------------------------------------- 176# Library used by dlfcn tests. 177# ----------------------------------------------------------------------------- 178ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) 179no-elf-hash-table-library_src_files := \ 180 empty.cpp \ 181 182no-elf-hash-table-library_ldflags := \ 183 -Wl,--hash-style=gnu \ 184 185module := no-elf-hash-table-library 186module_tag := optional 187build_type := target 188build_target := SHARED_LIBRARY 189include $(LOCAL_PATH)/Android.build.mk 190endif 191 192# ----------------------------------------------------------------------------- 193# Library used by dlext tests - with/without GNU RELRO program header 194# ----------------------------------------------------------------------------- 195libdlext_test_src_files := \ 196 dlext_test_library.cpp \ 197 198libdlext_test_ldflags := \ 199 -Wl,-z,relro \ 200 201module := libdlext_test 202module_tag := optional 203build_type := target 204build_target := SHARED_LIBRARY 205include $(LOCAL_PATH)/Android.build.mk 206 207libdlext_test_norelro_src_files := \ 208 dlext_test_library.cpp \ 209 210libdlext_test_norelro_ldflags := \ 211 -Wl,-z,norelro \ 212 213module := libdlext_test_norelro 214module_tag := optional 215build_type := target 216build_target := SHARED_LIBRARY 217include $(LOCAL_PATH)/Android.build.mk 218 219# ----------------------------------------------------------------------------- 220# Tests for the device using bionic's .so. Run with: 221# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 222# ----------------------------------------------------------------------------- 223bionic-unit-tests_whole_static_libraries := \ 224 libBionicTests \ 225 226bionic-unit-tests_src_files := \ 227 dlext_test.cpp \ 228 dlfcn_test.cpp \ 229 230bionic-unit-tests_ldflags := \ 231 -Wl,--export-dynamic \ 232 -Wl,-u,DlSymTestFunction \ 233 234bionic-unit-tests_shared_libraries_target := \ 235 libdl \ 236 237module := bionic-unit-tests 238module_tag := optional 239multilib := both 240build_type := target 241build_target := NATIVE_TEST 242include $(LOCAL_PATH)/Android.build.mk 243 244# ----------------------------------------------------------------------------- 245# Tests for the device linked against bionic's static library. Run with: 246# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 247# ----------------------------------------------------------------------------- 248bionic-unit-tests-static_whole_static_libraries := \ 249 libBionicTests \ 250 251bionic-unit-tests-static_static_libraries := \ 252 libstlport_static \ 253 libm \ 254 libc \ 255 libstdc++ \ 256 257bionic-unit-tests-static_force_static_executable := true 258 259module := bionic-unit-tests-static 260module_tag := optional 261multilib := both 262build_type := target 263build_target := NATIVE_TEST 264include $(LOCAL_PATH)/Android.build.mk 265 266# ----------------------------------------------------------------------------- 267# Tests to run on the host and linked against glibc. Run with: 268# cd bionic/tests; mm bionic-unit-tests-glibc-run 269# ----------------------------------------------------------------------------- 270 271ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 272 273bionic-unit-tests-glibc_whole_static_libraries := \ 274 libBionicStandardTests \ 275 276bionic-unit-tests-glibc_ldlibs := \ 277 -lrt \ 278 279module := bionic-unit-tests-glibc 280module_tag := optional 281build_type := host 282build_target := NATIVE_TEST 283include $(LOCAL_PATH)/Android.build.mk 284 285ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86)) 286LINKER = linker64 287NATIVE_TEST_SUFFIX=64 288else 289LINKER = linker 290NATIVE_TEST_SUFFIX=32 291endif 292 293# gtest needs ANDROID_DATA/local/tmp for death test output. 294# Make sure to create ANDROID_DATA/local/tmp if doesn't exist. 295# Use the current target out directory as ANDROID_DATA. 296# BIONIC_TEST_FLAGS is either empty or it comes from the user. 297bionic-unit-tests-glibc-run: bionic-unit-tests-glibc 298 mkdir -p $(TARGET_OUT_DATA)/local/tmp 299 ANDROID_DATA=$(TARGET_OUT_DATA) \ 300 ANDROID_ROOT=$(TARGET_OUT) \ 301 $(HOST_OUT_EXECUTABLES)/bionic-unit-tests-glibc$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS) 302 303# ----------------------------------------------------------------------------- 304# Run the unit tests built against x86 bionic on an x86 host. 305# ----------------------------------------------------------------------------- 306 307ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64)) 308# gtest needs ANDROID_DATA/local/tmp for death test output. 309# Make sure to create ANDROID_DATA/local/tmp if doesn't exist. 310# bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT. 311# BIONIC_TEST_FLAGS is either empty or it comes from the user. 312bionic-unit-tests-run-on-host: bionic-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh 313 if [ ! -d /system -o ! -d /system/bin ]; then \ 314 echo "Attempting to create /system/bin"; \ 315 sudo mkdir -p -m 0777 /system/bin; \ 316 fi 317 mkdir -p $(TARGET_OUT_DATA)/local/tmp 318 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin 319 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin 320 ANDROID_DATA=$(TARGET_OUT_DATA) \ 321 ANDROID_ROOT=$(TARGET_OUT) \ 322 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \ 323 $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests$(NATIVE_TEST_SUFFIX) $(BIONIC_TEST_FLAGS) 324endif 325 326endif # linux-x86 327 328endif # !BUILD_TINY_ANDROID 329