blob: da90a92f12d40bdc22879d10cc49327c2fe0c687 [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 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700158}
159
160// -----------------------------------------------------------------------------
161// Fortify tests.
162// -----------------------------------------------------------------------------
163
164cc_defaults {
165 name: "bionic_fortify_tests_defaults",
166 cflags: [
167 "-Wno-error",
168 "-U_FORTIFY_SOURCE",
169 ],
170 srcs: ["fortify_test_main.cpp"],
171 target: {
172 host: {
173 clang_cflags: ["-D__clang__"],
174 },
175 },
176}
177
178cc_test_library {
179 name: "libfortify1-tests-gcc",
180 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
181 clang: false,
182 cflags: [
183 "-D_FORTIFY_SOURCE=1",
184 "-DTEST_NAME=Fortify1_gcc"
185 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700186 shared: {
187 enabled: false,
188 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700189}
190
191cc_test_library {
192 name: "libfortify2-tests-gcc",
193 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
194 clang: false,
195 cflags: [
196 "-D_FORTIFY_SOURCE=2",
197 "-DTEST_NAME=Fortify2_gcc"
198 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700199 shared: {
200 enabled: false,
201 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700202}
203
204cc_test_library {
205 name: "libfortify1-tests-clang",
206 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
207 clang: true,
208 cflags: [
209 "-D_FORTIFY_SOURCE=1",
210 "-DTEST_NAME=Fortify1_clang"
211 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700212 shared: {
213 enabled: false,
214 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700215}
216
217cc_test_library {
218 name: "libfortify2-tests-clang",
219 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
220 clang: true,
221 cflags: [
222 "-D_FORTIFY_SOURCE=2",
223 "-DTEST_NAME=Fortify2_clang"
224 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700225 shared: {
226 enabled: false,
227 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700228}
229
230// -----------------------------------------------------------------------------
231// Library of all tests (excluding the dynamic linker tests).
232// -----------------------------------------------------------------------------
233cc_test_library {
234 name: "libBionicTests",
235 defaults: ["bionic_tests_defaults"],
236 whole_static_libs: [
237 "libBionicStandardTests",
238 "libfortify1-tests-gcc",
239 "libfortify2-tests-gcc",
240 "libfortify1-tests-clang",
241 "libfortify2-tests-clang",
242 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700243 shared: {
244 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700245 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700246}
247
248// -----------------------------------------------------------------------------
249// Library of bionic customized gtest main function, with simplified output format.
250// -----------------------------------------------------------------------------
251cc_test_library {
252 name: "libBionicGtestMain",
253 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700254 srcs: [
255 "gtest_main.cpp",
256 "gtest_globals.cpp",
257 ],
258 static_libs: [
259 "libbase",
260 ],
261 include_dirs: [
262 "bionic/libc",
263 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700264 target: {
265 darwin: {
266 enabled: true,
267 },
268 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700269 shared: {
270 enabled: false,
271 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700272}
273
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700274cc_test_library {
275 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800276 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700277 srcs: [
278 "atexit_test.cpp",
279 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700280 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700281 "dlfcn_test.cpp",
282 "pthread_dlfcn_test.cpp",
283 ],
284 static_libs: [
285 "libbase",
286 ],
287 include_dirs: [
288 "bionic/libc",
289 ],
290 shared: {
291 enabled: false,
292 },
293 target: {
294 android: {
295 srcs: [
296 "dlext_test.cpp",
297 "libdl_test.cpp",
298 ],
299 static_libs: [
300 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800301 "libLLVMObject",
302 "libLLVMBitReader",
303 "libLLVMMC",
304 "libLLVMMCParser",
305 "libLLVMCore",
306 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700307 ],
308 }
309 }
310}
311
Colin Cross2722ebb2016-07-11 16:20:06 -0700312// -----------------------------------------------------------------------------
313// Library of bionic customized gtest main function, with normal gtest output format,
314// which is needed by bionic cts test.
315// -----------------------------------------------------------------------------
316cc_test_library {
317 name: "libBionicCtsGtestMain",
318 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700319 srcs: [
320 "gtest_main.cpp",
321 "gtest_globals_cts.cpp",
322 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700323 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700324 shared: {
325 enabled: false,
326 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700327}
328
329// -----------------------------------------------------------------------------
330// Tests for the device using bionic's .so. Run with:
331// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
332// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
333// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
334// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
335// -----------------------------------------------------------------------------
336cc_defaults {
337 name: "bionic_unit_tests_defaults",
338 host_supported: false,
339
340 whole_static_libs: [
341 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700342 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700343 "libBionicGtestMain",
344 ],
345
346 static_libs: [
347 "libtinyxml2",
348 "liblog",
349 "libbase",
350 ],
351
352 srcs: [
353 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700354 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700355 "thread_local_test.cpp",
356 ],
357
358 conlyflags: [
359 "-fexceptions",
360 "-fnon-call-exceptions",
361 ],
362
363 ldflags: ["-Wl,--export-dynamic"],
364
365 include_dirs: ["bionic/libc"],
366
367 target: {
368 android: {
369 shared_libs: [
370 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700371 "libdl_preempt_test_1",
372 "libdl_preempt_test_2",
373 "libdl_test_df_1_global",
374 ],
375 static_libs: [
376 // The order of these libraries matters, do not shuffle them.
377 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700378 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700379 "libziparchive",
380 "libz",
381 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800382 "libLLVMObject",
383 "libLLVMBitReader",
384 "libLLVMMC",
385 "libLLVMMCParser",
386 "libLLVMCore",
387 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700388 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700389 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700390 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700391 "-Wl,--enable-new-dtags",
392 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700393 },
394 }
395}
396
397cc_test {
398 name: "bionic-unit-tests",
399 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
400 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800401
402 target: {
403 android: {
404 shared_libs: ["libicuuc"],
405 },
406 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700407}
408
409cc_test {
410 name: "bionic-unit-tests-gcc",
411 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
412 clang: false,
413}
414
415// -----------------------------------------------------------------------------
416// Tests for the device linked against bionic's static library. Run with:
417// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
418// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
419// -----------------------------------------------------------------------------
420cc_test {
421 name: "bionic-unit-tests-static",
422 defaults: ["bionic_tests_defaults"],
423 host_supported: false,
424
425 whole_static_libs: [
426 "libBionicTests",
427 "libBionicGtestMain",
428 ],
429
430 static_libs: [
431 "libm",
432 "libc",
433 "libc++_static",
434 "libdl",
435 "libtinyxml2",
436 "liblog",
437 "libbase",
438 ],
439
440 static_executable: true,
441 stl: "libc++_static",
442
443 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
444 // still causes issues when linking libc.a and libc++.a, since private isn't
445 // effective until it has been linked. To fix this, just allow multiple symbol
446 // definitions for the static tests.
447 ldflags: ["-Wl,--allow-multiple-definition"],
448}
449
450// -----------------------------------------------------------------------------
451// Tests to run on the host and linked against glibc. Run with:
452// cd bionic/tests; mm bionic-unit-tests-glibc-run
453// -----------------------------------------------------------------------------
454
455cc_test_host {
456 name: "bionic-unit-tests-glibc",
457 defaults: ["bionic_tests_defaults"],
458
459 srcs: [
460 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700461 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700462 "dlfcn_test.cpp",
463 "dl_test.cpp",
464 "pthread_dlfcn_test.cpp",
465 ],
466
467 shared_libs: [
468 "libdl_preempt_test_1",
469 "libdl_preempt_test_2",
470
471 "libdl_test_df_1_global",
472 ],
473
474 whole_static_libs: [
475 "libBionicStandardTests",
476 "libBionicGtestMain",
477 "libfortify1-tests-gcc",
478 "libfortify2-tests-gcc",
479 "libfortify1-tests-clang",
480 "libfortify2-tests-clang",
481 ],
482
483 static_libs: [
484 "libbase",
485 "liblog",
486 "libcutils",
487 ],
488
489 host_ldlibs: [
490 "-lresolv",
491 "-lrt",
492 "-ldl",
493 "-lutil",
494 ],
495
496 include_dirs: ["bionic/libc"],
497
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800498 ldflags: [
499 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
500 "-Wl,--export-dynamic",
501 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700502
503 sanitize: {
504 never: false,
505 },
506}
507
508subdirs = ["libs"]