blob: 4bea396d1debed2fe0bd8a09c76758de2f23be88 [file] [log] [blame]
Jason Wu6d8d44a2023-08-08 22:09:12 -04001// Copyright 2023 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package bp2build
16
17import (
18 "testing"
19
20 "android/soong/android"
21 "android/soong/sh"
22)
23
24func TestShTestSimple(t *testing.T) {
Jason Wu25c69ee2023-08-24 15:40:10 -040025 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
26 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
27 }, Bp2buildTestCase{
28 Description: "sh_test test",
29 ModuleTypeUnderTest: "sh_test",
30 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
31 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
Jason Wu6d8d44a2023-08-08 22:09:12 -040032 ModuleTypeUnderTestFactory: sh.ShTestFactory,
Jason Wu25c69ee2023-08-24 15:40:10 -040033 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
34 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
35 simpleModule("filegroup", "libc++") +
36 simpleModule("filegroup", "libcrypto") + `sh_test{
Jason Wu6d8d44a2023-08-08 22:09:12 -040037 name: "sts-rootcanal-sidebins",
38 src: "empty.sh",
39 test_suites: [
40 "sts",
41 "sts-lite",
42 ],
43 data_bins: [
44 "android.hardware.bluetooth@1.1-service.sim",
45 "android.hardware.bluetooth@1.1-impl-sim"
46 ],
47 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
48 data_libs: ["libc++","libcrypto"],
49 test_config: "art-gtests-target-install-apex.xml",
50 test_config_template: ":art-run-test-target-template",
51 auto_gen_config: false,
52 test_options:{tags: ["no-remote"],
53 },
54}`,
55 ExpectedBazelTargets: []string{
56 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
Jason Wu25c69ee2023-08-24 15:40:10 -040057 "srcs": `["empty.sh"]`,
58 "runs_on": `["device"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -040059 "data": `[
60 "android.hardware.bluetooth@1.1-service.sim.rc",
Jason Wu25c69ee2023-08-24 15:40:10 -040061 ":android.hardware.bluetooth@1.1-service.sim",
62 ":android.hardware.bluetooth@1.1-impl-sim",
63 ":libc++",
64 ":libcrypto",
Jason Wu6d8d44a2023-08-08 22:09:12 -040065 ]`,
Jason Wu25c69ee2023-08-24 15:40:10 -040066 "data_bins": `[
67 ":android.hardware.bluetooth@1.1-service.sim",
68 ":android.hardware.bluetooth@1.1-impl-sim",
69 ]`,
70 "tags": `["no-remote"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -040071 })},
72 })
73}
74
75func TestShTestHostSimple(t *testing.T) {
Jason Wu25c69ee2023-08-24 15:40:10 -040076 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
77 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
78 }, Bp2buildTestCase{
79 Description: "sh_test_host test",
80 ModuleTypeUnderTest: "sh_test_host",
81 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
82 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
Jason Wu6d8d44a2023-08-08 22:09:12 -040083 ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
Jason Wu25c69ee2023-08-24 15:40:10 -040084 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
85 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
86 simpleModule("filegroup", "libc++") +
87 simpleModule("filegroup", "libcrypto") + `sh_test_host{
Jason Wu6d8d44a2023-08-08 22:09:12 -040088 name: "sts-rootcanal-sidebins",
89 src: "empty.sh",
90 test_suites: [
91 "sts",
92 "sts-lite",
93 ],
94 data_bins: [
95 "android.hardware.bluetooth@1.1-service.sim",
96 "android.hardware.bluetooth@1.1-impl-sim"
97 ],
98 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
99 data_libs: ["libc++","libcrypto"],
100 test_config: "art-gtests-target-install-apex.xml",
101 test_config_template: ":art-run-test-target-template",
102 auto_gen_config: false,
103 test_options:{tags: ["no-remote"],
104 },
105}`,
106 ExpectedBazelTargets: []string{
107 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
Jason Wu25c69ee2023-08-24 15:40:10 -0400108 "srcs": `["empty.sh"]`,
109 "runs_on": `["host_without_device"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -0400110 "data": `[
111 "android.hardware.bluetooth@1.1-service.sim.rc",
Jason Wu25c69ee2023-08-24 15:40:10 -0400112 ":android.hardware.bluetooth@1.1-service.sim",
113 ":android.hardware.bluetooth@1.1-impl-sim",
114 ":libc++",
115 ":libcrypto",
Jason Wu6d8d44a2023-08-08 22:09:12 -0400116 ]`,
Jason Wu25c69ee2023-08-24 15:40:10 -0400117 "data_bins": `[
118 ":android.hardware.bluetooth@1.1-service.sim",
119 ":android.hardware.bluetooth@1.1-impl-sim",
120 ]`,
121 "tags": `["no-remote"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -0400122 "target_compatible_with": `select({
Jingwen Chen9c2e3ee2023-10-11 10:51:28 +0000123 "//build/bazel_common_rules/platforms/os:android": ["@platforms//:incompatible"],
Jason Wu6d8d44a2023-08-08 22:09:12 -0400124 "//conditions:default": [],
125 })`,
126 })},
127 })
128}
129
Jason Wu25c69ee2023-08-24 15:40:10 -0400130func TestShTestAutogen(t *testing.T) {
131 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
132 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
133 }, Bp2buildTestCase{
134 Description: "sh_test test",
135 ModuleTypeUnderTest: "sh_test",
136 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
137 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"},
Jason Wu6d8d44a2023-08-08 22:09:12 -0400138 ModuleTypeUnderTestFactory: sh.ShTestFactory,
Jason Wu25c69ee2023-08-24 15:40:10 -0400139 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
140 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
141 simpleModule("filegroup", "libc++") +
142 simpleModule("filegroup", "libcrypto") +
143 simpleModule("filegroup", "art-run-test-target-template") + `sh_test{
144 name: "sts-rootcanal-sidebins",
145 src: "empty.sh",
146 test_suites: [
147 "sts",
148 "sts-lite",
149 ],
150 data_bins: [
151 "android.hardware.bluetooth@1.1-service.sim",
152 "android.hardware.bluetooth@1.1-impl-sim"
153 ],
154 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
155 data_libs: ["libc++","libcrypto"],
156 test_config: "art-gtests-target-install-apex.xml",
157 test_config_template: ":art-run-test-target-template",
158 auto_gen_config: true,
159 test_options:{tags: ["no-remote"],
160 },
161}`,
162 ExpectedBazelTargets: []string{
163 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
164 "srcs": `["empty.sh"]`,
165 "runs_on": `["device"]`,
166 "auto_generate_test_config": "True",
Jingwen Chen9c2e3ee2023-10-11 10:51:28 +0000167 "target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
Jason Wu25c69ee2023-08-24 15:40:10 -0400168 "template_test_config": `":art-run-test-target-template"`,
169 "data": `[
170 "android.hardware.bluetooth@1.1-service.sim.rc",
171 ":android.hardware.bluetooth@1.1-service.sim",
172 ":android.hardware.bluetooth@1.1-impl-sim",
173 ":libc++",
174 ":libcrypto",
175 ]`,
176 "data_bins": `[
177 ":android.hardware.bluetooth@1.1-service.sim",
178 ":android.hardware.bluetooth@1.1-impl-sim",
179 ]`,
180 "tags": `["no-remote"]`,
181 })},
182 })
183}
184
185func TestShTestHostAutogen(t *testing.T) {
186 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
187 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
188 }, Bp2buildTestCase{
189 Description: "sh_test_host test",
190 ModuleTypeUnderTest: "sh_test_host",
191 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
192 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"},
193 ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
194 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
195 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
196 simpleModule("filegroup", "libc++") +
197 simpleModule("filegroup", "libcrypto") +
198 simpleModule("filegroup", "art-run-test-target-template") + `sh_test_host{
199 name: "sts-rootcanal-sidebins",
200 src: "empty.sh",
201 test_suites: [
202 "sts",
203 "sts-lite",
204 ],
205 data_bins: [
206 "android.hardware.bluetooth@1.1-service.sim",
207 "android.hardware.bluetooth@1.1-impl-sim"
208 ],
209 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
210 data_libs: ["libc++","libcrypto"],
211 test_config: "art-gtests-target-install-apex.xml",
212 test_config_template: ":art-run-test-target-template",
213 auto_gen_config: true,
214 test_options:{tags: ["no-remote"],
215 },
216}`,
217 ExpectedBazelTargets: []string{
218 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
219 "srcs": `["empty.sh"]`,
220 "runs_on": `["host_without_device"]`,
221 "auto_generate_test_config": "True",
222 "target_compatible_with": `select({
Jingwen Chen9c2e3ee2023-10-11 10:51:28 +0000223 "//build/bazel_common_rules/platforms/os:android": ["@platforms//:incompatible"],
Jason Wu25c69ee2023-08-24 15:40:10 -0400224 "//conditions:default": [],
225 })`,
226 "template_test_config": `":art-run-test-target-template"`,
227 "data": `[
228 "android.hardware.bluetooth@1.1-service.sim.rc",
229 ":android.hardware.bluetooth@1.1-service.sim",
230 ":android.hardware.bluetooth@1.1-impl-sim",
231 ":libc++",
232 ":libcrypto",
233 ]`,
234 "data_bins": `[
235 ":android.hardware.bluetooth@1.1-service.sim",
236 ":android.hardware.bluetooth@1.1-impl-sim",
237 ]`,
238 "tags": `["no-remote"]`,
239 })},
240 })
241}
242func TestShTestSimpleUnset(t *testing.T) {
243 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
244 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
245 }, Bp2buildTestCase{
246 Description: "sh_test test",
247 ModuleTypeUnderTest: "sh_test",
248 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
249 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
250 ModuleTypeUnderTestFactory: sh.ShTestFactory,
251 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
252 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
253 simpleModule("filegroup", "libc++") +
254 simpleModule("filegroup", "libcrypto") + `sh_test{
Jason Wu6d8d44a2023-08-08 22:09:12 -0400255 name: "sts-rootcanal-sidebins",
256 src: "empty.sh",
257 test_suites: [
258 "sts",
259 "sts-lite",
260 ],
261 data_bins: [
262 "android.hardware.bluetooth@1.1-service.sim",
263 "android.hardware.bluetooth@1.1-impl-sim"
264 ],
265 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
266 data_libs: ["libc++","libcrypto"],
267 test_options:{tags: ["no-remote"],
268 },
269}`,
270 ExpectedBazelTargets: []string{
271 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
Jason Wu25c69ee2023-08-24 15:40:10 -0400272 "srcs": `["empty.sh"]`,
273 "runs_on": `["device"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -0400274 "data": `[
275 "android.hardware.bluetooth@1.1-service.sim.rc",
Jason Wu25c69ee2023-08-24 15:40:10 -0400276 ":android.hardware.bluetooth@1.1-service.sim",
277 ":android.hardware.bluetooth@1.1-impl-sim",
278 ":libc++",
279 ":libcrypto",
280 ]`,
281 "data_bins": `[
282 ":android.hardware.bluetooth@1.1-service.sim",
283 ":android.hardware.bluetooth@1.1-impl-sim",
Jason Wu6d8d44a2023-08-08 22:09:12 -0400284 ]`,
285 "tags": `["no-remote"]`,
286 })},
287 })
288}
289
290func TestShTestHostSimpleUnset(t *testing.T) {
Jason Wu25c69ee2023-08-24 15:40:10 -0400291 RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
292 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
293 }, Bp2buildTestCase{
Jason Wu6d8d44a2023-08-08 22:09:12 -0400294 Description: "sh_test_host test",
295 ModuleTypeUnderTest: "sh_test_host",
296 ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
Jason Wu25c69ee2023-08-24 15:40:10 -0400297 StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
298 "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
299 Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
300 simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
301 simpleModule("filegroup", "libc++") +
302 simpleModule("filegroup", "libcrypto") + `sh_test_host{
Jason Wu6d8d44a2023-08-08 22:09:12 -0400303 name: "sts-rootcanal-sidebins",
304 src: "empty.sh",
305 test_suites: [
306 "sts",
307 "sts-lite",
308 ],
309 data_bins: [
310 "android.hardware.bluetooth@1.1-service.sim",
311 "android.hardware.bluetooth@1.1-impl-sim"
312 ],
313 data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
314 data_libs: ["libc++","libcrypto"],
315 test_options:{tags: ["no-remote"],
316 },
317}`,
318 ExpectedBazelTargets: []string{
319 MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
Jason Wu25c69ee2023-08-24 15:40:10 -0400320 "srcs": `["empty.sh"]`,
321 "runs_on": `["host_without_device"]`,
Jason Wu6d8d44a2023-08-08 22:09:12 -0400322 "data": `[
323 "android.hardware.bluetooth@1.1-service.sim.rc",
Jason Wu25c69ee2023-08-24 15:40:10 -0400324 ":android.hardware.bluetooth@1.1-service.sim",
325 ":android.hardware.bluetooth@1.1-impl-sim",
326 ":libc++",
327 ":libcrypto",
328 ]`,
329 "data_bins": `[
330 ":android.hardware.bluetooth@1.1-service.sim",
331 ":android.hardware.bluetooth@1.1-impl-sim",
Jason Wu6d8d44a2023-08-08 22:09:12 -0400332 ]`,
333 "tags": `["no-remote"]`,
334 "target_compatible_with": `select({
Jingwen Chen9c2e3ee2023-10-11 10:51:28 +0000335 "//build/bazel_common_rules/platforms/os:android": ["@platforms//:incompatible"],
Jason Wu6d8d44a2023-08-08 22:09:12 -0400336 "//conditions:default": [],
337 })`,
338 })},
339 })
340}