blob: c6ec944420edec5635aa6242fe11119fd59719a9 [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",
Colin Cross2722ebb2016-07-11 16:20:06 -0700132 "unistd_nofortify_test.cpp",
133 "unistd_test.cpp",
134 "utmp_test.cpp",
135 "wchar_test.cpp",
136 "wctype_test.cpp",
137 ],
138
139 include_dirs: [
140 "bionic/libc",
141 "external/tinyxml2",
142 ],
143
144 static_libs: ["libbase"],
145 host_ldlibs: ["-lrt"],
146}
147
148// -----------------------------------------------------------------------------
149// Fortify tests.
150// -----------------------------------------------------------------------------
151
152cc_defaults {
153 name: "bionic_fortify_tests_defaults",
154 cflags: [
155 "-Wno-error",
156 "-U_FORTIFY_SOURCE",
157 ],
158 srcs: ["fortify_test_main.cpp"],
159 target: {
160 host: {
161 clang_cflags: ["-D__clang__"],
162 },
163 },
164}
165
166cc_test_library {
167 name: "libfortify1-tests-gcc",
168 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
169 clang: false,
170 cflags: [
171 "-D_FORTIFY_SOURCE=1",
172 "-DTEST_NAME=Fortify1_gcc"
173 ],
174}
175
176cc_test_library {
177 name: "libfortify2-tests-gcc",
178 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
179 clang: false,
180 cflags: [
181 "-D_FORTIFY_SOURCE=2",
182 "-DTEST_NAME=Fortify2_gcc"
183 ],
184}
185
186cc_test_library {
187 name: "libfortify1-tests-clang",
188 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
189 clang: true,
190 cflags: [
191 "-D_FORTIFY_SOURCE=1",
192 "-DTEST_NAME=Fortify1_clang"
193 ],
194}
195
196cc_test_library {
197 name: "libfortify2-tests-clang",
198 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
199 clang: true,
200 cflags: [
201 "-D_FORTIFY_SOURCE=2",
202 "-DTEST_NAME=Fortify2_clang"
203 ],
204}
205
206// -----------------------------------------------------------------------------
207// Library of all tests (excluding the dynamic linker tests).
208// -----------------------------------------------------------------------------
209cc_test_library {
210 name: "libBionicTests",
211 defaults: ["bionic_tests_defaults"],
212 whole_static_libs: [
213 "libBionicStandardTests",
214 "libfortify1-tests-gcc",
215 "libfortify2-tests-gcc",
216 "libfortify1-tests-clang",
217 "libfortify2-tests-clang",
218 ],
219}
220
221// -----------------------------------------------------------------------------
222// Library of bionic customized gtest main function, with simplified output format.
223// -----------------------------------------------------------------------------
224cc_test_library {
225 name: "libBionicGtestMain",
226 defaults: ["bionic_tests_defaults"],
227 srcs: ["gtest_main.cpp"],
228 target: {
229 darwin: {
230 enabled: true,
231 },
232 },
233}
234
235// -----------------------------------------------------------------------------
236// Library of bionic customized gtest main function, with normal gtest output format,
237// which is needed by bionic cts test.
238// -----------------------------------------------------------------------------
239cc_test_library {
240 name: "libBionicCtsGtestMain",
241 defaults: ["bionic_tests_defaults"],
242 srcs: ["gtest_main.cpp"],
243 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
244}
245
246// -----------------------------------------------------------------------------
247// Tests for the device using bionic's .so. Run with:
248// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
249// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
250// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
251// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
252// -----------------------------------------------------------------------------
253cc_defaults {
254 name: "bionic_unit_tests_defaults",
255 host_supported: false,
256
257 whole_static_libs: [
258 "libBionicTests",
259 "libBionicGtestMain",
260 ],
261
262 static_libs: [
263 "libtinyxml2",
264 "liblog",
265 "libbase",
266 ],
267
268 srcs: [
269 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
270 "atexit_test.cpp",
271 "dl_test.cpp",
272 "dlext_test.cpp",
273 "__cxa_thread_atexit_test.cpp",
274 "dlfcn_test.cpp",
275 "libdl_test.cpp",
276 "pthread_dlfcn_test.cpp",
277 "thread_local_test.cpp",
278 ],
279
280 conlyflags: [
281 "-fexceptions",
282 "-fnon-call-exceptions",
283 ],
284
285 ldflags: ["-Wl,--export-dynamic"],
286
287 include_dirs: ["bionic/libc"],
288
289 target: {
290 android: {
291 shared_libs: [
292 "libdl",
293 "libpagemap",
294 "libdl_preempt_test_1",
295 "libdl_preempt_test_2",
296 "libdl_test_df_1_global",
297 ],
298 static_libs: [
299 // The order of these libraries matters, do not shuffle them.
300 "libbase",
301 "libziparchive",
302 "libz",
303 "libutils",
304 ],
305 },
306 }
307}
308
309cc_test {
310 name: "bionic-unit-tests",
311 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
312 clang: true,
313}
314
315cc_test {
316 name: "bionic-unit-tests-gcc",
317 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
318 clang: false,
319}
320
321// -----------------------------------------------------------------------------
322// Tests for the device linked against bionic's static library. Run with:
323// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
324// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
325// -----------------------------------------------------------------------------
326cc_test {
327 name: "bionic-unit-tests-static",
328 defaults: ["bionic_tests_defaults"],
329 host_supported: false,
330
331 whole_static_libs: [
332 "libBionicTests",
333 "libBionicGtestMain",
334 ],
335
336 static_libs: [
337 "libm",
338 "libc",
339 "libc++_static",
340 "libdl",
341 "libtinyxml2",
342 "liblog",
343 "libbase",
344 ],
345
346 static_executable: true,
347 stl: "libc++_static",
348
349 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
350 // still causes issues when linking libc.a and libc++.a, since private isn't
351 // effective until it has been linked. To fix this, just allow multiple symbol
352 // definitions for the static tests.
353 ldflags: ["-Wl,--allow-multiple-definition"],
354}
355
356// -----------------------------------------------------------------------------
357// Tests to run on the host and linked against glibc. Run with:
358// cd bionic/tests; mm bionic-unit-tests-glibc-run
359// -----------------------------------------------------------------------------
360
361cc_test_host {
362 name: "bionic-unit-tests-glibc",
363 defaults: ["bionic_tests_defaults"],
364
365 srcs: [
366 "atexit_test.cpp",
367 "dlfcn_test.cpp",
368 "dl_test.cpp",
369 "pthread_dlfcn_test.cpp",
370 ],
371
372 shared_libs: [
373 "libdl_preempt_test_1",
374 "libdl_preempt_test_2",
375
376 "libdl_test_df_1_global",
377 ],
378
379 whole_static_libs: [
380 "libBionicStandardTests",
381 "libBionicGtestMain",
382 "libfortify1-tests-gcc",
383 "libfortify2-tests-gcc",
384 "libfortify1-tests-clang",
385 "libfortify2-tests-clang",
386 ],
387
388 static_libs: [
389 "libbase",
390 "liblog",
391 "libcutils",
392 ],
393
394 host_ldlibs: [
395 "-lresolv",
396 "-lrt",
397 "-ldl",
398 "-lutil",
399 ],
400
401 include_dirs: ["bionic/libc"],
402
403 ldflags: ["-Wl,--export-dynamic"],
404
405 sanitize: {
406 never: false,
407 },
408}
409
410subdirs = ["libs"]