OSDN Git Service

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