blob: 1cca332194f97a3056c9cf2891d99bd483bda7d2 [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",
Elliott Hughesba267f42017-02-24 16:19:53 -080061 "endian_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070062 "error_test.cpp",
63 "eventfd_test.cpp",
64 "fcntl_test.cpp",
65 "fenv_test.cpp",
66 "ftw_test.cpp",
67 "getauxval_test.cpp",
68 "getcwd_test.cpp",
69 "grp_pwd_test.cpp",
70 "ifaddrs_test.cpp",
71 "inttypes_test.cpp",
Elliott Hughesfc8e6882016-11-18 16:27:29 -080072 "langinfo_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070073 "libc_logging_test.cpp",
74 "libgen_basename_test.cpp",
75 "libgen_test.cpp",
76 "locale_test.cpp",
77 "malloc_test.cpp",
78 "math_test.cpp",
79 "mntent_test.cpp",
80 "netdb_test.cpp",
81 "net_if_test.cpp",
82 "netinet_ether_test.cpp",
83 "netinet_in_test.cpp",
84 "netinet_udp_test.cpp",
85 "nl_types_test.cpp",
86 "pthread_test.cpp",
87 "pty_test.cpp",
88 "regex_test.cpp",
89 "resolv_test.cpp",
90 "sched_test.cpp",
91 "search_test.cpp",
92 "semaphore_test.cpp",
93 "setjmp_test.cpp",
94 "signal_test.cpp",
95 "stack_protector_test.cpp",
96 "stack_protector_test_helper.cpp",
97 "stack_unwinding_test.cpp",
98 "stdatomic_test.cpp",
99 "stdint_test.cpp",
100 "stdio_nofortify_test.cpp",
101 "stdio_test.cpp",
102 "stdio_ext_test.cpp",
103 "stdlib_test.cpp",
104 "string_nofortify_test.cpp",
105 "string_test.cpp",
106 "string_posix_strerror_r_test.cpp",
107 "strings_nofortify_test.cpp",
108 "strings_test.cpp",
109 "sstream_test.cpp",
110 "sys_epoll_test.cpp",
111 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700112 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700113 "sys_personality_test.cpp",
114 "sys_prctl_test.cpp",
115 "sys_procfs_test.cpp",
116 "sys_ptrace_test.cpp",
117 "sys_quota_test.cpp",
118 "sys_resource_test.cpp",
119 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700120 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700121 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700122 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "sys_socket_test.cpp",
124 "sys_stat_test.cpp",
125 "sys_statvfs_test.cpp",
126 "sys_syscall_test.cpp",
127 "sys_sysinfo_test.cpp",
128 "sys_sysmacros_test.cpp",
129 "sys_time_test.cpp",
130 "sys_timex_test.cpp",
131 "sys_types_test.cpp",
132 "sys_uio_test.cpp",
133 "sys_vfs_test.cpp",
134 "sys_xattr_test.cpp",
135 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000136 "system_properties_test2.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700137 "time_test.cpp",
138 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "unistd_nofortify_test.cpp",
140 "unistd_test.cpp",
141 "utmp_test.cpp",
142 "wchar_test.cpp",
143 "wctype_test.cpp",
144 ],
145
146 include_dirs: [
147 "bionic/libc",
148 "external/tinyxml2",
149 ],
150
Dan Willemsen41567702016-08-31 16:35:01 -0700151 static_libs: [
152 "libtinyxml2",
153 "liblog",
154 "libbase",
155 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700156 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700157 shared: {
158 enabled: false,
159 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000160
161 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700162}
163
164// -----------------------------------------------------------------------------
165// Fortify tests.
166// -----------------------------------------------------------------------------
167
168cc_defaults {
169 name: "bionic_fortify_tests_defaults",
170 cflags: [
171 "-Wno-error",
172 "-U_FORTIFY_SOURCE",
173 ],
174 srcs: ["fortify_test_main.cpp"],
175 target: {
176 host: {
177 clang_cflags: ["-D__clang__"],
178 },
179 },
180}
181
182cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700183 name: "libfortify1-tests-clang",
184 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
185 clang: true,
186 cflags: [
187 "-D_FORTIFY_SOURCE=1",
188 "-DTEST_NAME=Fortify1_clang"
189 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700190 shared: {
191 enabled: false,
192 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700193}
194
195cc_test_library {
196 name: "libfortify2-tests-clang",
197 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
198 clang: true,
199 cflags: [
200 "-D_FORTIFY_SOURCE=2",
201 "-DTEST_NAME=Fortify2_clang"
202 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700203 shared: {
204 enabled: false,
205 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700206}
207
208// -----------------------------------------------------------------------------
209// Library of all tests (excluding the dynamic linker tests).
210// -----------------------------------------------------------------------------
211cc_test_library {
212 name: "libBionicTests",
213 defaults: ["bionic_tests_defaults"],
214 whole_static_libs: [
215 "libBionicStandardTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700216 "libfortify1-tests-clang",
217 "libfortify2-tests-clang",
218 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700219 shared: {
220 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700221 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700222}
223
224// -----------------------------------------------------------------------------
225// Library of bionic customized gtest main function, with simplified output format.
226// -----------------------------------------------------------------------------
227cc_test_library {
228 name: "libBionicGtestMain",
229 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700230 srcs: [
231 "gtest_main.cpp",
232 "gtest_globals.cpp",
233 ],
234 static_libs: [
235 "libbase",
236 ],
237 include_dirs: [
238 "bionic/libc",
239 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700240 target: {
241 darwin: {
242 enabled: true,
243 },
244 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700245 shared: {
246 enabled: false,
247 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700248}
249
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700250cc_test_library {
251 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800252 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700253 srcs: [
254 "atexit_test.cpp",
255 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700256 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700257 "dlfcn_test.cpp",
258 "pthread_dlfcn_test.cpp",
259 ],
260 static_libs: [
261 "libbase",
262 ],
263 include_dirs: [
264 "bionic/libc",
265 ],
266 shared: {
267 enabled: false,
268 },
269 target: {
270 android: {
271 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700272 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700273 "dlext_test.cpp",
274 "libdl_test.cpp",
275 ],
276 static_libs: [
277 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800278 "libLLVMObject",
279 "libLLVMBitReader",
280 "libLLVMMC",
281 "libLLVMMCParser",
282 "libLLVMCore",
283 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700284 ],
285 }
286 }
287}
288
Colin Cross2722ebb2016-07-11 16:20:06 -0700289// -----------------------------------------------------------------------------
290// Library of bionic customized gtest main function, with normal gtest output format,
291// which is needed by bionic cts test.
292// -----------------------------------------------------------------------------
293cc_test_library {
294 name: "libBionicCtsGtestMain",
295 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700296 srcs: [
297 "gtest_main.cpp",
298 "gtest_globals_cts.cpp",
299 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700300 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700301 shared: {
302 enabled: false,
303 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700304}
305
306// -----------------------------------------------------------------------------
307// Tests for the device using bionic's .so. Run with:
308// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
309// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
310// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
311// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
312// -----------------------------------------------------------------------------
313cc_defaults {
314 name: "bionic_unit_tests_defaults",
315 host_supported: false,
316
317 whole_static_libs: [
318 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700319 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700320 "libBionicGtestMain",
321 ],
322
323 static_libs: [
324 "libtinyxml2",
325 "liblog",
326 "libbase",
327 ],
328
329 srcs: [
330 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700331 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700332 "thread_local_test.cpp",
333 ],
334
335 conlyflags: [
336 "-fexceptions",
337 "-fnon-call-exceptions",
338 ],
339
340 ldflags: ["-Wl,--export-dynamic"],
341
342 include_dirs: ["bionic/libc"],
343
Yabin Cui1f553ea2017-01-13 12:31:59 -0800344 stl: "libc++_static",
345
Colin Cross2722ebb2016-07-11 16:20:06 -0700346 target: {
347 android: {
348 shared_libs: [
349 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700350 "libdl_preempt_test_1",
351 "libdl_preempt_test_2",
352 "libdl_test_df_1_global",
353 ],
354 static_libs: [
355 // The order of these libraries matters, do not shuffle them.
356 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700357 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700358 "libziparchive",
359 "libz",
360 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800361 "libLLVMObject",
362 "libLLVMBitReader",
363 "libLLVMMC",
364 "libLLVMMCParser",
365 "libLLVMCore",
366 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700367 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700368 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700369 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700370 "-Wl,--enable-new-dtags",
371 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700372 },
373 }
374}
375
376cc_test {
377 name: "bionic-unit-tests",
378 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
379 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800380
381 target: {
382 android: {
383 shared_libs: ["libicuuc"],
384 },
385 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700386}
387
Colin Cross2722ebb2016-07-11 16:20:06 -0700388// -----------------------------------------------------------------------------
389// Tests for the device linked against bionic's static library. Run with:
390// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
391// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
392// -----------------------------------------------------------------------------
393cc_test {
394 name: "bionic-unit-tests-static",
395 defaults: ["bionic_tests_defaults"],
396 host_supported: false,
397
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800398 srcs: [
399 "gtest_preinit_debuggerd.cpp",
400 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700401 whole_static_libs: [
402 "libBionicTests",
403 "libBionicGtestMain",
404 ],
405
406 static_libs: [
407 "libm",
408 "libc",
409 "libc++_static",
410 "libdl",
411 "libtinyxml2",
412 "liblog",
413 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700414 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700415 ],
416
417 static_executable: true,
418 stl: "libc++_static",
419
420 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
421 // still causes issues when linking libc.a and libc++.a, since private isn't
422 // effective until it has been linked. To fix this, just allow multiple symbol
423 // definitions for the static tests.
424 ldflags: ["-Wl,--allow-multiple-definition"],
425}
426
427// -----------------------------------------------------------------------------
428// Tests to run on the host and linked against glibc. Run with:
429// cd bionic/tests; mm bionic-unit-tests-glibc-run
430// -----------------------------------------------------------------------------
431
432cc_test_host {
433 name: "bionic-unit-tests-glibc",
434 defaults: ["bionic_tests_defaults"],
435
436 srcs: [
437 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700438 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700439 "dlfcn_test.cpp",
440 "dl_test.cpp",
441 "pthread_dlfcn_test.cpp",
442 ],
443
444 shared_libs: [
445 "libdl_preempt_test_1",
446 "libdl_preempt_test_2",
447
448 "libdl_test_df_1_global",
449 ],
450
451 whole_static_libs: [
452 "libBionicStandardTests",
453 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700454 "libfortify1-tests-clang",
455 "libfortify2-tests-clang",
456 ],
457
458 static_libs: [
459 "libbase",
460 "liblog",
461 "libcutils",
462 ],
463
464 host_ldlibs: [
465 "-lresolv",
466 "-lrt",
467 "-ldl",
468 "-lutil",
469 ],
470
471 include_dirs: ["bionic/libc"],
472
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800473 ldflags: [
474 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
475 "-Wl,--export-dynamic",
476 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700477
478 sanitize: {
479 never: false,
480 },
481}
482
483subdirs = ["libs"]