summaryrefslogtreecommitdiff
path: root/fsgen/filesystem_creator_test.go
blob: 2c4d3c817e506b122455e58bdf8f9ebfdd006181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
// Copyright 2024 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package fsgen

import (
	"strings"
	"testing"

	"android/soong/android"
	"android/soong/etc"
	"android/soong/filesystem"
	"android/soong/java"

	"github.com/google/blueprint/proptools"
)

var prepareForTestWithFsgenBuildComponents = android.FixtureRegisterWithContext(registerBuildComponents)

var prepareMockRamdiksNodeList = android.FixtureMergeMockFs(android.MockFS{
	"ramdisk_node_list/ramdisk_node_list": nil,
	"ramdisk_node_list/Android.bp": []byte(`
		filegroup {
			name: "ramdisk_node_list",
			srcs: ["ramdisk_node_list"],
		}
	`),
})

func TestFileSystemCreatorSystemImageProps(t *testing.T) {
	result := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.PrepareForTestWithAndroidBuildComponents,
		android.PrepareForTestWithAllowMissingDependencies,
		filesystem.PrepareForTestWithFilesystemBuildComponents,
		prepareForTestWithFsgenBuildComponents,
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.BoardAvbEnable = true
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
				map[string]android.PartitionQualifiedVariablesType{
					"system": {
						BoardAvbKeyPath:       "external/avb/test/data/testkey_rsa4096.pem",
						BoardAvbAlgorithm:     "SHA256_RSA4096",
						BoardAvbRollbackIndex: "0",
						BoardFileSystemType:   "ext4",
					},
				}
		}),
		prepareMockRamdiksNodeList,
		android.FixtureMergeMockFs(android.MockFS{
			"external/avb/test/data/testkey_rsa4096.pem": nil,
			"external/avb/test/Android.bp": []byte(`
			filegroup {
				name: "avb_testkey_rsa4096",
				srcs: ["data/testkey_rsa4096.pem"],
			}
			`),
			"build/soong/fsgen/Android.bp": []byte(`
			soong_filesystem_creator {
				name: "foo",
			}
			`),
		}),
	).RunTest(t)

	fooSystem := result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().(interface {
		FsProps() filesystem.FilesystemProperties
	})
	android.AssertBoolEquals(
		t,
		"Property expected to match the product variable 'BOARD_AVB_ENABLE'",
		true,
		proptools.Bool(fooSystem.FsProps().Use_avb),
	)
	android.AssertStringEquals(
		t,
		"Property the avb_private_key property to be set to the existing filegroup",
		":avb_testkey_rsa4096",
		proptools.String(fooSystem.FsProps().Avb_private_key),
	)
	android.AssertStringEquals(
		t,
		"Property expected to match the product variable 'BOARD_AVB_ALGORITHM'",
		"SHA256_RSA4096",
		proptools.String(fooSystem.FsProps().Avb_algorithm),
	)
	android.AssertIntEquals(
		t,
		"Property expected to match the product variable 'BOARD_AVB_SYSTEM_ROLLBACK_INDEX'",
		0,
		proptools.Int(fooSystem.FsProps().Rollback_index),
	)
	android.AssertStringEquals(
		t,
		"Property expected to match the product variable 'BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE'",
		"ext4",
		proptools.String(fooSystem.FsProps().Type),
	)
}

