blob: 0be0f4cfd9a1be7652fc37122441342ea7c4fb54 [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
20 target: {
21 darwin: {
22 enabled: false,
23 },
24 },
25 cflags: [
26 "-fstack-protector-all",
27 "-g",
28 "-Wall",
29 "-Wextra",
30 "-Wunused",
31 "-Werror",
32 "-fno-builtin",
33
34 // We want to test deprecated API too.
35 "-Wno-deprecated-declarations",
36
37 // For glibc.
38 "-D__STDC_LIMIT_MACROS",
39 ],
40 stl: "libc++",
41 sanitize: {
42 never: true,
43 },
44}
45
46// -----------------------------------------------------------------------------
47// All standard tests.
48// -----------------------------------------------------------------------------
49
50cc_test_library {
51 name: "libBionicStandardTests",
52 defaults: ["bionic_tests_defaults"],
53 srcs: [
54 "arpa_inet_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070055 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070056 "buffer_tests.cpp",
57 "bug_26110743_test.cpp",
58 "complex_test.cpp",
59 "ctype_test.cpp",
60 "dirent_test.cpp",
61 "error_test.cpp",
62 "eventfd_test.cpp",
63 "fcntl_test.cpp",
64 "fenv_test.cpp",
65 "ftw_test.cpp",
66 "getauxval_test.cpp",
67 "getcwd_test.cpp",
68 "grp_pwd_test.cpp",
69 "ifaddrs_test.cpp",
70 "inttypes_test.cpp",
71 "libc_logging_test.cpp",
72 "libgen_basename_test.cpp",
73 "libgen_test.cpp",
74 "locale_test.cpp",
75 "malloc_test.cpp",
76 "math_test.cpp",
77 "mntent_test.cpp",
78 "netdb_test.cpp",
79 "net_if_test.cpp",
80 "netinet_ether_test.cpp",
81 "netinet_in_test.cpp",
82 "netinet_udp_test.cpp",
83 "nl_types_test.cpp",
84 "pthread_test.cpp",
85 "pty_test.cpp",
86 "regex_test.cpp",
87 "resolv_test.cpp",
88 "sched_test.cpp",
89 "search_test.cpp",
90 "semaphore_test.cpp",
91 "setjmp_test.cpp",
92 "signal_test.cpp",
93 "stack_protector_test.cpp",
94 "stack_protector_test_helper.cpp",
95 "stack_unwinding_test.cpp",
96 "stdatomic_test.cpp",
97 "stdint_test.cpp",
98 "stdio_nofortify_test.cpp",
99 "stdio_test.cpp",
100 "stdio_ext_test.cpp",
101 "stdlib_test.cpp",
102 "string_nofortify_test.cpp",
103 "string_test.cpp",
104 "string_posix_strerror_r_test.cpp",
105 "strings_nofortify_test.cpp",
106 "strings_test.cpp",
107 "sstream_test.cpp",
108 "sys_epoll_test.cpp",
109 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700110 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "sys_personality_test.cpp",
112 "sys_prctl_test.cpp",
113 "sys_procfs_test.cpp",
114 "sys_ptrace_test.cpp",
115 "sys_quota_test.cpp",
116 "sys_resource_test.cpp",
117 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700118 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700120 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700121 "sys_socket_test.cpp",
122 "sys_stat_test.cpp",
123 "sys_statvfs_test.cpp",
124 "sys_syscall_test.cpp",
125 "sys_sysinfo_test.cpp",
126 "sys_sysmacros_test.cpp",
127 "sys_time_test.cpp",
128 "sys_timex_test.cpp",
129 "sys_types_test.cpp",
130 "sys_uio_test.cpp",
131 "sys_vfs_test.cpp",
132 "sys_xattr_test.cpp",
133 "system_properties_test.cpp",
134 "time_test.cpp",
135 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "unistd_nofortify_test.cpp",
137 "unistd_test.cpp",
138 "utmp_test.cpp",
139 "wchar_test.cpp",
140 "wctype_test.cpp",
141 ],
142
143 include_dirs: [
144 "bionic/libc",
145 "external/tinyxml2",
146 ],
147
148 static_libs: ["libbase"],
149 host_ldlibs: ["-lrt"],
150}
151
152// -----------------------------------------------------------------------------
153// Fortify tests.
154// -----------------------------------------------------------------------------
155
156cc_defaults {
157 name: "bionic_fortify_tests_defaults",
158 cflags: [
159 "-Wno-error",
160 "-U_FORTIFY_SOURCE",
161 ],
162 srcs: ["fortify_test_main.cpp"],
163 target: {
164 host: {
165 clang_cflags: ["-D__clang__"],
166 },
167 },
168}
169
170cc_test_library {
171 name: "libfortify1-tests-gcc",
172 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
173 clang: false,
174 cflags: [
175 "-D_FORTIFY_SOURCE=1",
176 "-DTEST_NAME=Fortify1_gcc"
177 ],
178}
179
180cc_test_library {
181 name: "libfortify2-tests-gcc",
182 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
183 clang: false,
184 cflags: [
185 "-D_FORTIFY_SOURCE=2",
186 "-DTEST_NAME=Fortify2_gcc"
187 ],
188}
189
190cc_test_library {
191 name: "libfortify1-tests-clang",
192 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
193 clang: true,
194 cflags: [
195 "-D_FORTIFY_SOURCE=1",
196 "-DTEST_NAME=Fortify1_clang"
197 ],
198}
199
200cc_test_library {
201 name: "libfortify2-tests-clang",
202 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
203 clang: true,
204 cflags: [
205 "-D_FORTIFY_SOURCE=2",
206 "-DTEST_NAME=Fortify2_clang"
207 ],
208}
209
210// -----------------------------------------------------------------------------
211// Library of all tests (excluding the dynamic linker tests).
212// -----------------------------------------------------------------------------
213cc_test_library {
214 name: "libBionicTests",
215 defaults: ["bionic_tests_defaults"],
216 whole_static_libs: [
217 "libBionicStandardTests",
218 "libfortify1-tests-gcc",
219 "libfortify2-tests-gcc",
220 "libfortify1-tests-clang",
221 "libfortify2-tests-clang",
222 ],
223}
224
225// -----------------------------------------------------------------------------
226// Library of bionic customized gtest main function, with simplified output format.
227// -----------------------------------------------------------------------------
228cc_test_library {
229 name: "libBionicGtestMain",
230 defaults: ["bionic_tests_defaults"],
231 srcs: ["gtest_main.cpp"],
232 target: {
233 darwin: {
234 enabled: true,
235 },
236 },
237}
238
239// -----------------------------------------------------------------------------
240// Library of bionic customized gtest main function, with normal gtest output format,
241// which is needed by bionic cts test.
242// -----------------------------------------------------------------------------
243cc_test_library {
244 name: "libBionicCtsGtestMain",
245 defaults: ["bionic_tests_defaults"],
246 srcs: ["gtest_main.cpp"],
247 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
248}
249
250// -----------------------------------------------------------------------------
251// Tests for the device using bionic's .so. Run with:
252// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
253// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
254// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
255// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
256// -----------------------------------------------------------------------------
257cc_defaults {
258 name: "bionic_unit_tests_defaults",
259 host_supported: false,
260
261 whole_static_libs: [
262 "libBionicTests",
263 "libBionicGtestMain",
264 ],
265
266 static_libs: [
267 "libtinyxml2",
268 "liblog",
269 "libbase",
270 ],
271
272 srcs: [
273 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
274 "atexit_test.cpp",
275 "dl_test.cpp",
276 "dlext_test.cpp",
277 "__cxa_thread_atexit_test.cpp",
278 "dlfcn_test.cpp",
279 "libdl_test.cpp",
280 "pthread_dlfcn_test.cpp",
281 "thread_local_test.cpp",
282 ],
283
284 conlyflags: [
285 "-fexceptions",
286 "-fnon-call-exceptions",
287 ],
288
289 ldflags: ["-Wl,--export-dynamic"],
290
291 include_dirs: ["bionic/libc"],
292
293 target: {
294 android: {
295 shared_libs: [
296 "libdl",
297 "libpagemap",
298 "libdl_preempt_test_1",
299 "libdl_preempt_test_2",
300 "libdl_test_df_1_global",
301 ],
302 static_libs: [
303 // The order of these libraries matters, do not shuffle them.
304 "libbase",
305 "libziparchive",
306 "libz",
307 "libutils",
308 ],
309 },
310 }
311}
312
313cc_test {
314 name: "bionic-unit-tests",
315 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
316 clang: true,
317}
318
319cc_test {
320 name: "bionic-unit-tests-gcc",
321 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
322 clang: false,
323}
324
325// -----------------------------------------------------------------------------
326// Tests for the device linked against bionic's static library. Run with:
327// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
328// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
329// -----------------------------------------------------------------------------
330cc_test {
331 name: "bionic-unit-tests-static",
332 defaults: ["bionic_tests_defaults"],
333 host_supported: false,
334
335 whole_static_libs: [
336 "libBionicTests",
337 "libBionicGtestMain",
338 ],
339
340 static_libs: [
341 "libm",
342 "libc",
343 "libc++_static",
344 "libdl",
345 "libtinyxml2",
346 "liblog",
347 "libbase",
348 ],
349
350 static_executable: true,
351 stl: "libc++_static",
352
353 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
354 // still causes issues when linking libc.a and libc++.a, since private isn't
355 // effective until it has been linked. To fix this, just allow multiple symbol
356 // definitions for the static tests.
357 ldflags: ["-Wl,--allow-multiple-definition"],
358}
359
360// -----------------------------------------------------------------------------
361// Tests to run on the host and linked against glibc. Run with:
362// cd bionic/tests; mm bionic-unit-tests-glibc-run
363// -----------------------------------------------------------------------------
364
365cc_test_host {
366 name: "bionic-unit-tests-glibc",
367 defaults: ["bionic_tests_defaults"],
368
369 srcs: [
370 "atexit_test.cpp",
371 "dlfcn_test.cpp",
372 "dl_test.cpp",
373 "pthread_dlfcn_test.cpp",
374 ],
375
376 shared_libs: [
377 "libdl_preempt_test_1",
378 "libdl_preempt_test_2",
379
380 "libdl_test_df_1_global",
381 ],
382
383 whole_static_libs: [
384 "libBionicStandardTests",
385 "libBionicGtestMain",
386 "libfortify1-tests-gcc",
387 "libfortify2-tests-gcc",
388 "libfortify1-tests-clang",
389 "libfortify2-tests-clang",
390 ],
391
392 static_libs: [
393 "libbase",
394 "liblog",
395 "libcutils",
396 ],
397
398 host_ldlibs: [
399 "-lresolv",
400 "-lrt",
401 "-ldl",
402 "-lutil",
403 ],
404
405 include_dirs: ["bionic/libc"],
406
407 ldflags: ["-Wl,--export-dynamic"],
408
409 sanitize: {
410 never: false,
411 },
412}
413
414subdirs = ["libs"]