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