OSDN Git Service

mksquashfsimge.sh: Support creating a sparse image
[android-x86/system-extras.git] / tests / bionic / libc / Android.mk
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 #
18 ifdef BIONIC_TESTS
19
20 LOCAL_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 #
28 define 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 :=)
41 endef
42
43 # same as 'device-test' but builds a host executable instead
44 # you can use EXTRA_LDLIBS to indicate additional linker flags
45 #
46 define 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 :=)
59 endef
60
61 # First, the tests in 'common'
62
63 sources := \
64     common/test_clock.c \
65     common/test_cpu_set.c \
66     common/test_executable_destructor.c \
67     common/test_getaddrinfo.c \
68     common/test_gethostbyname.c \
69     common/test_gethostname.c \
70     common/test_pthread_cleanup_push.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_udp.c \
80
81 # _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc
82 #
83 EXTRA_LDLIBS := -lpthread -lrt
84 EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST
85 $(call host-test, $(sources))
86 $(call device-test, $(sources))
87
88 # The 'test_static_executable_destructor is the same than
89 # test_executable_destructor except that the generated program
90 # is statically linked instead.
91 include $(CLEAR_VARS)
92 LOCAL_MODULE := test_static_executable_destructor
93 LOCAL_SRC_FILES := common/test_executable_destructor.c
94 LOCAL_MODULE_TAGS := tests
95 LOCAL_STATIC_LIBRARIES := libc
96 LOCAL_FORCE_STATIC_EXECUTABLE := true
97 include $(BUILD_EXECUTABLE)
98
99 include $(CLEAR_VARS)
100 LOCAL_MODULE := test_static_executable_destructor
101 LOCAL_SRC_FILES := common/test_executable_destructor.c
102 LOCAL_MODULE_TAGS := tests
103 LOCAL_LDFLAGS := -static
104 include $(BUILD_HOST_EXECUTABLE)
105
106 # The 'test_dlopen_null' tests requires specific linker flags
107 #
108 # The -Wl,--export-dynamic ensures that dynamic symbols are
109 # exported from the executable.
110 #
111 # -Wl,-u,foo is used to ensure that symbol "foo" is not
112 # garbage-collected by the gold linker, since the function
113 # appears to be unused.
114 #
115 sources := common/test_dlopen_null.c \
116
117 EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo
118 EXTRA_CFLAGS := -DHOST
119 $(call host-test, $(sources))
120
121 EXTRA_LDLIBS := -ldl -Wl,--export-dynamic -Wl,-u,foo
122 $(call device-test, $(sources))
123
124
125 # Second, the Bionic-specific tests
126
127 sources :=  \
128     bionic/test_mutex.c \
129     bionic/test_cond.c \
130     bionic/test_getgrouplist.c \
131     bionic/test_netinet_icmp.c \
132     bionic/test_pthread_cond.c \
133     bionic/test_pthread_create.c \
134     bionic/test_setjmp.c \
135
136 $(call device-test, $(sources))
137
138 # Third, the other tests
139
140 sources := \
141     other/test_sysconf.c \
142     other/test_vfprintf_leak.c \
143
144 $(call device-test, $(sources))
145
146 # The relocations test is a bit special, since we need
147 # to build one shared object and one executable that depends
148 # on it.
149
150 include $(CLEAR_VARS)
151 LOCAL_SRC_FILES := bionic/lib_relocs.c
152 LOCAL_MODULE    := libtest_relocs
153
154 LOCAL_MODULE_TAGS := tests
155 include $(BUILD_SHARED_LIBRARY)
156
157 include $(CLEAR_VARS)
158 LOCAL_SRC_FILES := bionic/test_relocs.c
159 LOCAL_MODULE    := test_relocs
160 LOCAL_SHARED_LIBRARIES := libtest_relocs
161 LOCAL_MODULE_TAGS := tests
162 include $(BUILD_EXECUTABLE)
163
164 # This test tries to see if the static constructors in a
165 # shared library are only called once. We thus need to
166 # build a shared library, then call it from another
167 # program.
168 #
169 include $(CLEAR_VARS)
170 LOCAL_SRC_FILES := bionic/lib_static_init.cpp
171 LOCAL_MODULE    := libtest_static_init
172
173 LOCAL_MODULE_TAGS := tests
174 include $(BUILD_SHARED_LIBRARY)
175
176 include $(CLEAR_VARS)
177 LOCAL_SRC_FILES := bionic/test_static_init.cpp
178 LOCAL_MODULE    := test_static_init
179 LOCAL_SHARED_LIBRARIES := libtest_static_init
180 LOCAL_MODULE_TAGS := tests
181 include $(BUILD_EXECUTABLE)
182
183 # This test tries to see if static destructors are called
184 # on dlclose(). We thus need to generate a C++ shared library
185 include $(CLEAR_VARS)
186 LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp
187 LOCAL_MODULE := libdlclosetest1
188
189 LOCAL_MODULE_TAGS := tests
190 include $(BUILD_SHARED_LIBRARY)
191
192 # And this one does the same with __attribute__((constructor))
193 # and __attribute__((destructor))
194 include $(CLEAR_VARS)
195 LOCAL_SRC_FILES := bionic/libdlclosetest2.c
196 LOCAL_MODULE := libdlclosetest2
197
198 LOCAL_MODULE_TAGS := tests
199 include $(BUILD_SHARED_LIBRARY)
200
201 include $(CLEAR_VARS)
202 LOCAL_SRC_FILES := bionic/test_dlclose_destruction.c
203 LOCAL_MODULE := test_dlclose_destruction
204 LOCAL_LDFLAGS := -ldl
205 #LOCAL_SHARED_LIBRARIES := libdlclosetest1 libdlclosetest2
206 LOCAL_MODULE_TAGS := tests
207 include $(BUILD_EXECUTABLE)
208
209 # TODO: Add a variety of GLibc test programs too...
210
211 # Hello World to test libstdc++ support
212
213 sources := \
214     common/hello_world.cpp \
215
216 EXTRA_CFLAGS := -mandroid
217 #$(call device-test, $(sources))
218
219 endif  # BIONIC_TESTS