blob: 4ea1122abab3d0b014d7e2222025d516f87d4da4 [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",
55 "buffer_tests.cpp",
56 "bug_26110743_test.cpp",
57 "complex_test.cpp",
58 "ctype_test.cpp",
59 "dirent_test.cpp",
60 "error_test.cpp",
61 "eventfd_test.cpp",
62 "fcntl_test.cpp",
63 "fenv_test.cpp",
64 "ftw_test.cpp",
65 "getauxval_test.cpp",
66 "getcwd_test.cpp",
67 "grp_pwd_test.cpp",
68 "ifaddrs_test.cpp",
69 "inttypes_test.cpp",
70 "libc_logging_test.cpp",
71 "libgen_basename_test.cpp",
72 "libgen_test.cpp",
73 "locale_test.cpp",
74 "malloc_test.cpp",
75 "math_test.cpp",
76 "mntent_test.cpp",
77 "netdb_test.cpp",
78 "net_if_test.cpp",
79 "netinet_ether_test.cpp",
80 "netinet_in_test.cpp",
81 "netinet_udp_test.cpp",
82 "nl_types_test.cpp",
83 "pthread_test.cpp",
84 "pty_test.cpp",
85 "regex_test.cpp",
86 "resolv_test.cpp",
87 "sched_test.cpp",
88 "search_test.cpp",
89 "semaphore_test.cpp",
90 "setjmp_test.cpp",
91 "signal_test.cpp",
92 "stack_protector_test.cpp",
93 "stack_protector_test_helper.cpp",
94 "stack_unwinding_test.cpp",
95 "stdatomic_test.cpp",
96 "stdint_test.cpp",
97 "stdio_nofortify_test.cpp",
98 "stdio_test.cpp",
99 "stdio_ext_test.cpp",
100 "stdlib_test.cpp",
101 "string_nofortify_test.cpp",
102 "string_test.cpp",
103 "string_posix_strerror_r_test.cpp",
104 "strings_nofortify_test.cpp",
105 "strings_test.cpp",
106 "sstream_test.cpp",
107 "sys_epoll_test.cpp",
108 "sys_mman_test.cpp",
109 "sys_personality_test.cpp",
110 "sys_prctl_test.cpp",
111 "sys_procfs_test.cpp",
112 "sys_ptrace_test.cpp",
113 "sys_quota_test.cpp",
114 "sys_resource_test.cpp",
115 "sys_select_test.cpp",
116 "sys_sendfile_test.cpp",
117 "sys_socket_test.cpp",
118 "sys_stat_test.cpp",
119 "sys_statvfs_test.cpp",
120 "sys_syscall_test.cpp",
121 "sys_sysinfo_test.cpp",
122 "sys_sysmacros_test.cpp",
123 "sys_time_test.cpp",
124 "sys_timex_test.cpp",
125 "sys_types_test.cpp",
126 "sys_uio_test.cpp",
127 "sys_vfs_test.cpp",
128 "sys_xattr_test.cpp",
129 "system_properties_test.cpp",
130 "time_test.cpp",
131 "uchar_test.cpp",
132 "uniqueptr_test.cpp",
133 "unistd_nofortify_test.cpp",
134 "unistd_test.cpp",
135 "utmp_test.cpp",
136 "wchar_test.cpp",
137 "wctype_test.cpp",
138 ],
139
140 include_dirs: [
141 "bionic/libc",
142 "external/tinyxml2",
143 ],
144
145 static_libs: ["libbase"],
146 host_ldlibs: ["-lrt"],
147}
148
149// -----------------------------------------------------------------------------
150// Fortify tests.
151// -----------------------------------------------------------------------------
152
153cc_defaults {
154 name: "bionic_fortify_tests_defaults",
155 cflags: [
156 "-Wno-error",
157 "-U_FORTIFY_SOURCE",
158 ],
159 srcs: ["fortify_test_main.cpp"],
160 target: {
161 host: {
162 clang_cflags: ["-D__clang__"],
163 },
164 },
165}
166
167cc_test_library {
168 name: "libfortify1-tests-gcc",
169 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
170 clang: false,
171 cflags: [
172 "-D_FORTIFY_SOURCE=1",
173 "-DTEST_NAME=Fortify1_gcc"
174 ],
175}
176
177cc_test_library {
178 name: "libfortify2-tests-gcc",
179 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
180 clang: false,
181 cflags: [
182 "-D_FORTIFY_SOURCE=2",
183 "-DTEST_NAME=Fortify2_gcc"
184 ],
185}
186
187cc_test_library {
188 name: "libfortify1-tests-clang",
189 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
190 clang: true,
191 cflags: [
192 "-D_FORTIFY_SOURCE=1",
193 "-DTEST_NAME=Fortify1_clang"
194 ],
195}
196
197cc_test_library {
198 name: "libfortify2-tests-clang",
199 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
200 clang: true,
201 cflags: [
202 "-D_FORTIFY_SOURCE=2",
203 "-DTEST_NAME=Fortify2_clang"
204 ],
205}
206
207// -----------------------------------------------------------------------------
208// Library of all tests (excluding the dynamic linker tests).
209// -----------------------------------------------------------------------------
210cc_test_library {
211 name: "libBionicTests",
212 defaults: ["bionic_tests_defaults"],
213 whole_static_libs: [
214 "libBionicStandardTests",
215 "libfortify1-tests-gcc",
216 "libfortify2-tests-gcc",
217 "libfortify1-tests-clang",
218 "libfortify2-tests-clang",
219 ],
220}
221
222// -----------------------------------------------------------------------------
223// Library of bionic customized gtest main function, with simplified output format.
224// -----------------------------------------------------------------------------
225cc_test_library {
226 name: "libBionicGtestMain",
227 defaults: ["bionic_tests_defaults"],
228 srcs: ["gtest_main.cpp"],
229 target: {
230 darwin: {
231 enabled: true,
232 },
233 },
234}
235
236// -----------------------------------------------------------------------------
237// Library of bionic customized gtest main function, with normal gtest output format,
238// which is needed by bionic cts test.
239// -----------------------------------------------------------------------------
240cc_test_library {
241 name: "libBionicCtsGtestMain",
242 defaults: ["bionic_tests_defaults"],
243 srcs: ["gtest_main.cpp"],
244 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
245}
246
247// -----------------------------------------------------------------------------
248// Tests for the device using bionic's .so. Run with:
249// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
250// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
251// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
252// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
253// -----------------------------------------------------------------------------
254cc_defaults {
255 name: "bionic_unit_tests_defaults",
256 host_supported: false,
257
258 whole_static_libs: [
259 "libBionicTests",
260 "libBionicGtestMain",
261 ],
262
263 static_libs: [
264 "libtinyxml2",
265 "liblog",
266 "libbase",
267 ],
268
269 srcs: [
270 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
271 "atexit_test.cpp",
272 "dl_test.cpp",
273 "dlext_test.cpp",
274 "__cxa_thread_atexit_test.cpp",
275 "dlfcn_test.cpp",
276 "libdl_test.cpp",
277 "pthread_dlfcn_test.cpp",
278 "thread_local_test.cpp",
279 ],
280
281 conlyflags: [
282 "-fexceptions",
283 "-fnon-call-exceptions",
284 ],
285
286 ldflags: ["-Wl,--export-dynamic"],
287
288 include_dirs: ["bionic/libc"],
289
290 target: {
291 android: {
292 shared_libs: [
293 "libdl",
294 "libpagemap",
295 "libdl_preempt_test_1",
296 "libdl_preempt_test_2",
297 "libdl_test_df_1_global",
298 ],
299 static_libs: [
300 // The order of these libraries matters, do not shuffle them.
301 "libbase",
302 "libziparchive",
303 "libz",
304 "libutils",
305 ],
306 },
307 }
308}
309
310cc_test {
311 name: "bionic-unit-tests",
312 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
313 clang: true,
314}
315
316cc_test {
317 name: "bionic-unit-tests-gcc",
318 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
319 clang: false,
320}
321
322// -----------------------------------------------------------------------------
323// Tests for the device linked against bionic's static library. Run with:
324// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
325// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
326// -----------------------------------------------------------------------------
327cc_test {
328 name: "bionic-unit-tests-static",
329 defaults: ["bionic_tests_defaults"],
330 host_supported: false,
331
332 whole_static_libs: [
333 "libBionicTests",
334 "libBionicGtestMain",
335 ],
336
337 static_libs: [
338 "libm",
339 "libc",
340 "libc++_static",
341 "libdl",
342 "libtinyxml2",
343 "liblog",
344 "libbase",
345 ],
346
347 static_executable: true,
348 stl: "libc++_static",
349
350 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
351 // still causes issues when linking libc.a and libc++.a, since private isn't
352 // effective until it has been linked. To fix this, just allow multiple symbol
353 // definitions for the static tests.
354 ldflags: ["-Wl,--allow-multiple-definition"],
355}
356
357// -----------------------------------------------------------------------------
358// Tests to run on the host and linked against glibc. Run with:
359// cd bionic/tests; mm bionic-unit-tests-glibc-run
360// -----------------------------------------------------------------------------
361
362cc_test_host {
363 name: "bionic-unit-tests-glibc",
364 defaults: ["bionic_tests_defaults"],
365
366 srcs: [
367 "atexit_test.cpp",
368 "dlfcn_test.cpp",
369 "dl_test.cpp",
370 "pthread_dlfcn_test.cpp",
371 ],
372
373 shared_libs: [
374 "libdl_preempt_test_1",
375 "libdl_preempt_test_2",
376
377 "libdl_test_df_1_global",
378 ],
379
380 whole_static_libs: [
381 "libBionicStandardTests",
382 "libBionicGtestMain",
383 "libfortify1-tests-gcc",
384 "libfortify2-tests-gcc",
385 "libfortify1-tests-clang",
386 "libfortify2-tests-clang",
387 ],
388
389 static_libs: [
390 "libbase",
391 "liblog",
392 "libcutils",
393 ],
394
395 host_ldlibs: [
396 "-lresolv",
397 "-lrt",
398 "-ldl",
399 "-lutil",
400 ],
401
402 include_dirs: ["bionic/libc"],
403
404 ldflags: ["-Wl,--export-dynamic"],
405
406 sanitize: {
407 never: false,
408 },
409}
410
411subdirs = ["libs"]