func TestFileSystemCreatorSetPartitionDeps(t *testing.T) {
	result := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.PrepareForTestWithAndroidBuildComponents,
		android.PrepareForTestWithAllowMissingDependencies,
		filesystem.PrepareForTestWithFilesystemBuildComponents,
		prepareForTestWithFsgenBuildComponents,
		java.PrepareForTestWithJavaBuildComponents,
		java.PrepareForTestWithJavaDefaultModules,
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"bar", "baz"}
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
				map[string]android.PartitionQualifiedVariablesType{
					"system": {
						BoardFileSystemType: "ext4",
					},
				}
		}),
		prepareMockRamdiksNodeList,
		android.FixtureMergeMockFs(android.MockFS{
			"external/avb/test/data/testkey_rsa4096.pem": nil,
			"build/soong/fsgen/Android.bp": []byte(`
			soong_filesystem_creator {
				name: "foo",
			}
			`),
		}),
	).RunTestWithBp(t, `
	java_library {
		name: "bar",
		srcs: ["A.java"],
	}
	java_library {
		name: "baz",
		srcs: ["A.java"],
		product_specific: true,
	}
	`)

	android.AssertBoolEquals(
		t,
		"Generated system image expected to depend on system partition installed \"bar\"",
		true,
		java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "bar"),
	)
	android.AssertBoolEquals(
		t,
		"Generated system image expected to not depend on product partition installed \"baz\"",
		false,
		java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "baz"),
	)
}

func TestFileSystemCreatorDepsWithNamespace(t *testing.T) {
	result := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.PrepareForTestWithAndroidBuildComponents,
		android.PrepareForTestWithAllowMissingDependencies,
		android.PrepareForTestWithNamespace,
		android.PrepareForTestWithArchMutator,
		filesystem.PrepareForTestWithFilesystemBuildComponents,
		prepareForTestWithFsgenBuildComponents,
		java.PrepareForTestWithJavaBuildComponents,
		java.PrepareForTestWithJavaDefaultModules,
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"bar"}
			config.TestProductVariables.NamespacesToExport = []string{"a/b"}
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
				map[string]android.PartitionQualifiedVariablesType{
					"system": {
						BoardFileSystemType: "ext4",
					},
				}
		}),
		android.PrepareForNativeBridgeEnabled,
		prepareMockRamdiksNodeList,
		android.FixtureMergeMockFs(android.MockFS{
			"external/avb/test/data/testkey_rsa4096.pem": nil,
			"build/soong/fsgen/Android.bp": []byte(`
			soong_filesystem_creator {
				name: "foo",
			}
			`),
			"a/b/Android.bp": []byte(`
			soong_namespace{
			}
			java_library {
				name: "bar",
				srcs: ["A.java"],
				compile_multilib: "64",
			}
			`),
			"c/d/Android.bp": []byte(`
			soong_namespace{
			}
			java_library {
				name: "bar",
				srcs: ["A.java"],
			}
			`),
		}),
	).RunTest(t)

	var packagingProps android.PackagingProperties
	for _, prop := range result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().GetProperties() {
		if packagingPropStruct, ok := prop.(*android.PackagingProperties); ok {
			packagingProps = *packagingPropStruct
		}
	}
	moduleDeps := packagingProps.Multilib.Lib64.Deps

	eval := result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringListContains(
		t,
		"Generated system image expected to depend on \"bar\" defined in \"a/b\" namespace",
		moduleDeps.GetOrDefault(eval, nil),
		"//a/b:bar",
	)
	android.AssertStringListDoesNotContain(
		t,
		"Generated system image expected to not depend on \"bar\" defined in \"c/d\" namespace",
		moduleDeps.GetOrDefault(eval, nil),
		"//c/d:bar",
	)
}

func TestRemoveOverriddenModulesFromDeps(t *testing.T) {
	result := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.PrepareForTestWithAndroidBuildComponents,
		android.PrepareForTestWithAllowMissingDependencies,
		prepareForTestWithFsgenBuildComponents,
		java.PrepareForTestWithJavaBuildComponents,
		prepareMockRamdiksNodeList,
		android.FixtureMergeMockFs(android.MockFS{
			"external/avb/test/data/testkey_rsa4096.pem": nil,
			"build/soong/fsgen/Android.bp": []byte(`
			soong_filesystem_creator {
				name: "foo",
			}
			`),
		}),
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"libfoo", "libbar"}
		}),
	).RunTestWithBp(t, `
java_library {
	name: "libfoo",
}
java_library {
	name: "libbar",
	required: ["libbaz"],
}
java_library {
	name: "libbaz",
	overrides: ["libfoo"], // overrides libfoo
}
	`)
	resolvedSystemDeps := result.TestContext.Config().Get(fsGenStateOnceKey).(*FsGenState).fsDeps["system"]
	_, libFooInDeps := (*resolvedSystemDeps)["libfoo"]
	android.AssertBoolEquals(t, "libfoo should not appear in deps because it has been overridden by libbaz. The latter is a required dep of libbar, which is listed in PRODUCT_PACKAGES", false, libFooInDeps)
}

