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