blob: 4caaa5495f974cf83f65d00eb92833ff74b4d11c [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"],
253 srcs: ["gtest_main.cpp"],
254 target: {
255 darwin: {
256 enabled: true,
257 },
258 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700259 shared: {
260 enabled: false,
261 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700262}
263
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700264cc_test_library {
265 name: "libBionicLoaderTests",
266 defaults: ["bionic_tests_defaults"],
267 srcs: [
268 "atexit_test.cpp",
269 "dl_test.cpp",
270 "dlfcn_test.cpp",
271 "pthread_dlfcn_test.cpp",
272 ],
273 static_libs: [
274 "libbase",
275 ],
276 include_dirs: [
277 "bionic/libc",
278 ],
279 shared: {
280 enabled: false,
281 },
282 target: {
283 android: {
284 srcs: [
285 "dlext_test.cpp",
286 "libdl_test.cpp",
287 ],
288 static_libs: [
289 "libpagemap",
290 ],
291 }
292 }
293}
294
Colin Cross2722ebb2016-07-11 16:20:06 -0700295// -----------------------------------------------------------------------------
296// Library of bionic customized gtest main function, with normal gtest output format,
297// which is needed by bionic cts test.
298// -----------------------------------------------------------------------------
299cc_test_library {
300 name: "libBionicCtsGtestMain",
301 defaults: ["bionic_tests_defaults"],
302 srcs: ["gtest_main.cpp"],
303 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700304 shared: {
305 enabled: false,
306 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700307}
308
309// -----------------------------------------------------------------------------
310// Tests for the device using bionic's .so. Run with:
311// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
312// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
313// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
314// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
315// -----------------------------------------------------------------------------
316cc_defaults {
317 name: "bionic_unit_tests_defaults",
318 host_supported: false,
319
320 whole_static_libs: [
321 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700322 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700323 "libBionicGtestMain",
324 ],
325
326 static_libs: [
327 "libtinyxml2",
328 "liblog",
329 "libbase",
330 ],
331
332 srcs: [
333 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700334 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700335 "thread_local_test.cpp",
336 ],
337
338 conlyflags: [
339 "-fexceptions",
340 "-fnon-call-exceptions",
341 ],
342
343 ldflags: ["-Wl,--export-dynamic"],
344
345 include_dirs: ["bionic/libc"],
346
347 target: {
348 android: {
349 shared_libs: [
350 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700351 "libdl_preempt_test_1",
352 "libdl_preempt_test_2",
353 "libdl_test_df_1_global",
354 ],
355 static_libs: [
356 // The order of these libraries matters, do not shuffle them.
357 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700358 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700359 "libziparchive",
360 "libz",
361 "libutils",
362 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700363 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700364 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700365 "-Wl,--enable-new-dtags",
366 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700367 },
368 }
369}
370
371cc_test {
372 name: "bionic-unit-tests",
373 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
374 clang: true,
375}
376
377cc_test {
378 name: "bionic-unit-tests-gcc",
379 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
380 clang: false,
381}
382
383// -----------------------------------------------------------------------------
384// Tests for the device linked against bionic's static library. Run with:
385// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
386// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
387// -----------------------------------------------------------------------------
388cc_test {
389 name: "bionic-unit-tests-static",
390 defaults: ["bionic_tests_defaults"],
391 host_supported: false,
392
393 whole_static_libs: [
394 "libBionicTests",
395 "libBionicGtestMain",
396 ],
397
398 static_libs: [
399 "libm",
400 "libc",
401 "libc++_static",
402 "libdl",
403 "libtinyxml2",
404 "liblog",
405 "libbase",
406 ],
407
408 static_executable: true,
409 stl: "libc++_static",
410
411 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
412 // still causes issues when linking libc.a and libc++.a, since private isn't
413 // effective until it has been linked. To fix this, just allow multiple symbol
414 // definitions for the static tests.
415 ldflags: ["-Wl,--allow-multiple-definition"],
416}
417
418// -----------------------------------------------------------------------------
419// Tests to run on the host and linked against glibc. Run with:
420// cd bionic/tests; mm bionic-unit-tests-glibc-run
421// -----------------------------------------------------------------------------
422
423cc_test_host {
424 name: "bionic-unit-tests-glibc",
425 defaults: ["bionic_tests_defaults"],
426
427 srcs: [
428 "atexit_test.cpp",
429 "dlfcn_test.cpp",
430 "dl_test.cpp",
431 "pthread_dlfcn_test.cpp",
432 ],
433
434 shared_libs: [
435 "libdl_preempt_test_1",
436 "libdl_preempt_test_2",
437
438 "libdl_test_df_1_global",
439 ],
440
441 whole_static_libs: [
442 "libBionicStandardTests",
443 "libBionicGtestMain",
444 "libfortify1-tests-gcc",
445 "libfortify2-tests-gcc",
446 "libfortify1-tests-clang",
447 "libfortify2-tests-clang",
448 ],
449
450 static_libs: [
451 "libbase",
452 "liblog",
453 "libcutils",
454 ],
455
456 host_ldlibs: [
457 "-lresolv",
458 "-lrt",
459 "-ldl",
460 "-lutil",
461 ],
462
463 include_dirs: ["bionic/libc"],
464
465 ldflags: ["-Wl,--export-dynamic"],
466
467 sanitize: {
468 never: false,
469 },
470}
471
472subdirs = ["libs"]