blob: a6477dd6a278c254f92da116f611e0ff6ec94a50 [file] [log] [blame]
Tao Bao0ba5c942018-08-14 22:20:22 -07001// Copyright 2018 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
Jaewoong Jung4b79e982020-06-01 10:45:49 -070015package etc
Tao Bao0ba5c942018-08-14 22:20:22 -070016
17import (
Kiyoung Kimae11c232021-07-19 11:38:04 +090018 "fmt"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070019 "os"
Patrice Arruda300cef92019-02-22 15:47:57 -080020 "path/filepath"
Tao Bao0ba5c942018-08-14 22:20:22 -070021 "testing"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070022
Kiyoung Kimae11c232021-07-19 11:38:04 +090023 "github.com/google/blueprint/proptools"
24
Jaewoong Jung4b79e982020-06-01 10:45:49 -070025 "android/soong/android"
Kiyoung Kimae11c232021-07-19 11:38:04 +090026 "android/soong/snapshot"
Tao Bao0ba5c942018-08-14 22:20:22 -070027)
28
Jaewoong Jung4b79e982020-06-01 10:45:49 -070029func TestMain(m *testing.M) {
Paul Duffin5f9f7712021-03-15 15:35:49 +000030 os.Exit(m.Run())
Jaewoong Jung4b79e982020-06-01 10:45:49 -070031}
32
Paul Duffin89648f92021-03-20 00:36:55 +000033var prepareForPrebuiltEtcTest = android.GroupFixturePreparers(
Paul Duffin1172fed2021-03-08 11:28:18 +000034 android.PrepareForTestWithArchMutator,
35 PrepareForTestWithPrebuiltEtc,
36 android.FixtureMergeMockFs(android.MockFS{
Colin Cross98be1bb2019-12-13 20:41:13 -080037 "foo.conf": nil,
38 "bar.conf": nil,
39 "baz.conf": nil,
Paul Duffin1172fed2021-03-08 11:28:18 +000040 }),
41)
Colin Cross98be1bb2019-12-13 20:41:13 -080042
Kiyoung Kimae11c232021-07-19 11:38:04 +090043var prepareForPrebuiltEtcSnapshotTest = android.GroupFixturePreparers(
44 prepareForPrebuiltEtcTest,
45 android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
46 snapshot.VendorSnapshotImageSingleton.Init(ctx)
47 snapshot.RecoverySnapshotImageSingleton.Init(ctx)
48 }),
49 android.FixtureModifyConfig(func(config android.Config) {
50 config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
51 config.TestProductVariables.RecoverySnapshotVersion = proptools.StringPtr("current")
52 }),
53)
54
Tao Bao0ba5c942018-08-14 22:20:22 -070055func TestPrebuiltEtcVariants(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +000056 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Tao Bao0ba5c942018-08-14 22:20:22 -070057 prebuilt_etc {
58 name: "foo.conf",
59 src: "foo.conf",
60 }
61 prebuilt_etc {
62 name: "bar.conf",
63 src: "bar.conf",
64 recovery_available: true,
65 }
66 prebuilt_etc {
67 name: "baz.conf",
68 src: "baz.conf",
69 recovery: true,
70 }
71 `)
72
Paul Duffin921fac72021-03-10 09:00:58 +000073 foo_variants := result.ModuleVariantsForTests("foo.conf")
Tao Bao0ba5c942018-08-14 22:20:22 -070074 if len(foo_variants) != 1 {
75 t.Errorf("expected 1, got %#v", foo_variants)
76 }
77
Paul Duffin921fac72021-03-10 09:00:58 +000078 bar_variants := result.ModuleVariantsForTests("bar.conf")
Tao Bao0ba5c942018-08-14 22:20:22 -070079 if len(bar_variants) != 2 {
80 t.Errorf("expected 2, got %#v", bar_variants)
81 }
82
Paul Duffin921fac72021-03-10 09:00:58 +000083 baz_variants := result.ModuleVariantsForTests("baz.conf")
Tao Bao0ba5c942018-08-14 22:20:22 -070084 if len(baz_variants) != 1 {
85 t.Errorf("expected 1, got %#v", bar_variants)
86 }
87}
Jiyong Park139a2e62018-10-26 21:49:39 +090088
89func TestPrebuiltEtcOutputPath(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +000090 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Jiyong Park139a2e62018-10-26 21:49:39 +090091 prebuilt_etc {
92 name: "foo.conf",
93 src: "foo.conf",
94 filename: "foo.installed.conf",
95 }
96 `)
97
Paul Duffin921fac72021-03-10 09:00:58 +000098 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffine84b1332021-03-12 11:59:43 +000099 android.AssertStringEquals(t, "output file path", "foo.installed.conf", p.outputFilePath.Base())
Jiyong Park139a2e62018-10-26 21:49:39 +0900100}
Jiyong Park1a7cf082018-11-13 11:59:12 +0900101
102func TestPrebuiltEtcGlob(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000103 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Jiyong Park1a7cf082018-11-13 11:59:12 +0900104 prebuilt_etc {
105 name: "my_foo",
106 src: "foo.*",
107 }
108 prebuilt_etc {
109 name: "my_bar",
110 src: "bar.*",
111 filename_from_src: true,
112 }
113 `)
114
Paul Duffin921fac72021-03-10 09:00:58 +0000115 p := result.Module("my_foo", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffine84b1332021-03-12 11:59:43 +0000116 android.AssertStringEquals(t, "my_foo output file path", "my_foo", p.outputFilePath.Base())
Jiyong Park1a7cf082018-11-13 11:59:12 +0900117
Paul Duffin921fac72021-03-10 09:00:58 +0000118 p = result.Module("my_bar", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffine84b1332021-03-12 11:59:43 +0000119 android.AssertStringEquals(t, "my_bar output file path", "bar.conf", p.outputFilePath.Base())
Jiyong Park1a7cf082018-11-13 11:59:12 +0900120}
Anton Hanssonce0e2582019-02-04 14:19:27 +0000121
122func TestPrebuiltEtcAndroidMk(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000123 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Anton Hanssonce0e2582019-02-04 14:19:27 +0000124 prebuilt_etc {
125 name: "foo",
126 src: "foo.conf",
127 owner: "abc",
128 filename_from_src: true,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700129 required: ["modA", "moduleB"],
130 host_required: ["hostModA", "hostModB"],
131 target_required: ["targetModA"],
Anton Hanssonce0e2582019-02-04 14:19:27 +0000132 }
133 `)
134
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700135 expected := map[string][]string{
136 "LOCAL_MODULE": {"foo"},
137 "LOCAL_MODULE_CLASS": {"ETC"},
138 "LOCAL_MODULE_OWNER": {"abc"},
139 "LOCAL_INSTALLED_MODULE_STEM": {"foo.conf"},
140 "LOCAL_REQUIRED_MODULES": {"modA", "moduleB"},
141 "LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"},
142 "LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
Anton Hanssonce0e2582019-02-04 14:19:27 +0000143 }
144
Paul Duffin921fac72021-03-10 09:00:58 +0000145 mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
146 entries := android.AndroidMkEntriesForTest(t, result.TestContext, mod)[0]
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700147 for k, expectedValue := range expected {
148 if value, ok := entries.EntryMap[k]; ok {
Paul Duffine84b1332021-03-12 11:59:43 +0000149 android.AssertDeepEquals(t, k, expectedValue, value)
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700150 } else {
151 t.Errorf("No %s defined, saw %q", k, entries.EntryMap)
Anton Hanssonce0e2582019-02-04 14:19:27 +0000152 }
153 }
154}
Jaewoong Jung24788182019-02-04 14:34:10 -0800155
Liz Kammer0449a632020-06-26 10:12:36 -0700156func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000157 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Liz Kammer0449a632020-06-26 10:12:36 -0700158 prebuilt_etc {
159 name: "foo.conf",
160 src: "foo.conf",
161 relative_install_path: "bar",
162 }
163 `)
164
Paul Duffin921fac72021-03-10 09:00:58 +0000165 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000166 expected := "out/soong/target/product/test_device/system/etc/bar"
167 android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
Liz Kammer0449a632020-06-26 10:12:36 -0700168}
169
170func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000171 prepareForPrebuiltEtcTest.
Paul Duffin1172fed2021-03-08 11:28:18 +0000172 ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("relative_install_path is set. Cannot set sub_dir")).
173 RunTestWithBp(t, `
174 prebuilt_etc {
175 name: "foo.conf",
176 src: "foo.conf",
177 sub_dir: "bar",
178 relative_install_path: "bar",
179 }
180 `)
Liz Kammer0449a632020-06-26 10:12:36 -0700181}
182
Jaewoong Jung24788182019-02-04 14:34:10 -0800183func TestPrebuiltEtcHost(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000184 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Jaewoong Jung24788182019-02-04 14:34:10 -0800185 prebuilt_etc_host {
186 name: "foo.conf",
187 src: "foo.conf",
188 }
189 `)
190
Colin Cross0c66bc62021-07-20 09:47:41 -0700191 buildOS := result.Config.BuildOS.String()
Paul Duffin921fac72021-03-10 09:00:58 +0000192 p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
Jaewoong Jung24788182019-02-04 14:34:10 -0800193 if !p.Host() {
194 t.Errorf("host bit is not set for a prebuilt_etc_host module.")
195 }
196}
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800197
Colin Cross725eac62022-10-03 15:31:29 -0700198func TestPrebuiltEtcAllowMissingDependencies(t *testing.T) {
199 result := android.GroupFixturePreparers(
200 prepareForPrebuiltEtcTest,
201 android.PrepareForTestDisallowNonExistentPaths,
202 android.FixtureModifyConfig(
203 func(config android.Config) {
204 config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
205 }),
206 ).RunTestWithBp(t, `
207 prebuilt_etc {
208 name: "foo.conf",
209 filename_from_src: true,
210 arch: {
211 x86: {
212 src: "x86.conf",
213 },
214 },
215 }
216 `)
217
218 android.AssertStringEquals(t, "expected error rule", "android/soong/android.Error",
219 result.ModuleForTests("foo.conf", "android_arm64_armv8-a").Output("foo.conf").Rule.String())
220}
221
Inseob Kim27408bf2021-04-06 21:00:17 +0900222func TestPrebuiltRootInstallDirPath(t *testing.T) {
223 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
224 prebuilt_root {
225 name: "foo.conf",
226 src: "foo.conf",
227 filename: "foo.conf",
228 }
229 `)
230
231 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
232 expected := "out/soong/target/product/test_device/system"
233 android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
234}
235
236func TestPrebuiltRootInstallDirPathValidate(t *testing.T) {
237 prepareForPrebuiltEtcTest.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("filename cannot contain separator")).RunTestWithBp(t, `
238 prebuilt_root {
239 name: "foo.conf",
240 src: "foo.conf",
241 filename: "foo/bar.conf",
242 }
243 `)
244}
245
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800246func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000247 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800248 prebuilt_usr_share {
249 name: "foo.conf",
250 src: "foo.conf",
251 sub_dir: "bar",
252 }
253 `)
254
Paul Duffin921fac72021-03-10 09:00:58 +0000255 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000256 expected := "out/soong/target/product/test_device/system/usr/share/bar"
257 android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800258}
Patrice Arruda300cef92019-02-22 15:47:57 -0800259
260func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000261 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Patrice Arruda300cef92019-02-22 15:47:57 -0800262 prebuilt_usr_share_host {
263 name: "foo.conf",
264 src: "foo.conf",
265 sub_dir: "bar",
266 }
267 `)
268
Colin Cross0c66bc62021-07-20 09:47:41 -0700269 buildOS := result.Config.BuildOS.String()
Paul Duffin921fac72021-03-10 09:00:58 +0000270 p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000271 expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
272 android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
Patrice Arruda300cef92019-02-22 15:47:57 -0800273}
Patrice Arruda61583eb2019-05-14 08:20:45 -0700274
275func TestPrebuiltFontInstallDirPath(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000276 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
Patrice Arruda61583eb2019-05-14 08:20:45 -0700277 prebuilt_font {
278 name: "foo.conf",
279 src: "foo.conf",
280 }
281 `)
282
Paul Duffin921fac72021-03-10 09:00:58 +0000283 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000284 expected := "out/soong/target/product/test_device/system/fonts"
285 android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700286}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700287
288func TestPrebuiltFirmwareDirPath(t *testing.T) {
Paul Duffin5f9f7712021-03-15 15:35:49 +0000289 targetPath := "out/soong/target/product/test_device"
Patrice Arruda057a8b12019-06-03 15:29:27 -0700290 tests := []struct {
291 description string
292 config string
293 expectedPath string
294 }{{
295 description: "prebuilt: system firmware",
296 config: `
297 prebuilt_firmware {
298 name: "foo.conf",
299 src: "foo.conf",
300 }`,
301 expectedPath: filepath.Join(targetPath, "system/etc/firmware"),
302 }, {
303 description: "prebuilt: vendor firmware",
304 config: `
305 prebuilt_firmware {
306 name: "foo.conf",
307 src: "foo.conf",
308 soc_specific: true,
309 sub_dir: "sub_dir",
310 }`,
311 expectedPath: filepath.Join(targetPath, "vendor/firmware/sub_dir"),
312 }}
313 for _, tt := range tests {
314 t.Run(tt.description, func(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000315 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
Paul Duffin921fac72021-03-10 09:00:58 +0000316 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000317 android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700318 })
319 }
320}
Patrice Arruda0f688002020-06-08 21:40:25 +0000321
322func TestPrebuiltDSPDirPath(t *testing.T) {
Paul Duffin5f9f7712021-03-15 15:35:49 +0000323 targetPath := "out/soong/target/product/test_device"
Patrice Arruda0f688002020-06-08 21:40:25 +0000324 tests := []struct {
325 description string
326 config string
327 expectedPath string
328 }{{
329 description: "prebuilt: system dsp",
330 config: `
331 prebuilt_dsp {
332 name: "foo.conf",
333 src: "foo.conf",
334 }`,
335 expectedPath: filepath.Join(targetPath, "system/etc/dsp"),
336 }, {
337 description: "prebuilt: vendor dsp",
338 config: `
339 prebuilt_dsp {
340 name: "foo.conf",
341 src: "foo.conf",
342 soc_specific: true,
343 sub_dir: "sub_dir",
344 }`,
345 expectedPath: filepath.Join(targetPath, "vendor/dsp/sub_dir"),
346 }}
347 for _, tt := range tests {
348 t.Run(tt.description, func(t *testing.T) {
Paul Duffin89648f92021-03-20 00:36:55 +0000349 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
Paul Duffin921fac72021-03-10 09:00:58 +0000350 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
Paul Duffin5f9f7712021-03-15 15:35:49 +0000351 android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
Patrice Arruda0f688002020-06-08 21:40:25 +0000352 })
353 }
354}
Colin Cross83ebf232021-04-09 09:41:23 -0700355
356func TestPrebuiltRFSADirPath(t *testing.T) {
357 targetPath := "out/soong/target/product/test_device"
358 tests := []struct {
359 description string
360 config string
361 expectedPath string
362 }{{
363 description: "prebuilt: system rfsa",
364 config: `
365 prebuilt_rfsa {
366 name: "foo.conf",
367 src: "foo.conf",
368 }`,
369 expectedPath: filepath.Join(targetPath, "system/lib/rfsa"),
370 }, {
371 description: "prebuilt: vendor rfsa",
372 config: `
373 prebuilt_rfsa {
374 name: "foo.conf",
375 src: "foo.conf",
376 soc_specific: true,
377 sub_dir: "sub_dir",
378 }`,
379 expectedPath: filepath.Join(targetPath, "vendor/lib/rfsa/sub_dir"),
380 }}
381 for _, tt := range tests {
382 t.Run(tt.description, func(t *testing.T) {
383 result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
384 p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
385 android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
386 })
387 }
388}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900389
390func checkIfSnapshotTaken(t *testing.T, result *android.TestResult, image string, moduleName string) {
391 checkIfSnapshotExistAsExpected(t, result, image, moduleName, true)
392}
393
394func checkIfSnapshotNotTaken(t *testing.T, result *android.TestResult, image string, moduleName string) {
395 checkIfSnapshotExistAsExpected(t, result, image, moduleName, false)
396}
397
398func checkIfSnapshotExistAsExpected(t *testing.T, result *android.TestResult, image string, moduleName string, expectToExist bool) {
399 snapshotSingleton := result.SingletonForTests(image + "-snapshot")
400 archType := "arm64"
401 archVariant := "armv8-a"
402 archDir := fmt.Sprintf("arch-%s", archType)
403
404 snapshotDir := fmt.Sprintf("%s-snapshot", image)
405 snapshotVariantPath := filepath.Join(snapshotDir, archType)
406 outputDir := filepath.Join(snapshotVariantPath, archDir, "etc")
407 imageVariant := ""
408 if image == "recovery" {
409 imageVariant = "recovery_"
410 }
411 mod := result.ModuleForTests(moduleName, fmt.Sprintf("android_%s%s_%s", imageVariant, archType, archVariant))
412 outputFiles := mod.OutputFiles(t, "")
413 if len(outputFiles) != 1 {
414 t.Errorf("%q must have single output\n", moduleName)
415 return
416 }
417 snapshotPath := filepath.Join(outputDir, moduleName)
418
419 if expectToExist {
420 out := snapshotSingleton.Output(snapshotPath)
421
422 if out.Input.String() != outputFiles[0].String() {
423 t.Errorf("The input of snapshot %q must be %q, but %q", "prebuilt_vendor", out.Input.String(), outputFiles[0])
424 }
425
426 snapshotJsonPath := snapshotPath + ".json"
427
428 if snapshotSingleton.MaybeOutput(snapshotJsonPath).Rule == nil {
429 t.Errorf("%q expected but not found", snapshotJsonPath)
430 }
431 } else {
432 out := snapshotSingleton.MaybeOutput(snapshotPath)
433 if out.Rule != nil {
434 t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
435 }
436 }
437}
438
439func TestPrebuiltTakeSnapshot(t *testing.T) {
440 var testBp = `
441 prebuilt_etc {
442 name: "prebuilt_vendor",
443 src: "foo.conf",
444 vendor: true,
445 }
446
447 prebuilt_etc {
448 name: "prebuilt_vendor_indirect",
449 src: "foo.conf",
450 vendor: true,
451 }
452
453 prebuilt_etc {
454 name: "prebuilt_recovery",
455 src: "bar.conf",
456 recovery: true,
457 }
458
459 prebuilt_etc {
460 name: "prebuilt_recovery_indirect",
461 src: "bar.conf",
462 recovery: true,
463 }
464 `
465
466 t.Run("prebuilt: vendor and recovery snapshot", func(t *testing.T) {
467 result := prepareForPrebuiltEtcSnapshotTest.RunTestWithBp(t, testBp)
468
469 checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor")
470 checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor_indirect")
471 checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery")
472 checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery_indirect")
473 })
474
475 t.Run("prebuilt: directed snapshot", func(t *testing.T) {
476 prepareForPrebuiltEtcDirectedSnapshotTest := android.GroupFixturePreparers(
477 prepareForPrebuiltEtcSnapshotTest,
478 android.FixtureModifyConfig(func(config android.Config) {
479 config.TestProductVariables.DirectedVendorSnapshot = true
480 config.TestProductVariables.VendorSnapshotModules = make(map[string]bool)
481 config.TestProductVariables.VendorSnapshotModules["prebuilt_vendor"] = true
482 config.TestProductVariables.DirectedRecoverySnapshot = true
483 config.TestProductVariables.RecoverySnapshotModules = make(map[string]bool)
484 config.TestProductVariables.RecoverySnapshotModules["prebuilt_recovery"] = true
485 }),
486 )
487
488 result := prepareForPrebuiltEtcDirectedSnapshotTest.RunTestWithBp(t, testBp)
489
490 checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor")
491 checkIfSnapshotNotTaken(t, result, "vendor", "prebuilt_vendor_indirect")
492 checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery")
493 checkIfSnapshotNotTaken(t, result, "recovery", "prebuilt_recovery_indirect")
494 })
495}