Android.mk revision a4502d4e775e9038621cf32dd311ee6afa788dd0
1# Copyright (C) 2008 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15# Build control file for Bionic's test programs 16# define the BIONIC_TESTS environment variable to build the test programs 17# 18ifdef BIONIC_TESTS 19 20LOCAL_PATH:= $(call my-dir) 21 22# used to define a simple test program and build it as a standalone 23# device executable. 24# 25# you can use EXTRA_CFLAGS to indicate additional CFLAGS to use 26# in the build. the variable will be cleaned on exit 27# 28define device-test 29 $(foreach file,$(1), \ 30 $(eval include $(CLEAR_VARS)) \ 31 $(eval LOCAL_SRC_FILES := $(file)) \ 32 $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \ 33 $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \ 34 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 35 $(eval LOCAL_LDFLAGS += $(EXTRA_LDLIBS)) \ 36 $(eval LOCAL_MODULE_TAGS := tests) \ 37 $(eval include $(BUILD_EXECUTABLE)) \ 38 ) \ 39 $(eval EXTRA_CFLAGS :=) \ 40 $(eval EXTRA_LDLIBS :=) 41endef 42 43# same as 'device-test' but builds a host executable instead 44# you can use EXTRA_LDLIBS to indicate additional linker flags 45# 46define host-test 47 $(foreach file,$(1), \ 48 $(eval include $(CLEAR_VARS)) \ 49 $(eval LOCAL_SRC_FILES := $(file)) \ 50 $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \ 51 $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \ 52 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 53 $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \ 54 $(eval LOCAL_MODULE_TAGS := tests) \ 55 $(eval include $(BUILD_HOST_EXECUTABLE)) \ 56 ) \ 57 $(eval EXTRA_CFLAGS :=) \ 58 $(eval EXTRA_LDLIBS :=) 59endef 60 61# First, the tests in 'common' 62 63sources := \ 64 common/test_cpu_set.c \ 65 common/test_executable_destructor.c \ 66 common/test_getaddrinfo.c \ 67 common/test_gethostbyname.c \ 68 common/test_gethostname.c \ 69 common/test_pthread_cleanup_push.c \ 70 common/test_pthread_getcpuclockid.c \ 71 common/test_pthread_join.c \ 72 common/test_pthread_mutex.c \ 73 common/test_pthread_rwlock.c \ 74 common/test_pthread_once.c \ 75 common/test_semaphore.c \ 76 common/test_sem_post.c \ 77 common/test_seteuid.c \ 78 common/test_static_cpp_mutex.cpp \ 79 common/test_strftime_2039.c \ 80 common/test_tm_zone.c \ 81 common/test_udp.c \ 82 83# _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc 84# 85EXTRA_LDLIBS := -lpthread -lrt 86EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST 87$(call host-test, $(sources)) 88$(call device-test, $(sources)) 89 90# The 'test_static_executable_destructor is the same than 91# test_executable_destructor except that the generated program 92# is statically linked instead. 93include $(CLEAR_VARS) 94LOCAL_MODULE := test_static_executable_destructor 95LOCAL_SRC_FILES := common/test_executable_destructor.c 96LOCAL_MODULE_TAGS := tests 97LOCAL_STATIC_LIBRARIES := libc 98LOCAL_FORCE_STATIC_EXECUTABLE := true 99include $(BUILD_EXECUTABLE) 100 101include $(CLEAR_VARS) 102LOCAL_MODULE := test_static_executable_destructor 103LOCAL_SRC_FILES := common/test_executable_destructor.c 104LOCAL_MODULE_TAGS := tests 105LOCAL_LDFLAGS := -static 106include $(BUILD_HOST_EXECUTABLE) 107 108# The 'test_dlopen_null' tests requires specific linker flags 109# 110# The -Wl,--export-dynamic ensures that dynamic symbols are 111# exported from the executable. 112# 113# -Wl,-u,foo is used to ensure that symbol "foo" is not 114# garbage-collected by the gold linker, since the function 115# appears to be unused. 116# 117sources := common/test_dlopen_null.c \ 118 119EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo 120EXTRA_CFLAGS := -DHOST 121$(call host-test, $(sources)) 122 123EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo 124$(call device-test, $(sources)) 125 126 127sources := \ 128 common/test_libgen.c \ 129 130EXTRA_CFLAGS := -DHOST 131$(call host-test, $(sources)) 132$(call device-test, $(sources)) 133 134# Second, the Bionic-specific tests 135 136sources := \ 137 bionic/test_mutex.c \ 138 bionic/test_cond.c \ 139 bionic/test_getgrouplist.c \ 140 bionic/test_netinet_icmp.c \ 141 bionic/test_pthread_cond.c \ 142 bionic/test_pthread_create.c \ 143 bionic/test_setjmp.c \ 144 145$(call device-test, $(sources)) 146 147# Third, the other tests 148 149sources := \ 150 other/bench_locks.c \ 151 other/test_aligned.c \ 152 other/test_arc4random.c \ 153 other/test_atomics.c \ 154 other/test_sysconf.c \ 155 other/test_system.c \ 156 other/test_thread_max.c \ 157 other/test_timer_create.c \ 158 other/test_timer_create2.c \ 159 other/test_timer_create3.c \ 160 other/test_vfprintf_leak.c \ 161 162$(call device-test, $(sources)) 163 164# The relocations test is a bit special, since we need 165# to build one shared object and one executable that depends 166# on it. 167 168include $(CLEAR_VARS) 169LOCAL_SRC_FILES := bionic/lib_relocs.c 170LOCAL_MODULE := libtest_relocs 171LOCAL_PRELINK_MODULE := false 172LOCAL_MODULE_TAGS := tests 173include $(BUILD_SHARED_LIBRARY) 174 175include $(CLEAR_VARS) 176LOCAL_SRC_FILES := bionic/test_relocs.c 177LOCAL_MODULE := test_relocs 178LOCAL_SHARED_LIBRARIES := libtest_relocs 179LOCAL_MODULE_TAGS := tests 180include $(BUILD_EXECUTABLE) 181 182# This test tries to see if the static constructors in a 183# shared library are only called once. We thus need to 184# build a shared library, then call it from another 185# program. 186# 187include $(CLEAR_VARS) 188LOCAL_SRC_FILES := bionic/lib_static_init.cpp 189LOCAL_MODULE := libtest_static_init 190LOCAL_PRELINK_MODULE := false 191LOCAL_MODULE_TAGS := tests 192include $(BUILD_SHARED_LIBRARY) 193 194include $(CLEAR_VARS) 195LOCAL_SRC_FILES := bionic/test_static_init.cpp 196LOCAL_MODULE := test_static_init 197LOCAL_SHARED_LIBRARIES := libtest_static_init 198LOCAL_MODULE_TAGS := tests 199include $(BUILD_EXECUTABLE) 200 201# This test tries to see if static destructors are called 202# on dlclose(). We thus need to generate a C++ shared library 203include $(CLEAR_VARS) 204LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp 205LOCAL_MODULE := libdlclosetest1 206LOCAL_PRELINK_MODULE := false 207LOCAL_MODULE_TAGS := tests 208include $(BUILD_SHARED_LIBRARY) 209 210# And this one does the same with __attribute__((constructor)) 211# and __attribute__((destructor)) 212include $(CLEAR_VARS) 213LOCAL_SRC_FILES := bionic/libdlclosetest2.c 214LOCAL_MODULE := libdlclosetest2 215LOCAL_PRELINK_MODULE := false 216LOCAL_MODULE_TAGS := tests 217include $(BUILD_SHARED_LIBRARY) 218 219include $(CLEAR_VARS) 220LOCAL_SRC_FILES := bionic/test_dlclose_destruction.c 221LOCAL_MODULE := test_dlclose_destruction 222LOCAL_LDFLAGS := -ldl 223#LOCAL_SHARED_LIBRARIES := libdlclosetest1 libdlclosetest2 224LOCAL_MODULE_TAGS := tests 225include $(BUILD_EXECUTABLE) 226 227# Testing 'clone' is only possible on Linux systems 228include $(CLEAR_VARS) 229LOCAL_SRC_FILES := common/test_clone.c 230LOCAL_MODULE := test_clone 231LOCAL_MODULE_TAGS := tests 232include $(BUILD_EXECUTABLE) 233 234ifeq ($(HOST_OS),linux) 235include $(CLEAR_VARS) 236LOCAL_SRC_FILES := common/test_clone.c 237LOCAL_MODULE := test_clone 238LOCAL_MODULE_TAGS := tests 239include $(BUILD_HOST_EXECUTABLE) 240endif 241 242# TODO: Add a variety of GLibc test programs too... 243 244# Hello World to test libstdc++ support 245 246sources := \ 247 common/hello_world.cpp \ 248 249EXTRA_CFLAGS := -mandroid 250#$(call device-test, $(sources)) 251 252endif # BIONIC_TESTS 253