blob: 85ae26e6657454342282282c48fab794fbdf7cb2 [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",
135 "time_test.cpp",
136 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700137 "unistd_nofortify_test.cpp",
138 "unistd_test.cpp",
139 "utmp_test.cpp",
140 "wchar_test.cpp",
141 "wctype_test.cpp",
142 ],
143
144 include_dirs: [
145 "bionic/libc",
146 "external/tinyxml2",
147 ],
148
Dan Willemsen41567702016-08-31 16:35:01 -0700149 static_libs: [
150 "libtinyxml2",
151 "liblog",
152 "libbase",
153 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700154 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700155 shared: {
156 enabled: false,
157 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000158
159 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700160}
161
162// -----------------------------------------------------------------------------
163// Fortify tests.
164// -----------------------------------------------------------------------------
165
166cc_defaults {
167 name: "bionic_fortify_tests_defaults",
168 cflags: [
169 "-Wno-error",
170 "-U_FORTIFY_SOURCE",
171 ],
172 srcs: ["fortify_test_main.cpp"],
173 target: {
174 host: {
175 clang_cflags: ["-D__clang__"],
176 },
177 },
178}
179
180cc_test_library {
181 name: "libfortify1-tests-gcc",
182 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
183 clang: false,
184 cflags: [
185 "-D_FORTIFY_SOURCE=1",
186 "-DTEST_NAME=Fortify1_gcc"
187 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700188 shared: {
189 enabled: false,
190 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700191}
192
193cc_test_library {
194 name: "libfortify2-tests-gcc",
195 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
196 clang: false,
197 cflags: [
198 "-D_FORTIFY_SOURCE=2",
199 "-DTEST_NAME=Fortify2_gcc"
200 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700201 shared: {
202 enabled: false,
203 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700204}
205
206cc_test_library {
207 name: "libfortify1-tests-clang",
208 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
209 clang: true,
210 cflags: [
211 "-D_FORTIFY_SOURCE=1",
212 "-DTEST_NAME=Fortify1_clang"
213 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700214 shared: {
215 enabled: false,
216 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700217}
218
219cc_test_library {
220 name: "libfortify2-tests-clang",
221 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
222 clang: true,
223 cflags: [
224 "-D_FORTIFY_SOURCE=2",
225 "-DTEST_NAME=Fortify2_clang"
226 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700227 shared: {
228 enabled: false,
229 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700230}
231
232// -----------------------------------------------------------------------------
233// Library of all tests (excluding the dynamic linker tests).
234// -----------------------------------------------------------------------------
235cc_test_library {
236 name: "libBionicTests",
237 defaults: ["bionic_tests_defaults"],
238 whole_static_libs: [
239 "libBionicStandardTests",
240 "libfortify1-tests-gcc",
241 "libfortify2-tests-gcc",
242 "libfortify1-tests-clang",
243 "libfortify2-tests-clang",
244 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700245 shared: {
246 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700247 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700248}
249
250// -----------------------------------------------------------------------------
251// Library of bionic customized gtest main function, with simplified output format.
252// -----------------------------------------------------------------------------
253cc_test_library {
254 name: "libBionicGtestMain",
255 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700256 srcs: [
257 "gtest_main.cpp",
258 "gtest_globals.cpp",
259 ],
260 static_libs: [
261 "libbase",
262 ],
263 include_dirs: [
264 "bionic/libc",
265 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700266 target: {
267 darwin: {
268 enabled: true,
269 },
270 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700271 shared: {
272 enabled: false,
273 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700274}
275
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700276cc_test_library {
277 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800278 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700279 srcs: [
280 "atexit_test.cpp",
281 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700282 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700283 "dlfcn_test.cpp",
284 "pthread_dlfcn_test.cpp",
285 ],
286 static_libs: [
287 "libbase",
288 ],
289 include_dirs: [
290 "bionic/libc",
291 ],
292 shared: {
293 enabled: false,
294 },
295 target: {
296 android: {
297 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700298 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700299 "dlext_test.cpp",
300 "libdl_test.cpp",
301 ],
302 static_libs: [
303 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800304 "libLLVMObject",
305 "libLLVMBitReader",
306 "libLLVMMC",
307 "libLLVMMCParser",
308 "libLLVMCore",
309 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700310 ],
311 }
312 }
313}
314
Colin Cross2722ebb2016-07-11 16:20:06 -0700315// -----------------------------------------------------------------------------
316// Library of bionic customized gtest main function, with normal gtest output format,
317// which is needed by bionic cts test.
318// -----------------------------------------------------------------------------
319cc_test_library {
320 name: "libBionicCtsGtestMain",
321 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700322 srcs: [
323 "gtest_main.cpp",
324 "gtest_globals_cts.cpp",
325 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700326 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700327 shared: {
328 enabled: false,
329 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700330}
331
332// -----------------------------------------------------------------------------
333// Tests for the device using bionic's .so. Run with:
334// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
335// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
336// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
337// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
338// -----------------------------------------------------------------------------
339cc_defaults {
340 name: "bionic_unit_tests_defaults",
341 host_supported: false,
342
343 whole_static_libs: [
344 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700345 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700346 "libBionicGtestMain",
347 ],
348
349 static_libs: [
350 "libtinyxml2",
351 "liblog",
352 "libbase",
353 ],
354
355 srcs: [
356 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700357 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700358 "thread_local_test.cpp",
359 ],
360
361 conlyflags: [
362 "-fexceptions",
363 "-fnon-call-exceptions",
364 ],
365
366 ldflags: ["-Wl,--export-dynamic"],
367
368 include_dirs: ["bionic/libc"],
369
Yabin Cui1f553ea2017-01-13 12:31:59 -0800370 stl: "libc++_static",
371
Colin Cross2722ebb2016-07-11 16:20:06 -0700372 target: {
373 android: {
374 shared_libs: [
375 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700376 "libdl_preempt_test_1",
377 "libdl_preempt_test_2",
378 "libdl_test_df_1_global",
379 ],
380 static_libs: [
381 // The order of these libraries matters, do not shuffle them.
382 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700383 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700384 "libziparchive",
385 "libz",
386 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800387 "libLLVMObject",
388 "libLLVMBitReader",
389 "libLLVMMC",
390 "libLLVMMCParser",
391 "libLLVMCore",
392 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700393 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700394 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700395 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700396 "-Wl,--enable-new-dtags",
397 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700398 },
399 }
400}
401
402cc_test {
403 name: "bionic-unit-tests",
404 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
405 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800406
407 target: {
408 android: {
409 shared_libs: ["libicuuc"],
410 },
411 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700412}
413
414cc_test {
415 name: "bionic-unit-tests-gcc",
416 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
417 clang: false,
418}
419
420// -----------------------------------------------------------------------------
421// Tests for the device linked against bionic's static library. Run with:
422// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
423// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
424// -----------------------------------------------------------------------------
425cc_test {
426 name: "bionic-unit-tests-static",
427 defaults: ["bionic_tests_defaults"],
428 host_supported: false,
429
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800430 srcs: [
431 "gtest_preinit_debuggerd.cpp",
432 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700433 whole_static_libs: [
434 "libBionicTests",
435 "libBionicGtestMain",
436 ],
437
438 static_libs: [
439 "libm",
440 "libc",
441 "libc++_static",
442 "libdl",
443 "libtinyxml2",
444 "liblog",
445 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700446 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700447 ],
448
449 static_executable: true,
450 stl: "libc++_static",
451
452 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
453 // still causes issues when linking libc.a and libc++.a, since private isn't
454 // effective until it has been linked. To fix this, just allow multiple symbol
455 // definitions for the static tests.
456 ldflags: ["-Wl,--allow-multiple-definition"],
457}
458
459// -----------------------------------------------------------------------------
460// Tests to run on the host and linked against glibc. Run with:
461// cd bionic/tests; mm bionic-unit-tests-glibc-run
462// -----------------------------------------------------------------------------
463
464cc_test_host {
465 name: "bionic-unit-tests-glibc",
466 defaults: ["bionic_tests_defaults"],
467
468 srcs: [
469 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700470 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700471 "dlfcn_test.cpp",
472 "dl_test.cpp",
473 "pthread_dlfcn_test.cpp",
474 ],
475
476 shared_libs: [
477 "libdl_preempt_test_1",
478 "libdl_preempt_test_2",
479
480 "libdl_test_df_1_global",
481 ],
482
483 whole_static_libs: [
484 "libBionicStandardTests",
485 "libBionicGtestMain",
486 "libfortify1-tests-gcc",
487 "libfortify2-tests-gcc",
488 "libfortify1-tests-clang",
489 "libfortify2-tests-clang",
490 ],
491
492 static_libs: [
493 "libbase",
494 "liblog",
495 "libcutils",
496 ],
497
498 host_ldlibs: [
499 "-lresolv",
500 "-lrt",
501 "-ldl",
502 "-lutil",
503 ],
504
505 include_dirs: ["bionic/libc"],
506
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800507 ldflags: [
508 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
509 "-Wl,--export-dynamic",
510 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700511
512 sanitize: {
513 never: false,
514 },
515}
516
517subdirs = ["libs"]