Android.mk revision f3c73901cb5ca4de2651151cf2c65b31a729466e
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# Tests for the device using bionic's .so. Run with: 194# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 195# ----------------------------------------------------------------------------- 196bionic-unit-tests_whole_static_libraries := \ 197 libBionicTests \ 198 199bionic-unit-tests_src_files := \ 200 dlfcn_test.cpp \ 201 202bionic-unit-tests_ldflags := \ 203 -Wl,--export-dynamic \ 204 -Wl,-u,DlSymTestFunction \ 205 206bionic-unit-tests_shared_libraries_target := \ 207 libdl \ 208 209module := bionic-unit-tests 210module_tag := optional 211build_type := target 212build_target := NATIVE_TEST 213include $(LOCAL_PATH)/Android.build.mk 214 215# ----------------------------------------------------------------------------- 216# Tests for the device linked against bionic's static library. Run with: 217# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 218# ----------------------------------------------------------------------------- 219bionic-unit-tests-static_whole_static_libraries := \ 220 libBionicTests \ 221 222bionic-unit-tests-static_static_libraries := \ 223 libstlport_static \ 224 libm \ 225 libc \ 226 libstdc++ \ 227 228bionic-unit-tests-static_force_static_executable := true 229 230module := bionic-unit-tests-static 231module_tag := optional 232build_type := target 233build_target := NATIVE_TEST 234include $(LOCAL_PATH)/Android.build.mk 235 236# ----------------------------------------------------------------------------- 237# Tests to run on the host and linked against glibc. Run with: 238# cd bionic/tests; mm bionic-unit-tests-glibc-run 239# ----------------------------------------------------------------------------- 240bionic-unit-tests-glibc_whole_static_libraries := \ 241 libBionicStandardTests \ 242 243bionic-unit-tests-glibc_ldlibs := \ 244 -lrt \ 245 246module := bionic-unit-tests-glibc 247module_tag := optional 248build_type := host 249build_target := NATIVE_TEST 250include $(LOCAL_PATH)/Android.build.mk 251 252# gtest needs ANDROID_DATA/local/tmp for death test output. 253# Make sure to create ANDROID_DATA/local/tmp if doesn't exist. 254# Use the current target out directory as ANDROID_DATA. 255# BIONIC_TEST_FLAGS is either empty or it comes from the user. 256bionic-unit-tests-glibc-run: bionic-unit-tests-glibc 257 mkdir -p $(TARGET_OUT_DATA)/local/tmp 258 ANDROID_DATA=$(TARGET_OUT_DATA) \ 259 ANDROID_ROOT=$(TARGET_OUT) \ 260 $(HOST_OUT_EXECUTABLES)/bionic-unit-tests-glibc $(BIONIC_TEST_FLAGS) 261 262# ----------------------------------------------------------------------------- 263# Run the unit tests built against x86 bionic on an x86 host. 264# ----------------------------------------------------------------------------- 265ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 266ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64)) 267ifeq ($(TARGET_ARCH),x86) 268LINKER = linker 269else 270LINKER = linker64 271endif 272# gtest needs ANDROID_DATA/local/tmp for death test output. 273# Make sure to create ANDROID_DATA/local/tmp if doesn't exist. 274# bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT. 275# BIONIC_TEST_FLAGS is either empty or it comes from the user. 276bionic-unit-tests-run-on-host: bionic-unit-tests $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh 277 if [ ! -d /system -o ! -d /system/bin ]; then \ 278 echo "Attempting to create /system/bin"; \ 279 sudo mkdir -p -m 0777 /system/bin; \ 280 fi 281 mkdir -p $(TARGET_OUT_DATA)/local/tmp 282 cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin 283 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin 284 ANDROID_DATA=$(TARGET_OUT_DATA) \ 285 ANDROID_ROOT=$(TARGET_OUT) \ 286 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \ 287 $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests $(BIONIC_TEST_FLAGS) 288endif 289endif 290 291endif # !BUILD_TINY_ANDROID 292