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_test_internal_library_defaults",
106    ],
107
108    target: {
109        linux: {
110            cflags: [
111                // gtest issue
112                "-Wno-used-but-marked-unused",
113                "-Wno-deprecated",
114                "-Wno-missing-noreturn",
115            ],
116        },
117    },
118
119    isolated: true,
120
121    srcs: [
122        "NativeBridgeTest.cpp",
123        "NativeBridgeApi.c",
124        "CodeCacheCreate_test.cpp",
125        "CodeCacheExists_test.cpp",
126        "CodeCacheStatFail_test.cpp",
127        "CompleteFlow_test.cpp",
128        "InvalidCharsNativeBridge_test.cpp",
129        "NativeBridge2Signal_test.cpp",
130        "NativeBridgeVersion_test.cpp",
131        "NeedsNativeBridge_test.cpp",
132        "PreInitializeNativeBridge_test.cpp",
133        "PreInitializeNativeBridgeFail2_test.cpp",
134        "ReSetupNativeBridge_test.cpp",
135        "UnavailableNativeBridge_test.cpp",
136        "ValidNameNativeBridge_test.cpp",
137        "NativeBridge3UnloadLibrary_test.cpp",
138        "NativeBridge3GetError_test.cpp",
139        "NativeBridge3IsPathSupported_test.cpp",
140        "NativeBridge3InitAnonymousNamespace_test.cpp",
141        "NativeBridge3CreateNamespace_test.cpp",
142        "NativeBridge3LoadLibraryExt_test.cpp",
143        "NativeBridge6PreZygoteFork_test.cpp",
144        "NativeBridge7CriticalNative_test.cpp",
145    ],
146
147    shared_libs: [
148        "libbase",
149        "liblog",
150        "libnativebridge",
151        "libnativebridge6prezygotefork",
152        "libnativebridge7criticalnative",
153
154        // Ideally these would only need to be listed in data_libs, but they
155        // are dlopen'd by libnativebridge, not by libnativebridge-tests,
156        // and the linker can't find them relative to /system/lib64/libnativebridge.so.
157        // Linking them here causes them to be loaded from alongside
158        // libnativebridge-tests when it is executed, and then the later dlopen
159        // returns the handle to the already-loaded library.
160        "libnativebridge-test-case",
161        "libnativebridge2-test-case",
162        "libnativebridge3-test-case",
163        "libnativebridge6-test-case",
164        "libnativebridge7-test-case",
165    ],
166    data_libs: [
167        "libnativebridge-test-case",
168        "libnativebridge2-test-case",
169        "libnativebridge3-test-case",
170        "libnativebridge6-test-case",
171        "libnativebridge7-test-case",
172        "libnativebridge6prezygotefork",
173        "libnativebridge7criticalnative",
174    ],
175
176    test_suites: [
177        "general-tests",
178    ],
179}
180
181// Very basic tests in CTS to verify backed-by API coverage of the exported API
182// in libnativebridge.map.txt.
183cc_test {
184    name: "art_libnativebridge_cts_tests",
185    defaults: ["art_standalone_test_defaults"],
186    shared_libs: ["libnativebridge"],
187    static_libs: ["libbase"],
188    srcs: ["libnativebridge_api_test.cpp"],
189    test_config_template: ":art-gtests-target-standalone-cts-template",
190    test_suites: [
191        "cts",
192        "general-tests",
193        "mts-art",
194        "mcts-art",
195    ],
196}
197
198cc_test {
199    name: "libnativebridge-lazy-tests",
200    defaults: ["art_standalone_test_defaults"],
201    static_libs: [
202        "libbase",
203        "libnativebridge_lazy",
204    ],
205    srcs: ["libnativebridge_api_test.cpp"],
206    test_suites: [
207        "general-tests",
208        "mts-art",
209    ],
210}
211