1 # Copyright (C) 2008 The Android Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # Build control file for Bionic's test programs
16 # define the BIONIC_TESTS environment variable to build the test programs
20 LOCAL_PATH:= $(call my-dir)
22 # used to define a simple test program and build it as a standalone
25 # you can use EXTRA_CFLAGS to indicate additional CFLAGS to use
26 # in the build. the variable will be cleaned on exit
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)) \
39 $(eval EXTRA_CFLAGS :=) \
40 $(eval EXTRA_LDLIBS :=)
43 # same as 'device-test' but builds a host executable instead
44 # you can use EXTRA_LDLIBS to indicate additional linker flags
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)) \
57 $(eval EXTRA_CFLAGS :=) \
58 $(eval EXTRA_LDLIBS :=)
61 # First, the tests in 'common'
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_rwlock.c \
72 common/test_pthread_once.c \
73 common/test_semaphore.c \
74 common/test_sem_post.c \
75 common/test_seteuid.c \
76 common/test_static_cpp_mutex.cpp \
77 common/test_strftime_2039.c \
78 common/test_tm_zone.c \
81 # _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc
83 EXTRA_LDLIBS := -lpthread -lrt
84 EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST
85 $(call host-test, $(sources))
86 $(call device-test, $(sources))
88 # The 'test_dlopen_null' tests requires specific linker flags
90 # The -Wl,--export-dynamic ensures that dynamic symbols are
91 # exported from the executable.
93 # -Wl,-u,foo is used to ensure that symbol "foo" is not
94 # garbage-collected by the gold linker, since the function
95 # appears to be unused.
97 sources := common/test_dlopen_null.c \
99 EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo
100 EXTRA_CFLAGS := -DHOST
101 $(call host-test, $(sources))
103 EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo
104 $(call device-test, $(sources))
108 common/test_libgen.c \
110 EXTRA_CFLAGS := -DHOST
111 $(call host-test, $(sources))
112 $(call device-test, $(sources))
114 # Second, the Bionic-specific tests
117 bionic/test_mutex.c \
119 bionic/test_getgrouplist.c \
120 bionic/test_netinet_icmp.c \
121 bionic/test_pthread_cond.c \
122 bionic/test_pthread_create.c \
123 bionic/test_setjmp.c \
125 $(call device-test, $(sources))
127 # Third, the other tests
130 other/bench_locks.c \
131 other/test_aligned.c \
132 other/test_arc4random.c \
133 other/test_atomics.c \
134 other/test_sysconf.c \
135 other/test_system.c \
136 other/test_thread_max.c \
137 other/test_timer_create.c \
138 other/test_timer_create2.c \
139 other/test_timer_create3.c \
140 other/test_vfprintf_leak.c \
142 $(call device-test, $(sources))
144 # The relocations test is a bit special, since we need
145 # to build one shared object and one executable that depends
148 include $(CLEAR_VARS)
149 LOCAL_SRC_FILES := bionic/lib_relocs.c
150 LOCAL_MODULE := libtest_relocs
151 LOCAL_PRELINK_MODULE := false
152 include $(BUILD_SHARED_LIBRARY)
154 include $(CLEAR_VARS)
155 LOCAL_SRC_FILES := bionic/test_relocs.c
156 LOCAL_MODULE := test_relocs
157 LOCAL_SHARED_LIBRARIES := libtest_relocs
158 include $(BUILD_EXECUTABLE)
160 # This test tries to see if the static constructors in a
161 # shared library are only called once. We thus need to
162 # build a shared library, then call it from another
165 include $(CLEAR_VARS)
166 LOCAL_SRC_FILES := bionic/lib_static_init.cpp
167 LOCAL_MODULE := libtest_static_init
168 LOCAL_PRELINK_MODULE := false
169 include $(BUILD_SHARED_LIBRARY)
171 include $(CLEAR_VARS)
172 LOCAL_SRC_FILES := bionic/test_static_init.cpp
173 LOCAL_MODULE := test_static_init
174 LOCAL_SHARED_LIBRARIES := libtest_static_init
175 include $(BUILD_EXECUTABLE)
177 # This test tries to see if static destructors are called
178 # on dlclose(). We thus need to generate a C++ shared library
179 include $(CLEAR_VARS)
180 LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp
181 LOCAL_MODULE := libdlclosetest1
182 LOCAL_PRELINK_MODULE := false
183 include $(BUILD_SHARED_LIBRARY)
185 include $(CLEAR_VARS)
186 LOCAL_SRC_FILES := bionic/test_dlclose_destruction.c
187 LOCAL_MODULE := test_dlclose_destruction
188 LOCAL_LDFLAGS := -ldl
189 #LOCAL_SHARED_LIBRARIES := libdlclosetest1
190 include $(BUILD_EXECUTABLE)
192 # Testing 'clone' is only possible on Linux systems
193 include $(CLEAR_VARS)
194 LOCAL_SRC_FILES := common/test_clone.c
195 LOCAL_MODULE := test_clone
196 include $(BUILD_EXECUTABLE)
198 ifeq ($(HOST_OS),linux)
199 include $(CLEAR_VARS)
200 LOCAL_SRC_FILES := common/test_clone.c
201 LOCAL_MODULE := test_clone
202 include $(BUILD_HOST_EXECUTABLE)
205 # TODO: Add a variety of GLibc test programs too...
207 # Hello World to test libstdc++ support
210 common/hello_world.cpp \
212 EXTRA_CFLAGS := -mandroid
213 #$(call device-test, $(sources))