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