func TestPrebuiltEtcModuleGen(t *testing.T) {
	result := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.PrepareForTestWithAndroidBuildComponents,
		android.PrepareForTestWithAllowMissingDependencies,
		filesystem.PrepareForTestWithFilesystemBuildComponents,
		prepareForTestWithFsgenBuildComponents,
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductCopyFiles = []string{
				"frameworks/base/config/preloaded-classes:system/etc/preloaded-classes",
				"frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl:system/usr/keylayout/subdir/Vendor_0079_Product_0011.kl",
				"frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl:system/usr/keylayout/subdir/Vendor_0079_Product_18d4.kl",
				"some/non/existing/file.txt:system/etc/file.txt",
				"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf.xml:google",
				"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml",
				"device/sample/etc/apns-full-conf.xml:system/foo/file.txt",
				"device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml",
				"device/sample/firmware/firmware.bin:recovery/root/firmware.bin",
				"device/sample/firmware/firmware.bin:recovery/root/firmware-2.bin",
				"device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware.bin",
				"device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware-2.bin",
			}
			config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
				map[string]android.PartitionQualifiedVariablesType{
					"system": {
						BoardFileSystemType: "ext4",
					},
				}
		}),
		prepareMockRamdiksNodeList,
		android.FixtureMergeMockFs(android.MockFS{
			"external/avb/test/data/testkey_rsa4096.pem": nil,
			"build/soong/fsgen/Android.bp": []byte(`
			soong_filesystem_creator {
				name: "foo",
			}
			`),
			"frameworks/base/config/preloaded-classes":                   nil,
			"frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl": nil,
			"frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl": nil,
			"device/sample/etc/apns-full-conf.xml":                       nil,
			"device/sample/firmware/firmware.bin":                        nil,
		}),
	).RunTest(t)

	getModuleProp := func(m android.Module, matcher func(actual interface{}) string) string {
		for _, prop := range m.GetProperties() {

			if str := matcher(prop); str != "" {
				return str
			}
		}
		return ""
	}

	// check generated prebuilt_* module type install path and install partition
	generatedModule := result.ModuleForTests(t, "system-frameworks_base_config-etc-0", "android_arm64_armv8-a").Module()
	etcModule := generatedModule.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have etc install path",
		"etc",
		etcModule.BaseDir(),
	)
	android.AssertBoolEquals(
		t,
		"module expected to be installed in system partition",
		true,
		!generatedModule.InstallInProduct() &&
			!generatedModule.InstallInVendor() &&
			!generatedModule.InstallInSystemExt(),
	)

	// check generated prebuilt_* module specifies correct relative_install_path property
	generatedModule = result.ModuleForTests(t, "system-frameworks_base_data_keyboards-usr_keylayout_subdir-0", "android_arm64_armv8-a").Module()
	etcModule = generatedModule.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to set correct relative_install_path properties",
		"subdir",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module sets correct srcs
	eval := generatedModule.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"Vendor_0079_Product_0011.kl",
		getModuleProp(generatedModule, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 2 {
					return srcs[0]
				}
			}
			return ""
		}),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"Vendor_0079_Product_18d4.kl",
		getModuleProp(generatedModule, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 2 {
					return srcs[1]
				}
			}
			return ""
		}),
	)

	// check that prebuilt_* module is not generated for non existing source file
	android.AssertStringEquals(
		t,
		"prebuilt_* module not generated for non existing source file",
		"",
		strings.Join(result.ModuleVariantsForTests("system-some_non_existing-etc-0"), ","),
	)

	// check that duplicate src file can exist in PRODUCT_COPY_FILES and generates separate modules
	generatedModule0 := result.ModuleForTests(t, "product-device_sample_etc-etc-0", "android_arm64_armv8-a").Module()
	generatedModule1 := result.ModuleForTests(t, "product-device_sample_etc-etc-1", "android_arm64_armv8-a").Module()

	// check that generated prebuilt_* module sets correct srcs and dsts property
	eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"apns-full-conf.xml",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 1 {
					return srcs[0]
				}
			}
			return ""
		}),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct dsts property",
		"apns-conf.xml",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) == 1 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	// check that generated prebuilt_* module sets correct srcs and dsts property
	eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"apns-full-conf.xml",
		getModuleProp(generatedModule1, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 1 {
					return srcs[0]
				}
			}
			return ""
		}),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct dsts property",
		"apns-conf-2.xml",
		getModuleProp(generatedModule1, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) == 1 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	generatedModule0 = result.ModuleForTests(t, "system-device_sample_etc-foo-0", "android_common").Module()
	generatedModule1 = result.ModuleForTests(t, "system-device_sample_etc-foo-1", "android_common").Module()

	// check that generated prebuilt_* module sets correct srcs and dsts property
	eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"apns-full-conf.xml",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 1 {
					return srcs[0]
				}
			}
			return ""
		}),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct dsts property",
		"foo/file.txt",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) == 1 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	// check generated prebuilt_* module specifies correct install path and relative install path
	etcModule = generatedModule1.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have . install path",
		".",
		etcModule.BaseDir(),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct relative_install_path properties",
		"foo",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module sets correct srcs
	eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct srcs property",
		"apns-full-conf.xml",
		getModuleProp(generatedModule1, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
				srcs := p.Srcs.GetOrDefault(eval, nil)
				if len(srcs) == 1 {
					return srcs[0]
				}
			}
			return ""
		}),
	)

	generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-0", "android_recovery_arm64_armv8-a").Module()
	generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-1", "android_recovery_common").Module()

	// check generated prebuilt_* module specifies correct install path and relative install path
	etcModule = generatedModule0.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have . install path",
		".",
		etcModule.BaseDir(),
	)
	android.AssertStringEquals(
		t,
		"module expected to set empty relative_install_path properties",
		"",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module don't set dsts
	eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to not set dsts property",
		"",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) != 0 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	// check generated prebuilt_* module specifies correct install path and relative install path
	etcModule = generatedModule1.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have . install path",
		".",
		etcModule.BaseDir(),
	)
	android.AssertStringEquals(
		t,
		"module expected to set empty relative_install_path properties",
		"",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module sets correct dsts
	eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct dsts property",
		"firmware-2.bin",
		getModuleProp(generatedModule1, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) == 1 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-0", "android_recovery_common").Module()
	generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-1", "android_recovery_common").Module()

	// check generated prebuilt_* module specifies correct install path and relative install path
	etcModule = generatedModule0.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have . install path",
		".",
		etcModule.BaseDir(),
	)
	android.AssertStringEquals(
		t,
		"module expected to set correct relative_install_path properties",
		"lib/firmware",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module sets correct srcs
	eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to not set dsts property",
		"",
		getModuleProp(generatedModule0, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) != 0 {
					return dsts[0]
				}
			}
			return ""
		}),
	)

	// check generated prebuilt_* module specifies correct install path and relative install path
	etcModule = generatedModule1.(*etc.PrebuiltEtc)
	android.AssertStringEquals(
		t,
		"module expected to have . install path",
		".",
		etcModule.BaseDir(),
	)
	android.AssertStringEquals(
		t,
		"module expected to set empty relative_install_path properties",
		"",
		etcModule.SubDir(),
	)

	// check that generated prebuilt_* module sets correct srcs
	eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
	android.AssertStringEquals(
		t,
		"module expected to set correct dsts property",
		"lib/firmware/firmware-2.bin",
		getModuleProp(generatedModule1, func(actual interface{}) string {
			if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
				dsts := p.Dsts.GetOrDefault(eval, nil)
				if len(dsts) == 1 {
					return dsts[0]
				}
			}
			return ""
		}),
	)
}