Android.mk revision 10112f51911af42c4e32791858f498900155f9af
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_MODULE_TAGS := tests) \ 36 $(eval include $(BUILD_EXECUTABLE)) \ 37 ) \ 38 $(eval EXTRA_CFLAGS :=) 39endef 40 41# same as 'device-test' but builds a host executable instead 42# you can use EXTRA_LDLIBS to indicate additional linker flags 43# 44define host-test 45 $(foreach file,$(1), \ 46 $(eval include $(CLEAR_VARS)) \ 47 $(eval LOCAL_SRC_FILES := $(file)) \ 48 $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \ 49 $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \ 50 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 51 $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \ 52 $(eval LOCAL_MODULE_TAGS := tests) \ 53 $(eval include $(BUILD_HOST_EXECUTABLE)) \ 54 ) \ 55 $(eval EXTRA_CFLAGS :=) \ 56 $(eval EXTRA_LDLIBS :=) 57endef 58 59# First, the tests in 'common' 60 61sources := \ 62 common/test_getaddrinfo.c \ 63 common/test_gethostbyname.c \ 64 common/test_gethostname.c \ 65 common/test_pthread_cleanup_push.c \ 66 common/test_pthread_getcpuclockid.c \ 67 common/test_pthread_join.c \ 68 common/test_pthread_mutex.c \ 69 common/test_pthread_rwlock.c \ 70 common/test_pthread_once.c \ 71 common/test_semaphore.c \ 72 common/test_sem_post.c \ 73 common/test_seteuid.c \ 74 common/test_static_cpp_mutex.cpp \ 75 common/test_strftime_2039.c \ 76 common/test_tm_zone.c \ 77 common/test_udp.c \ 78 79# _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc 80# 81EXTRA_LDLIBS := -lpthread -lrt 82EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST 83$(call host-test, $(sources)) 84$(call device-test, $(sources)) 85 86sources := \ 87 common/test_libgen.c \ 88 89EXTRA_CFLAGS := -DHOST 90$(call host-test, $(sources)) 91$(call device-test, $(sources)) 92 93# Second, the Bionic-specific tests 94 95sources := \ 96 bionic/test_mutex.c \ 97 bionic/test_cond.c \ 98 bionic/test_getgrouplist.c \ 99 bionic/test_netinet_icmp.c \ 100 bionic/test_pthread_cond.c \ 101 bionic/test_pthread_create.c \ 102 bionic/test_setjmp.c \ 103 104$(call device-test, $(sources)) 105 106# Third, the other tests 107 108sources := \ 109 other/bench_locks.c \ 110 other/test_aligned.c \ 111 other/test_arc4random.c \ 112 other/test_atomics.c \ 113 other/test_sysconf.c \ 114 other/test_system.c \ 115 other/test_thread_max.c \ 116 other/test_timer_create.c \ 117 other/test_timer_create2.c \ 118 other/test_timer_create3.c \ 119 other/test_vfprintf_leak.c \ 120 121$(call device-test, $(sources)) 122 123# The relocations test is a bit special, since we need 124# to build one shared object and one executable that depends 125# on it. 126 127include $(CLEAR_VARS) 128LOCAL_SRC_FILES := bionic/lib_relocs.c 129LOCAL_MODULE := libtest_relocs 130LOCAL_PRELINK_MODULE := false 131include $(BUILD_SHARED_LIBRARY) 132 133include $(CLEAR_VARS) 134LOCAL_SRC_FILES := bionic/test_relocs.c 135LOCAL_MODULE := test_relocs 136LOCAL_SHARED_LIBRARIES := libtest_relocs 137include $(BUILD_EXECUTABLE) 138 139# This test tries to see if the static constructors in a 140# shared library are only called once. We thus need to 141# build a shared library, then call it from another 142# program. 143# 144include $(CLEAR_VARS) 145LOCAL_SRC_FILES := bionic/lib_static_init.cpp 146LOCAL_MODULE := libtest_static_init 147LOCAL_PRELINK_MODULE := false 148include $(BUILD_SHARED_LIBRARY) 149 150include $(CLEAR_VARS) 151LOCAL_SRC_FILES := bionic/test_static_init.cpp 152LOCAL_MODULE := test_static_init 153LOCAL_SHARED_LIBRARIES := libtest_static_init 154include $(BUILD_EXECUTABLE) 155 156# This test tries to see if static destructors are called 157# on dlclose(). We thus need to generate a C++ shared library 158include $(CLEAR_VARS) 159LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp 160LOCAL_MODULE := libdlclosetest1 161LOCAL_PRELINK_MODULE := false 162include $(BUILD_SHARED_LIBRARY) 163 164include $(CLEAR_VARS) 165LOCAL_SRC_FILES := bionic/test_dlclose_destruction.c 166LOCAL_MODULE := test_dlclose_destruction 167LOCAL_LDFLAGS := -ldl 168#LOCAL_SHARED_LIBRARIES := libdlclosetest1 169include $(BUILD_EXECUTABLE) 170 171# Testing 'clone' is only possible on Linux systems 172include $(CLEAR_VARS) 173LOCAL_SRC_FILES := common/test_clone.c 174LOCAL_MODULE := test_clone 175include $(BUILD_EXECUTABLE) 176 177ifeq ($(HOST_OS),linux) 178include $(CLEAR_VARS) 179LOCAL_SRC_FILES := common/test_clone.c 180LOCAL_MODULE := test_clone 181include $(BUILD_HOST_EXECUTABLE) 182endif 183 184# TODO: Add a variety of GLibc test programs too... 185 186# Hello World to test libstdc++ support 187 188sources := \ 189 common/hello_world.cpp \ 190 191EXTRA_CFLAGS := -mandroid 192#$(call device-test, $(sources)) 193 194endif # BIONIC_TESTS 195