blob: 64a5c30a6475072bddad0977d479ec21bb28a25d [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 {
182 name: "libfortify1-tests-gcc",
183 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
184 clang: false,
185 cflags: [
186 "-D_FORTIFY_SOURCE=1",
187 "-DTEST_NAME=Fortify1_gcc"
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-gcc",
196 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
197 clang: false,
198 cflags: [
199 "-D_FORTIFY_SOURCE=2",
200 "-DTEST_NAME=Fortify2_gcc"
201 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700202 shared: {
203 enabled: false,
204 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700205}
206
207cc_test_library {
208 name: "libfortify1-tests-clang",
209 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
210 clang: true,
211 cflags: [
212 "-D_FORTIFY_SOURCE=1",
213 "-DTEST_NAME=Fortify1_clang"
214 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700215 shared: {
216 enabled: false,
217 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700218}
219
220cc_test_library {
221 name: "libfortify2-tests-clang",
222 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
223 clang: true,
224 cflags: [
225 "-D_FORTIFY_SOURCE=2",
226 "-DTEST_NAME=Fortify2_clang"
227 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700228 shared: {
229 enabled: false,
230 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700231}
232
233// -----------------------------------------------------------------------------
234// Library of all tests (excluding the dynamic linker tests).
235// -----------------------------------------------------------------------------
236cc_test_library {
237 name: "libBionicTests",
238 defaults: ["bionic_tests_defaults"],
239 whole_static_libs: [
240 "libBionicStandardTests",
241 "libfortify1-tests-gcc",
242 "libfortify2-tests-gcc",
243 "libfortify1-tests-clang",
244 "libfortify2-tests-clang",
245 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700246 shared: {
247 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700248 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700249}
250
251// -----------------------------------------------------------------------------
252// Library of bionic customized gtest main function, with simplified output format.
253// -----------------------------------------------------------------------------
254cc_test_library {
255 name: "libBionicGtestMain",
256 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700257 srcs: [
258 "gtest_main.cpp",
259 "gtest_globals.cpp",
260 ],
261 static_libs: [
262 "libbase",
263 ],
264 include_dirs: [
265 "bionic/libc",
266 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700267 target: {
268 darwin: {
269 enabled: true,
270 },
271 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700272 shared: {
273 enabled: false,
274 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700275}
276
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700277cc_test_library {
278 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800279 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700280 srcs: [
281 "atexit_test.cpp",
282 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700283 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700284 "dlfcn_test.cpp",
285 "pthread_dlfcn_test.cpp",
286 ],
287 static_libs: [
288 "libbase",
289 ],
290 include_dirs: [
291 "bionic/libc",
292 ],
293 shared: {
294 enabled: false,
295 },
296 target: {
297 android: {
298 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700299 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700300 "dlext_test.cpp",
301 "libdl_test.cpp",
302 ],
303 static_libs: [
304 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800305 "libLLVMObject",
306 "libLLVMBitReader",
307 "libLLVMMC",
308 "libLLVMMCParser",
309 "libLLVMCore",
310 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700311 ],
312 }
313 }
314}
315
Colin Cross2722ebb2016-07-11 16:20:06 -0700316// -----------------------------------------------------------------------------
317// Library of bionic customized gtest main function, with normal gtest output format,
318// which is needed by bionic cts test.
319// -----------------------------------------------------------------------------
320cc_test_library {
321 name: "libBionicCtsGtestMain",
322 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700323 srcs: [
324 "gtest_main.cpp",
325 "gtest_globals_cts.cpp",
326 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700327 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700328 shared: {
329 enabled: false,
330 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700331}
332
333// -----------------------------------------------------------------------------
334// Tests for the device using bionic's .so. Run with:
335// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
336// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
337// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
338// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
339// -----------------------------------------------------------------------------
340cc_defaults {
341 name: "bionic_unit_tests_defaults",
342 host_supported: false,
343
344 whole_static_libs: [
345 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700346 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700347 "libBionicGtestMain",
348 ],
349
350 static_libs: [
351 "libtinyxml2",
352 "liblog",
353 "libbase",
354 ],
355
356 srcs: [
357 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700358 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700359 "thread_local_test.cpp",
360 ],
361
362 conlyflags: [
363 "-fexceptions",
364 "-fnon-call-exceptions",
365 ],
366
367 ldflags: ["-Wl,--export-dynamic"],
368
369 include_dirs: ["bionic/libc"],
370
Yabin Cui1f553ea2017-01-13 12:31:59 -0800371 stl: "libc++_static",
372
Colin Cross2722ebb2016-07-11 16:20:06 -0700373 target: {
374 android: {
375 shared_libs: [
376 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700377 "libdl_preempt_test_1",
378 "libdl_preempt_test_2",
379 "libdl_test_df_1_global",
380 ],
381 static_libs: [
382 // The order of these libraries matters, do not shuffle them.
383 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700384 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700385 "libziparchive",
386 "libz",
387 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800388 "libLLVMObject",
389 "libLLVMBitReader",
390 "libLLVMMC",
391 "libLLVMMCParser",
392 "libLLVMCore",
393 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700394 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700395 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700396 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700397 "-Wl,--enable-new-dtags",
398 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700399 },
400 }
401}
402
403cc_test {
404 name: "bionic-unit-tests",
405 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
406 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800407
408 target: {
409 android: {
410 shared_libs: ["libicuuc"],
411 },
412 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700413}
414
415cc_test {
416 name: "bionic-unit-tests-gcc",
417 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
418 clang: false,
419}
420
421// -----------------------------------------------------------------------------
422// Tests for the device linked against bionic's static library. Run with:
423// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
424// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
425// -----------------------------------------------------------------------------
426cc_test {
427 name: "bionic-unit-tests-static",
428 defaults: ["bionic_tests_defaults"],
429 host_supported: false,
430
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800431 srcs: [
432 "gtest_preinit_debuggerd.cpp",
433 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700434 whole_static_libs: [
435 "libBionicTests",
436 "libBionicGtestMain",
437 ],
438
439 static_libs: [
440 "libm",
441 "libc",
442 "libc++_static",
443 "libdl",
444 "libtinyxml2",
445 "liblog",
446 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700447 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700448 ],
449
450 static_executable: true,
451 stl: "libc++_static",
452
453 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
454 // still causes issues when linking libc.a and libc++.a, since private isn't
455 // effective until it has been linked. To fix this, just allow multiple symbol
456 // definitions for the static tests.
457 ldflags: ["-Wl,--allow-multiple-definition"],
458}
459
460// -----------------------------------------------------------------------------
461// Tests to run on the host and linked against glibc. Run with:
462// cd bionic/tests; mm bionic-unit-tests-glibc-run
463// -----------------------------------------------------------------------------
464
465cc_test_host {
466 name: "bionic-unit-tests-glibc",
467 defaults: ["bionic_tests_defaults"],
468
469 srcs: [
470 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700471 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700472 "dlfcn_test.cpp",
473 "dl_test.cpp",
474 "pthread_dlfcn_test.cpp",
475 ],
476
477 shared_libs: [
478 "libdl_preempt_test_1",
479 "libdl_preempt_test_2",
480
481 "libdl_test_df_1_global",
482 ],
483
484 whole_static_libs: [
485 "libBionicStandardTests",
486 "libBionicGtestMain",
487 "libfortify1-tests-gcc",
488 "libfortify2-tests-gcc",
489 "libfortify1-tests-clang",
490 "libfortify2-tests-clang",
491 ],
492
493 static_libs: [
494 "libbase",
495 "liblog",
496 "libcutils",
497 ],
498
499 host_ldlibs: [
500 "-lresolv",
501 "-lrt",
502 "-ldl",
503 "-lutil",
504 ],
505
506 include_dirs: ["bionic/libc"],
507
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800508 ldflags: [
509 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
510 "-Wl,--export-dynamic",
511 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700512
513 sanitize: {
514 never: false,
515 },
516}
517
518subdirs = ["libs"]