blob: 688d8e1e14147eafc6c2fce1919e7c2f2d408e17 [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",
71 "libc_logging_test.cpp",
72 "libgen_basename_test.cpp",
73 "libgen_test.cpp",
74 "locale_test.cpp",
75 "malloc_test.cpp",
76 "math_test.cpp",
77 "mntent_test.cpp",
78 "netdb_test.cpp",
79 "net_if_test.cpp",
80 "netinet_ether_test.cpp",
81 "netinet_in_test.cpp",
82 "netinet_udp_test.cpp",
83 "nl_types_test.cpp",
84 "pthread_test.cpp",
85 "pty_test.cpp",
86 "regex_test.cpp",
87 "resolv_test.cpp",
88 "sched_test.cpp",
89 "search_test.cpp",
90 "semaphore_test.cpp",
91 "setjmp_test.cpp",
92 "signal_test.cpp",
93 "stack_protector_test.cpp",
94 "stack_protector_test_helper.cpp",
95 "stack_unwinding_test.cpp",
96 "stdatomic_test.cpp",
97 "stdint_test.cpp",
98 "stdio_nofortify_test.cpp",
99 "stdio_test.cpp",
100 "stdio_ext_test.cpp",
101 "stdlib_test.cpp",
102 "string_nofortify_test.cpp",
103 "string_test.cpp",
104 "string_posix_strerror_r_test.cpp",
105 "strings_nofortify_test.cpp",
106 "strings_test.cpp",
107 "sstream_test.cpp",
108 "sys_epoll_test.cpp",
109 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700110 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "sys_personality_test.cpp",
112 "sys_prctl_test.cpp",
113 "sys_procfs_test.cpp",
114 "sys_ptrace_test.cpp",
115 "sys_quota_test.cpp",
116 "sys_resource_test.cpp",
117 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700118 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700120 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700121 "sys_socket_test.cpp",
122 "sys_stat_test.cpp",
123 "sys_statvfs_test.cpp",
124 "sys_syscall_test.cpp",
125 "sys_sysinfo_test.cpp",
126 "sys_sysmacros_test.cpp",
127 "sys_time_test.cpp",
128 "sys_timex_test.cpp",
129 "sys_types_test.cpp",
130 "sys_uio_test.cpp",
131 "sys_vfs_test.cpp",
132 "sys_xattr_test.cpp",
133 "system_properties_test.cpp",
134 "time_test.cpp",
135 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "unistd_nofortify_test.cpp",
137 "unistd_test.cpp",
138 "utmp_test.cpp",
139 "wchar_test.cpp",
140 "wctype_test.cpp",
141 ],
142
143 include_dirs: [
144 "bionic/libc",
145 "external/tinyxml2",
146 ],
147
Dan Willemsen41567702016-08-31 16:35:01 -0700148 static_libs: [
149 "libtinyxml2",
150 "liblog",
151 "libbase",
152 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700153 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700154 shared: {
155 enabled: false,
156 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700157}
158
159// -----------------------------------------------------------------------------
160// Fortify tests.
161// -----------------------------------------------------------------------------
162
163cc_defaults {
164 name: "bionic_fortify_tests_defaults",
165 cflags: [
166 "-Wno-error",
167 "-U_FORTIFY_SOURCE",
168 ],
169 srcs: ["fortify_test_main.cpp"],
170 target: {
171 host: {
172 clang_cflags: ["-D__clang__"],
173 },
174 },
175}
176
177cc_test_library {
178 name: "libfortify1-tests-gcc",
179 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
180 clang: false,
181 cflags: [
182 "-D_FORTIFY_SOURCE=1",
183 "-DTEST_NAME=Fortify1_gcc"
184 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700185 shared: {
186 enabled: false,
187 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700188}
189
190cc_test_library {
191 name: "libfortify2-tests-gcc",
192 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
193 clang: false,
194 cflags: [
195 "-D_FORTIFY_SOURCE=2",
196 "-DTEST_NAME=Fortify2_gcc"
197 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700198 shared: {
199 enabled: false,
200 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700201}
202
203cc_test_library {
204 name: "libfortify1-tests-clang",
205 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
206 clang: true,
207 cflags: [
208 "-D_FORTIFY_SOURCE=1",
209 "-DTEST_NAME=Fortify1_clang"
210 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700211 shared: {
212 enabled: false,
213 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700214}
215
216cc_test_library {
217 name: "libfortify2-tests-clang",
218 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
219 clang: true,
220 cflags: [
221 "-D_FORTIFY_SOURCE=2",
222 "-DTEST_NAME=Fortify2_clang"
223 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700224 shared: {
225 enabled: false,
226 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700227}
228
229// -----------------------------------------------------------------------------
230// Library of all tests (excluding the dynamic linker tests).
231// -----------------------------------------------------------------------------
232cc_test_library {
233 name: "libBionicTests",
234 defaults: ["bionic_tests_defaults"],
235 whole_static_libs: [
236 "libBionicStandardTests",
237 "libfortify1-tests-gcc",
238 "libfortify2-tests-gcc",
239 "libfortify1-tests-clang",
240 "libfortify2-tests-clang",
241 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700242 shared: {
243 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700244 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700245}
246
247// -----------------------------------------------------------------------------
248// Library of bionic customized gtest main function, with simplified output format.
249// -----------------------------------------------------------------------------
250cc_test_library {
251 name: "libBionicGtestMain",
252 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700253 srcs: [
254 "gtest_main.cpp",
255 "gtest_globals.cpp",
256 ],
257 static_libs: [
258 "libbase",
259 ],
260 include_dirs: [
261 "bionic/libc",
262 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700263 target: {
264 darwin: {
265 enabled: true,
266 },
267 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700268 shared: {
269 enabled: false,
270 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700271}
272
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700273cc_test_library {
274 name: "libBionicLoaderTests",
275 defaults: ["bionic_tests_defaults"],
276 srcs: [
277 "atexit_test.cpp",
278 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700279 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700280 "dlfcn_test.cpp",
281 "pthread_dlfcn_test.cpp",
282 ],
283 static_libs: [
284 "libbase",
285 ],
286 include_dirs: [
287 "bionic/libc",
288 ],
289 shared: {
290 enabled: false,
291 },
292 target: {
293 android: {
294 srcs: [
295 "dlext_test.cpp",
296 "libdl_test.cpp",
297 ],
298 static_libs: [
299 "libpagemap",
300 ],
301 }
302 }
303}
304
Colin Cross2722ebb2016-07-11 16:20:06 -0700305// -----------------------------------------------------------------------------
306// Library of bionic customized gtest main function, with normal gtest output format,
307// which is needed by bionic cts test.
308// -----------------------------------------------------------------------------
309cc_test_library {
310 name: "libBionicCtsGtestMain",
311 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700312 srcs: [
313 "gtest_main.cpp",
314 "gtest_globals_cts.cpp",
315 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700316 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700317 shared: {
318 enabled: false,
319 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700320}
321
322// -----------------------------------------------------------------------------
323// Tests for the device using bionic's .so. Run with:
324// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
325// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
326// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
327// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
328// -----------------------------------------------------------------------------
329cc_defaults {
330 name: "bionic_unit_tests_defaults",
331 host_supported: false,
332
333 whole_static_libs: [
334 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700335 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700336 "libBionicGtestMain",
337 ],
338
339 static_libs: [
340 "libtinyxml2",
341 "liblog",
342 "libbase",
343 ],
344
345 srcs: [
346 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700347 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700348 "thread_local_test.cpp",
349 ],
350
351 conlyflags: [
352 "-fexceptions",
353 "-fnon-call-exceptions",
354 ],
355
356 ldflags: ["-Wl,--export-dynamic"],
357
358 include_dirs: ["bionic/libc"],
359
360 target: {
361 android: {
362 shared_libs: [
363 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700364 "libdl_preempt_test_1",
365 "libdl_preempt_test_2",
366 "libdl_test_df_1_global",
367 ],
368 static_libs: [
369 // The order of these libraries matters, do not shuffle them.
370 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700371 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700372 "libziparchive",
373 "libz",
374 "libutils",
375 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700376 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700377 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700378 "-Wl,--enable-new-dtags",
379 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700380 },
381 }
382}
383
384cc_test {
385 name: "bionic-unit-tests",
386 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
387 clang: true,
388}
389
390cc_test {
391 name: "bionic-unit-tests-gcc",
392 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
393 clang: false,
394}
395
396// -----------------------------------------------------------------------------
397// Tests for the device linked against bionic's static library. Run with:
398// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
399// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
400// -----------------------------------------------------------------------------
401cc_test {
402 name: "bionic-unit-tests-static",
403 defaults: ["bionic_tests_defaults"],
404 host_supported: false,
405
406 whole_static_libs: [
407 "libBionicTests",
408 "libBionicGtestMain",
409 ],
410
411 static_libs: [
412 "libm",
413 "libc",
414 "libc++_static",
415 "libdl",
416 "libtinyxml2",
417 "liblog",
418 "libbase",
419 ],
420
421 static_executable: true,
422 stl: "libc++_static",
423
424 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
425 // still causes issues when linking libc.a and libc++.a, since private isn't
426 // effective until it has been linked. To fix this, just allow multiple symbol
427 // definitions for the static tests.
428 ldflags: ["-Wl,--allow-multiple-definition"],
429}
430
431// -----------------------------------------------------------------------------
432// Tests to run on the host and linked against glibc. Run with:
433// cd bionic/tests; mm bionic-unit-tests-glibc-run
434// -----------------------------------------------------------------------------
435
436cc_test_host {
437 name: "bionic-unit-tests-glibc",
438 defaults: ["bionic_tests_defaults"],
439
440 srcs: [
441 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700442 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700443 "dlfcn_test.cpp",
444 "dl_test.cpp",
445 "pthread_dlfcn_test.cpp",
446 ],
447
448 shared_libs: [
449 "libdl_preempt_test_1",
450 "libdl_preempt_test_2",
451
452 "libdl_test_df_1_global",
453 ],
454
455 whole_static_libs: [
456 "libBionicStandardTests",
457 "libBionicGtestMain",
458 "libfortify1-tests-gcc",
459 "libfortify2-tests-gcc",
460 "libfortify1-tests-clang",
461 "libfortify2-tests-clang",
462 ],
463
464 static_libs: [
465 "libbase",
466 "liblog",
467 "libcutils",
468 ],
469
470 host_ldlibs: [
471 "-lresolv",
472 "-lrt",
473 "-ldl",
474 "-lutil",
475 ],
476
477 include_dirs: ["bionic/libc"],
478
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800479 ldflags: [
480 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
481 "-Wl,--export-dynamic",
482 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700483
484 sanitize: {
485 never: false,
486 },
487}
488
489subdirs = ["libs"]