Android.mk revision 611cdccd9690a9083816f6d4746e998d58250a86
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 $(info LOCAL_MODULE=$(LOCAL_MODULE))) \
35    $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
36    $(eval LOCAL_MODULE_TAGS := tests) \
37    $(eval include $(BUILD_EXECUTABLE)) \
38  ) \
39  $(eval EXTRA_CFLAGS :=)
40endef
41
42# same as 'device-test' but builds a host executable instead
43# you can use EXTRA_LDLIBS to indicate additional linker flags
44#
45define host-test
46  $(foreach file,$(1), \
47    $(eval include $(CLEAR_VARS)) \
48    $(eval LOCAL_SRC_FILES := $(file)) \
49    $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \
50    $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \
51    $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE) file=$(file))) \
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_once.c \
71    common/test_semaphore.c \
72    common/test_seteuid.c \
73    common/test_static_cpp_mutex.cpp \
74    common/test_tm_zone.c \
75    common/test_udp.c \
76
77EXTRA_LDLIBS := -lpthread -lrt
78$(call host-test, $(sources))
79$(call device-test, $(sources))
80
81sources := \
82    common/test_libgen.c \
83
84EXTRA_CFLAGS := -DHOST
85$(call host-test, $(sources))
86$(call device-test, $(sources))
87
88# Second, the Bionic-specific tests
89
90sources :=  \
91    bionic/test_mutex.c \
92    bionic/test_cond.c \
93    bionic/test_getgrouplist.c \
94    bionic/test_netinet_icmp.c \
95    bionic/test_pthread_cond.c \
96    bionic/test_pthread_create.c \
97
98$(call device-test, $(sources))
99
100# Third, the other tests
101
102sources := \
103    other/bench_locks.c \
104    other/test_aligned.c \
105    other/test_arc4random.c \
106    other/test_atomics.c \
107    other/test_sysconf.c \
108    other/test_system.c \
109    other/test_thread_max.c \
110    other/test_timer_create.c \
111    other/test_timer_create2.c \
112    other/test_timer_create3.c \
113    other/test_vfprintf_leak.c \
114
115$(call device-test, $(sources))
116
117# The relocations test is a bit special, since we need
118# to build one shared object and one executable that depends
119# on it.
120
121include $(CLEAR_VARS)
122LOCAL_SRC_FILES := bionic/lib_relocs.c
123LOCAL_MODULE    := libtest_relocs
124LOCAL_PRELINK_MODULE := false
125include $(BUILD_SHARED_LIBRARY)
126
127include $(CLEAR_VARS)
128LOCAL_SRC_FILES := bionic/test_relocs.c
129LOCAL_MODULE    := test_relocs
130LOCAL_SHARED_LIBRARIES := libtest_relocs
131include $(BUILD_EXECUTABLE)
132
133# This test tries to see if the static constructors in a
134# shared library are only called once. We thus need to
135# build a shared library, then call it from another
136# program.
137#
138include $(CLEAR_VARS)
139LOCAL_SRC_FILES := bionic/lib_static_init.cpp
140LOCAL_MODULE    := libtest_static_init
141LOCAL_PRELINK_MODULE := false
142include $(BUILD_SHARED_LIBRARY)
143
144include $(CLEAR_VARS)
145LOCAL_SRC_FILES := bionic/test_static_init.cpp
146LOCAL_MODULE    := test_static_init
147LOCAL_SHARED_LIBRARIES := libtest_static_init
148include $(BUILD_EXECUTABLE)
149
150# TODO: Add a variety of GLibc test programs too...
151
152# Hello World to test libstdc++ support
153
154sources := \
155    common/hello_world.cpp \
156
157EXTRA_CFLAGS := -mandroid
158#$(call device-test, $(sources))
159
160endif  # BIONIC_TESTS
161