blob: 2ccdbf8acc955ed154e52b451f556b264b50f529 [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",
Elliott Hughesfc8e6882016-11-18 16:27:29 -080071 "langinfo_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070072 "libc_logging_test.cpp",
73 "libgen_basename_test.cpp",
74 "libgen_test.cpp",
75 "locale_test.cpp",
76 "malloc_test.cpp",
77 "math_test.cpp",
78 "mntent_test.cpp",
79 "netdb_test.cpp",
80 "net_if_test.cpp",
81 "netinet_ether_test.cpp",
82 "netinet_in_test.cpp",
83 "netinet_udp_test.cpp",
84 "nl_types_test.cpp",
85 "pthread_test.cpp",
86 "pty_test.cpp",
87 "regex_test.cpp",
88 "resolv_test.cpp",
89 "sched_test.cpp",
90 "search_test.cpp",
91 "semaphore_test.cpp",
92 "setjmp_test.cpp",
93 "signal_test.cpp",
94 "stack_protector_test.cpp",
95 "stack_protector_test_helper.cpp",
96 "stack_unwinding_test.cpp",
97 "stdatomic_test.cpp",
98 "stdint_test.cpp",
99 "stdio_nofortify_test.cpp",
100 "stdio_test.cpp",
101 "stdio_ext_test.cpp",
102 "stdlib_test.cpp",
103 "string_nofortify_test.cpp",
104 "string_test.cpp",
105 "string_posix_strerror_r_test.cpp",
106 "strings_nofortify_test.cpp",
107 "strings_test.cpp",
108 "sstream_test.cpp",
109 "sys_epoll_test.cpp",
110 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700111 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700112 "sys_personality_test.cpp",
113 "sys_prctl_test.cpp",
114 "sys_procfs_test.cpp",
115 "sys_ptrace_test.cpp",
116 "sys_quota_test.cpp",
117 "sys_resource_test.cpp",
118 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700119 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700120 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700121 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "sys_socket_test.cpp",
123 "sys_stat_test.cpp",
124 "sys_statvfs_test.cpp",
125 "sys_syscall_test.cpp",
126 "sys_sysinfo_test.cpp",
127 "sys_sysmacros_test.cpp",
128 "sys_time_test.cpp",
129 "sys_timex_test.cpp",
130 "sys_types_test.cpp",
131 "sys_uio_test.cpp",
132 "sys_vfs_test.cpp",
133 "sys_xattr_test.cpp",
134 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000135 "system_properties_test2.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "time_test.cpp",
137 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "unistd_nofortify_test.cpp",
139 "unistd_test.cpp",
140 "utmp_test.cpp",
141 "wchar_test.cpp",
142 "wctype_test.cpp",
143 ],
144
145 include_dirs: [
146 "bionic/libc",
147 "external/tinyxml2",
148 ],
149
Dan Willemsen41567702016-08-31 16:35:01 -0700150 static_libs: [
151 "libtinyxml2",
152 "liblog",
153 "libbase",
154 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700156 shared: {
157 enabled: false,
158 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000159
160 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700161}
162
163// -----------------------------------------------------------------------------
164// Fortify tests.
165// -----------------------------------------------------------------------------
166
167cc_defaults {
168 name: "bionic_fortify_tests_defaults",
169 cflags: [
170 "-Wno-error",
171 "-U_FORTIFY_SOURCE",
172 ],
173 srcs: ["fortify_test_main.cpp"],
174 target: {
175 host: {
176 clang_cflags: ["-D__clang__"],
177 },
178 },
179}
180
181cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700182 name: "libfortify1-tests-clang",
183 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
184 clang: true,
185 cflags: [
186 "-D_FORTIFY_SOURCE=1",
187 "-DTEST_NAME=Fortify1_clang"
188 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700189 shared: {
190 enabled: false,
191 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700192}
193
194cc_test_library {
195 name: "libfortify2-tests-clang",
196 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
197 clang: true,
198 cflags: [
199 "-D_FORTIFY_SOURCE=2",
200 "-DTEST_NAME=Fortify2_clang"
201 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700202 shared: {
203 enabled: false,
204 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700205}
206
207// -----------------------------------------------------------------------------
208// Library of all tests (excluding the dynamic linker tests).
209// -----------------------------------------------------------------------------
210cc_test_library {
211 name: "libBionicTests",
212 defaults: ["bionic_tests_defaults"],
213 whole_static_libs: [
214 "libBionicStandardTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700215 "libfortify1-tests-clang",
216 "libfortify2-tests-clang",
217 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700218 shared: {
219 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700220 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700221}
222
223// -----------------------------------------------------------------------------
224// Library of bionic customized gtest main function, with simplified output format.
225// -----------------------------------------------------------------------------
226cc_test_library {
227 name: "libBionicGtestMain",
228 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700229 srcs: [
230 "gtest_main.cpp",
231 "gtest_globals.cpp",
232 ],
233 static_libs: [
234 "libbase",
235 ],
236 include_dirs: [
237 "bionic/libc",
238 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700239 target: {
240 darwin: {
241 enabled: true,
242 },
243 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700244 shared: {
245 enabled: false,
246 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700247}
248
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700249cc_test_library {
250 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800251 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700252 srcs: [
253 "atexit_test.cpp",
254 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700255 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700256 "dlfcn_test.cpp",
257 "pthread_dlfcn_test.cpp",
258 ],
259 static_libs: [
260 "libbase",
261 ],
262 include_dirs: [
263 "bionic/libc",
264 ],
265 shared: {
266 enabled: false,
267 },
268 target: {
269 android: {
270 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700271 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700272 "dlext_test.cpp",
273 "libdl_test.cpp",
274 ],
275 static_libs: [
276 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800277 "libLLVMObject",
278 "libLLVMBitReader",
279 "libLLVMMC",
280 "libLLVMMCParser",
281 "libLLVMCore",
282 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700283 ],
284 }
285 }
286}
287
Colin Cross2722ebb2016-07-11 16:20:06 -0700288// -----------------------------------------------------------------------------
289// Library of bionic customized gtest main function, with normal gtest output format,
290// which is needed by bionic cts test.
291// -----------------------------------------------------------------------------
292cc_test_library {
293 name: "libBionicCtsGtestMain",
294 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700295 srcs: [
296 "gtest_main.cpp",
297 "gtest_globals_cts.cpp",
298 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700299 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700300 shared: {
301 enabled: false,
302 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700303}
304
305// -----------------------------------------------------------------------------
306// Tests for the device using bionic's .so. Run with:
307// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
308// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
309// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
310// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
311// -----------------------------------------------------------------------------
312cc_defaults {
313 name: "bionic_unit_tests_defaults",
314 host_supported: false,
315
316 whole_static_libs: [
317 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700318 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700319 "libBionicGtestMain",
320 ],
321
322 static_libs: [
323 "libtinyxml2",
324 "liblog",
325 "libbase",
326 ],
327
328 srcs: [
329 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700330 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700331 "thread_local_test.cpp",
332 ],
333
334 conlyflags: [
335 "-fexceptions",
336 "-fnon-call-exceptions",
337 ],
338
339 ldflags: ["-Wl,--export-dynamic"],
340
341 include_dirs: ["bionic/libc"],
342
Yabin Cui1f553ea2017-01-13 12:31:59 -0800343 stl: "libc++_static",
344
Colin Cross2722ebb2016-07-11 16:20:06 -0700345 target: {
346 android: {
347 shared_libs: [
348 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700349 "libdl_preempt_test_1",
350 "libdl_preempt_test_2",
351 "libdl_test_df_1_global",
352 ],
353 static_libs: [
354 // The order of these libraries matters, do not shuffle them.
355 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700356 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700357 "libziparchive",
358 "libz",
359 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800360 "libLLVMObject",
361 "libLLVMBitReader",
362 "libLLVMMC",
363 "libLLVMMCParser",
364 "libLLVMCore",
365 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700366 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700367 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700368 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700369 "-Wl,--enable-new-dtags",
370 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700371 },
372 }
373}
374
375cc_test {
376 name: "bionic-unit-tests",
377 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
378 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800379
380 target: {
381 android: {
382 shared_libs: ["libicuuc"],
383 },
384 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700385}
386
Colin Cross2722ebb2016-07-11 16:20:06 -0700387// -----------------------------------------------------------------------------
388// Tests for the device linked against bionic's static library. Run with:
389// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
390// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
391// -----------------------------------------------------------------------------
392cc_test {
393 name: "bionic-unit-tests-static",
394 defaults: ["bionic_tests_defaults"],
395 host_supported: false,
396
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800397 srcs: [
398 "gtest_preinit_debuggerd.cpp",
399 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700400 whole_static_libs: [
401 "libBionicTests",
402 "libBionicGtestMain",
403 ],
404
405 static_libs: [
406 "libm",
407 "libc",
408 "libc++_static",
409 "libdl",
410 "libtinyxml2",
411 "liblog",
412 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700413 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700414 ],
415
416 static_executable: true,
417 stl: "libc++_static",
418
419 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
420 // still causes issues when linking libc.a and libc++.a, since private isn't
421 // effective until it has been linked. To fix this, just allow multiple symbol
422 // definitions for the static tests.
423 ldflags: ["-Wl,--allow-multiple-definition"],
424}
425
426// -----------------------------------------------------------------------------
427// Tests to run on the host and linked against glibc. Run with:
428// cd bionic/tests; mm bionic-unit-tests-glibc-run
429// -----------------------------------------------------------------------------
430
431cc_test_host {
432 name: "bionic-unit-tests-glibc",
433 defaults: ["bionic_tests_defaults"],
434
435 srcs: [
436 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700437 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700438 "dlfcn_test.cpp",
439 "dl_test.cpp",
440 "pthread_dlfcn_test.cpp",
441 ],
442
443 shared_libs: [
444 "libdl_preempt_test_1",
445 "libdl_preempt_test_2",
446
447 "libdl_test_df_1_global",
448 ],
449
450 whole_static_libs: [
451 "libBionicStandardTests",
452 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700453 "libfortify1-tests-clang",
454 "libfortify2-tests-clang",
455 ],
456
457 static_libs: [
458 "libbase",
459 "liblog",
460 "libcutils",
461 ],
462
463 host_ldlibs: [
464 "-lresolv",
465 "-lrt",
466 "-ldl",
467 "-lutil",
468 ],
469
470 include_dirs: ["bionic/libc"],
471
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800472 ldflags: [
473 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
474 "-Wl,--export-dynamic",
475 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700476
477 sanitize: {
478 never: false,
479 },
480}
481
482subdirs = ["libs"]