Android.mk revision 6f09971503f9bea177168d1599e925a5b22d18dd
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_getaddrinfo.c \ 65 common/test_gethostbyname.c \ 66 common/test_gethostname.c \ 67 common/test_pthread_cleanup_push.c \ 68 common/test_pthread_getcpuclockid.c \ 69 common/test_pthread_join.c \ 70 common/test_pthread_mutex.c \ 71 common/test_pthread_once.c \ 72 common/test_semaphore.c \ 73 common/test_sem_post.c \ 74 common/test_seteuid.c \ 75 common/test_static_cpp_mutex.cpp \ 76 common/test_strftime_2039.c \ 77 common/test_tm_zone.c \ 78 common/test_udp.c \ 79 80# _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc 81# 82EXTRA_LDLIBS := -lpthread -lrt 83EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST 84$(call host-test, $(sources)) 85$(call device-test, $(sources)) 86 87# The 'test_dlopen_null' tests requires specific linker flags 88# 89# The -Wl,--export-dynamic ensures that dynamic symbols are 90# exported from the executable. 91# 92# -Wl,-u,foo is used to ensure that symbol "foo" is not 93# garbage-collected by the gold linker, since the function 94# appears to be unused. 95# 96sources := common/test_dlopen_null.c \ 97 98EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo 99EXTRA_CFLAGS := -DHOST 100$(call host-test, $(sources)) 101 102EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo 103$(call device-test, $(sources)) 104 105 106sources := \ 107 common/test_libgen.c \ 108 109EXTRA_CFLAGS := -DHOST 110$(call host-test, $(sources)) 111$(call device-test, $(sources)) 112 113# Second, the Bionic-specific tests 114 115sources := \ 116 bionic/test_mutex.c \ 117 bionic/test_cond.c \ 118 bionic/test_getgrouplist.c \ 119 bionic/test_netinet_icmp.c \ 120 bionic/test_pthread_cond.c \ 121 bionic/test_pthread_create.c \ 122 123$(call device-test, $(sources)) 124 125# Third, the other tests 126 127sources := \ 128 other/bench_locks.c \ 129 other/test_aligned.c \ 130 other/test_arc4random.c \ 131 other/test_atomics.c \ 132 other/test_sysconf.c \ 133 other/test_system.c \ 134 other/test_thread_max.c \ 135 other/test_timer_create.c \ 136 other/test_timer_create2.c \ 137 other/test_timer_create3.c \ 138 other/test_vfprintf_leak.c \ 139 140$(call device-test, $(sources)) 141 142# The relocations test is a bit special, since we need 143# to build one shared object and one executable that depends 144# on it. 145 146include $(CLEAR_VARS) 147LOCAL_SRC_FILES := bionic/lib_relocs.c 148LOCAL_MODULE := libtest_relocs 149LOCAL_PRELINK_MODULE := false 150include $(BUILD_SHARED_LIBRARY) 151 152include $(CLEAR_VARS) 153LOCAL_SRC_FILES := bionic/test_relocs.c 154LOCAL_MODULE := test_relocs 155LOCAL_SHARED_LIBRARIES := libtest_relocs 156include $(BUILD_EXECUTABLE) 157 158# This test tries to see if the static constructors in a 159# shared library are only called once. We thus need to 160# build a shared library, then call it from another 161# program. 162# 163include $(CLEAR_VARS) 164LOCAL_SRC_FILES := bionic/lib_static_init.cpp 165LOCAL_MODULE := libtest_static_init 166LOCAL_PRELINK_MODULE := false 167include $(BUILD_SHARED_LIBRARY) 168 169include $(CLEAR_VARS) 170LOCAL_SRC_FILES := bionic/test_static_init.cpp 171LOCAL_MODULE := test_static_init 172LOCAL_SHARED_LIBRARIES := libtest_static_init 173include $(BUILD_EXECUTABLE) 174 175# This test tries to see if static destructors are called 176# on dlclose(). We thus need to generate a C++ shared library 177include $(CLEAR_VARS) 178LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp 179LOCAL_MODULE := libdlclosetest1 180LOCAL_PRELINK_MODULE := false 181include $(BUILD_SHARED_LIBRARY) 182 183include $(CLEAR_VARS) 184LOCAL_SRC_FILES := bionic/test_dlclose_destruction.c 185LOCAL_MODULE := test_dlclose_destruction 186LOCAL_LDFLAGS := -ldl 187#LOCAL_SHARED_LIBRARIES := libdlclosetest1 188include $(BUILD_EXECUTABLE) 189 190# Testing 'clone' is only possible on Linux systems 191include $(CLEAR_VARS) 192LOCAL_SRC_FILES := common/test_clone.c 193LOCAL_MODULE := test_clone 194include $(BUILD_EXECUTABLE) 195 196ifeq ($(HOST_OS),linux) 197include $(CLEAR_VARS) 198LOCAL_SRC_FILES := common/test_clone.c 199LOCAL_MODULE := test_clone 200include $(BUILD_HOST_EXECUTABLE) 201endif 202 203# TODO: Add a variety of GLibc test programs too... 204 205# Hello World to test libstdc++ support 206 207sources := \ 208 common/hello_world.cpp \ 209 210EXTRA_CFLAGS := -mandroid 211#$(call device-test, $(sources)) 212 213endif # BIONIC_TESTS 214