xref: /aosp_15_r20/art/libnativebridge/tests/Android.bp (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1//
2// Copyright (C) 2017 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
17package {
18    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "art_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["art_license"],
24}
25
26cc_defaults {
27    name: "libnativebridge-test-case-defaults",
28    defaults: [
29        "art_defaults",
30        "art_test_common_defaults",
31    ],
32    host_supported: true,
33    // TODO(mast): Split up art_gtest_defaults so that it can be used for the
34    // following without pulling in lots of libs.
35    target: {
36        linux: {
37            cflags: [
38                // gtest issue
39                "-Wno-used-but-marked-unused",
40                "-Wno-deprecated",
41                "-Wno-missing-noreturn",
42            ],
43        },
44    },
45    header_libs: [
46        "jni_headers",
47        "libnativebridge-headers",
48    ],
49    cppflags: ["-fvisibility=protected"],
50}
51
52cc_test_library {
53    name: "libnativebridge-test-case",
54    srcs: ["NativeBridgeTestCase.cpp"],
55    defaults: ["libnativebridge-test-case-defaults"],
56}
57
58cc_test_library {
59    name: "libnativebridge2-test-case",
60    srcs: ["NativeBridgeTestCase2.cpp"],
61    defaults: ["libnativebridge-test-case-defaults"],
62}
63
64cc_test_library {
65    name: "libnativebridge3-test-case",
66    srcs: ["NativeBridgeTestCase3.cpp"],
67    defaults: ["libnativebridge-test-case-defaults"],
68}
69
70cc_test_library {
71    name: "libnativebridge6-test-case",
72    srcs: ["NativeBridgeTestCase6.cpp"],
73    defaults: ["libnativebridge-test-case-defaults"],
74    shared_libs: [
75        "libnativebridge6prezygotefork",
76    ],
77}
78
79cc_test_library {
80    name: "libnativebridge7-test-case",
81    srcs: ["NativeBridgeTestCase7.cpp"],
82    defaults: ["libnativebridge-test-case-defaults"],
83    shared_libs: [
84        "libnativebridge7criticalnative",
85    ],
86}
87
88// A helper library to produce test-case side effect of PreZygoteForkNativeBridge.
89cc_test_library {
90    name: "libnativebridge6prezygotefork",
91    srcs: ["NativeBridge6PreZygoteFork_lib.cpp"],
92    defaults: ["libnativebridge-test-case-defaults"],
93}
94
95cc_test_library {
96    name: "libnativebridge7criticalnative",
97    srcs: ["NativeBridge7CriticalNative_lib.cpp"],
98    defaults: ["libnativebridge-test-case-defaults"],
99}
100
101cc_test {
102    name: "libnativebridge-tests",
103    defaults: [
104        "art_defaults",
105        "art_standalone_test_defaults",
106    ],
107
108    isolated: true,
109
110    srcs: [
111        "NativeBridgeTest.cpp",
112        "NativeBridgeApi.c",
113        "CodeCacheCreate_test.cpp",
114        "CodeCacheExists_test.cpp",
115        "CodeCacheStatFail_test.cpp",
116        "CompleteFlow_test.cpp",
117        "InvalidCharsNativeBridge_test.cpp",
118        "NativeBridge2Signal_test.cpp",
119        "NativeBridgeVersion_test.cpp",
120        "NeedsNativeBridge_test.cpp",
121        "PreInitializeNativeBridge_test.cpp",
122        "PreInitializeNativeBridgeFail2_test.cpp",
123        "ReSetupNativeBridge_test.cpp",
124        "UnavailableNativeBridge_test.cpp",
125        "ValidNameNativeBridge_test.cpp",
126        "NativeBridge3UnloadLibrary_test.cpp",
127        "NativeBridge3GetError_test.cpp",
128        "NativeBridge3IsPathSupported_test.cpp",
129        "NativeBridge3CreateNamespace_test.cpp",
130        "NativeBridge3LoadLibraryExt_test.cpp",
131        "NativeBridge6PreZygoteFork_test.cpp",
132        "NativeBridge7CriticalNative_test.cpp",
133    ],
134
135    static_libs: [
136        "libbase",
137        "libnativebridge",
138    ],
139    shared_libs: [
140        "liblog",
141        "libnativebridge6prezygotefork",
142        "libnativebridge7criticalnative",
143    ],
144    data_libs: [
145        "libnativebridge6prezygotefork",
146        "libnativebridge7criticalnative",
147
148        // These are dlopen'd by libnativebridge, not libnativebridge-tests, but
149        // the former is statically linked into the latter, so the linker will
150        // find them next to the test binary.
151        "libnativebridge-test-case",
152        "libnativebridge2-test-case",
153        "libnativebridge3-test-case",
154        "libnativebridge6-test-case",
155        "libnativebridge7-test-case",
156    ],
157
158    target: {
159        linux: {
160            cflags: [
161                // gtest issue
162                "-Wno-used-but-marked-unused",
163                "-Wno-deprecated",
164                "-Wno-missing-noreturn",
165            ],
166        },
167        android: {
168            shared_libs: ["libdl_android"], // libnativebridge dependency
169        },
170    },
171
172    test_suites: [
173        "general-tests",
174    ],
175}
176
177// Very basic tests in CTS/MCTS to verify backed-by API coverage of the exported
178// API in libnativebridge.map.txt.
179cc_test {
180    name: "art_libnativebridge_cts_tests",
181    defaults: ["art_standalone_test_defaults"],
182    shared_libs: ["libnativebridge"],
183    static_libs: ["libbase"],
184    srcs: ["libnativebridge_api_test.cpp"],
185    test_config_template: ":art-gtests-target-standalone-cts-template",
186    test_suites: [
187        "cts",
188        "general-tests",
189        "mts-art",
190        "mcts-art",
191    ],
192}
193
194cc_test {
195    name: "libnativebridge-lazy-tests",
196    defaults: ["art_standalone_test_defaults"],
197    static_libs: [
198        "libbase",
199    ],
200    shared_libs: ["libnativebridge_lazy"],
201    data_libs: ["libnativebridge_lazy"],
202    srcs: ["libnativebridge_api_test.cpp"],
203    test_suites: [
204        "general-tests",
205        "mts-art",
206    ],
207}
208