1// Build the unit tests.
2
3package {
4    // http://go/android-license-faq
5    // A large-scale-change added 'default_applicable_licenses' to import
6    // the below license kinds from "libnativehelper_license":
7    //   SPDX-license-identifier-Apache-2.0
8    default_applicable_licenses: ["libnativehelper_license"],
9}
10
11cc_defaults {
12    name: "libnativehelper_test_defaults",
13    cflags: [
14        // Base set of cflags used by all things ART.
15        "-fno-rtti",
16        "-ggdb3",
17        "-Wall",
18        "-Werror",
19        "-Wextra",
20        "-Wstrict-aliasing",
21        "-fstrict-aliasing",
22        "-Wunreachable-code",
23        "-Wredundant-decls",
24        "-Wshadow",
25        "-Wunused",
26        "-fvisibility=protected",
27
28        // Warn about thread safety violations with clang.
29        "-Wthread-safety",
30        "-Wthread-safety-negative",
31
32        // Warn if switch fallthroughs aren't annotated.
33        "-Wimplicit-fallthrough",
34
35        // Enable float equality warnings.
36        "-Wfloat-equal",
37
38        // Enable warning of converting ints to void*.
39        "-Wint-to-void-pointer-cast",
40
41        // Enable warning for deprecated language features.
42        "-Wdeprecated",
43
44        // Disable warning from external/libcxxabi/include/cxxabi.h
45        "-Wno-deprecated-dynamic-exception-spec",
46
47        // Enable warning for unreachable break & return.
48        "-Wunreachable-code-break",
49        "-Wunreachable-code-return",
50
51        // Enable thread annotations for std::mutex, etc.
52        "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
53    ],
54    host_supported: true,
55    test_options: {
56        unit_test: true,
57    },
58    tidy: true,
59}
60
61cc_test {
62    name: "libnativehelper_tests",
63    defaults: ["libnativehelper_test_defaults"],
64    test_suites: ["device-tests"],
65    srcs: [
66        "scoped_local_frame_test.cpp",
67        "scoped_local_ref_test.cpp",
68        "scoped_primitive_array_test.cpp",
69        "libnativehelper_api_test.c",
70        "JniSafeRegisterNativeMethods_test.cpp",
71    ],
72    shared_libs: ["libnativehelper"],
73}
74
75cc_test {
76    name: "libnativehelper_lazy_tests",
77    defaults: ["libnativehelper_test_defaults"],
78    test_suites: ["device-tests"],
79    srcs: ["libnativehelper_lazy_test.cpp"],
80    shared_libs: ["liblog"],
81    static_libs: ["libnativehelper_lazy"],
82}
83
84// Tests for internal functions that aren't present in the APEX stub API. Use
85// `bootstrap:true` to bypass the stub library. This test won't link when
86// prebuilts are preferred, because we cannot link against the source variant
87// then.
88// TODO(b/180107266): Enable in TEST_MAPPING. Also use a better way than
89// `bootstrap:true` - `test_for` ought to work but fails because the test is
90// host enabled so host variants of the APEXes are expected.
91cc_test {
92    name: "libnativehelper_internal_tests",
93    defaults: [
94        "art_module_source_build_defaults",
95        "libnativehelper_test_defaults",
96    ],
97    srcs: [
98        "ExpandableString_test.cpp",
99        "JniInvocation_test.cpp",
100    ],
101    bootstrap: true,
102    shared_libs: ["libnativehelper"],
103}
104