1// Copyright 2024 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 fsgen 16 17import ( 18 "strings" 19 "testing" 20 21 "android/soong/android" 22 "android/soong/etc" 23 "android/soong/filesystem" 24 "android/soong/java" 25 26 "github.com/google/blueprint/proptools" 27) 28 29var prepareForTestWithFsgenBuildComponents = android.FixtureRegisterWithContext(registerBuildComponents) 30 31var prepareMockRamdiksNodeList = android.FixtureMergeMockFs(android.MockFS{ 32 "ramdisk_node_list/ramdisk_node_list": nil, 33 "ramdisk_node_list/Android.bp": []byte(` 34 filegroup { 35 name: "ramdisk_node_list", 36 srcs: ["ramdisk_node_list"], 37 } 38 `), 39}) 40 41func TestFileSystemCreatorSystemImageProps(t *testing.T) { 42 result := android.GroupFixturePreparers( 43 android.PrepareForIntegrationTestWithAndroid, 44 android.PrepareForTestWithAndroidBuildComponents, 45 android.PrepareForTestWithAllowMissingDependencies, 46 filesystem.PrepareForTestWithFilesystemBuildComponents, 47 prepareForTestWithFsgenBuildComponents, 48 android.FixtureModifyConfig(func(config android.Config) { 49 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.BoardAvbEnable = true 50 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = 51 map[string]android.PartitionQualifiedVariablesType{ 52 "system": { 53 BoardAvbKeyPath: "external/avb/test/data/testkey_rsa4096.pem", 54 BoardAvbAlgorithm: "SHA256_RSA4096", 55 BoardAvbRollbackIndex: "0", 56 BoardFileSystemType: "ext4", 57 }, 58 } 59 }), 60 prepareMockRamdiksNodeList, 61 android.FixtureMergeMockFs(android.MockFS{ 62 "external/avb/test/data/testkey_rsa4096.pem": nil, 63 "external/avb/test/Android.bp": []byte(` 64 filegroup { 65 name: "avb_testkey_rsa4096", 66 srcs: ["data/testkey_rsa4096.pem"], 67 } 68 `), 69 "build/soong/fsgen/Android.bp": []byte(` 70 soong_filesystem_creator { 71 name: "foo", 72 } 73 `), 74 }), 75 ).RunTest(t) 76 77 fooSystem := result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().(interface { 78 FsProps() filesystem.FilesystemProperties 79 }) 80 android.AssertBoolEquals( 81 t, 82 "Property expected to match the product variable 'BOARD_AVB_ENABLE'", 83 true, 84 proptools.Bool(fooSystem.FsProps().Use_avb), 85 ) 86 android.AssertStringEquals( 87 t, 88 "Property the avb_private_key property to be set to the existing filegroup", 89 ":avb_testkey_rsa4096", 90 proptools.String(fooSystem.FsProps().Avb_private_key), 91 ) 92 android.AssertStringEquals( 93 t, 94 "Property expected to match the product variable 'BOARD_AVB_ALGORITHM'", 95 "SHA256_RSA4096", 96 proptools.String(fooSystem.FsProps().Avb_algorithm), 97 ) 98 android.AssertIntEquals( 99 t, 100 "Property expected to match the product variable 'BOARD_AVB_SYSTEM_ROLLBACK_INDEX'", 101 0, 102 proptools.Int(fooSystem.FsProps().Rollback_index), 103 ) 104 android.AssertStringEquals( 105 t, 106 "Property expected to match the product variable 'BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE'", 107 "ext4", 108 proptools.String(fooSystem.FsProps().Type), 109 ) 110} 111 112func TestFileSystemCreatorSetPartitionDeps(t *testing.T) { 113 result := android.GroupFixturePreparers( 114 android.PrepareForIntegrationTestWithAndroid, 115 android.PrepareForTestWithAndroidBuildComponents, 116 android.PrepareForTestWithAllowMissingDependencies, 117 filesystem.PrepareForTestWithFilesystemBuildComponents, 118 prepareForTestWithFsgenBuildComponents, 119 java.PrepareForTestWithJavaBuildComponents, 120 java.PrepareForTestWithJavaDefaultModules, 121 android.FixtureModifyConfig(func(config android.Config) { 122 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"bar", "baz"} 123 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = 124 map[string]android.PartitionQualifiedVariablesType{ 125 "system": { 126 BoardFileSystemType: "ext4", 127 }, 128 } 129 }), 130 prepareMockRamdiksNodeList, 131 android.FixtureMergeMockFs(android.MockFS{ 132 "external/avb/test/data/testkey_rsa4096.pem": nil, 133 "build/soong/fsgen/Android.bp": []byte(` 134 soong_filesystem_creator { 135 name: "foo", 136 } 137 `), 138 }), 139 ).RunTestWithBp(t, ` 140 java_library { 141 name: "bar", 142 srcs: ["A.java"], 143 } 144 java_library { 145 name: "baz", 146 srcs: ["A.java"], 147 product_specific: true, 148 } 149 `) 150 151 android.AssertBoolEquals( 152 t, 153 "Generated system image expected to depend on system partition installed \"bar\"", 154 true, 155 java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "bar"), 156 ) 157 android.AssertBoolEquals( 158 t, 159 "Generated system image expected to not depend on product partition installed \"baz\"", 160 false, 161 java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "baz"), 162 ) 163} 164 165func TestFileSystemCreatorDepsWithNamespace(t *testing.T) { 166 result := android.GroupFixturePreparers( 167 android.PrepareForIntegrationTestWithAndroid, 168 android.PrepareForTestWithAndroidBuildComponents, 169 android.PrepareForTestWithAllowMissingDependencies, 170 android.PrepareForTestWithNamespace, 171 android.PrepareForTestWithArchMutator, 172 filesystem.PrepareForTestWithFilesystemBuildComponents, 173 prepareForTestWithFsgenBuildComponents, 174 java.PrepareForTestWithJavaBuildComponents, 175 java.PrepareForTestWithJavaDefaultModules, 176 android.FixtureModifyConfig(func(config android.Config) { 177 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"bar"} 178 config.TestProductVariables.NamespacesToExport = []string{"a/b"} 179 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = 180 map[string]android.PartitionQualifiedVariablesType{ 181 "system": { 182 BoardFileSystemType: "ext4", 183 }, 184 } 185 }), 186 android.PrepareForNativeBridgeEnabled, 187 prepareMockRamdiksNodeList, 188 android.FixtureMergeMockFs(android.MockFS{ 189 "external/avb/test/data/testkey_rsa4096.pem": nil, 190 "build/soong/fsgen/Android.bp": []byte(` 191 soong_filesystem_creator { 192 name: "foo", 193 } 194 `), 195 "a/b/Android.bp": []byte(` 196 soong_namespace{ 197 } 198 java_library { 199 name: "bar", 200 srcs: ["A.java"], 201 compile_multilib: "64", 202 } 203 `), 204 "c/d/Android.bp": []byte(` 205 soong_namespace{ 206 } 207 java_library { 208 name: "bar", 209 srcs: ["A.java"], 210 } 211 `), 212 }), 213 ).RunTest(t) 214 215 var packagingProps android.PackagingProperties 216 for _, prop := range result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().GetProperties() { 217 if packagingPropStruct, ok := prop.(*android.PackagingProperties); ok { 218 packagingProps = *packagingPropStruct 219 } 220 } 221 moduleDeps := packagingProps.Multilib.Lib64.Deps 222 223 eval := result.ModuleForTests(t, "test_product_generated_system_image", "android_common").Module().ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 224 android.AssertStringListContains( 225 t, 226 "Generated system image expected to depend on \"bar\" defined in \"a/b\" namespace", 227 moduleDeps.GetOrDefault(eval, nil), 228 "//a/b:bar", 229 ) 230 android.AssertStringListDoesNotContain( 231 t, 232 "Generated system image expected to not depend on \"bar\" defined in \"c/d\" namespace", 233 moduleDeps.GetOrDefault(eval, nil), 234 "//c/d:bar", 235 ) 236} 237 238func TestRemoveOverriddenModulesFromDeps(t *testing.T) { 239 result := android.GroupFixturePreparers( 240 android.PrepareForIntegrationTestWithAndroid, 241 android.PrepareForTestWithAndroidBuildComponents, 242 android.PrepareForTestWithAllowMissingDependencies, 243 prepareForTestWithFsgenBuildComponents, 244 java.PrepareForTestWithJavaBuildComponents, 245 prepareMockRamdiksNodeList, 246 android.FixtureMergeMockFs(android.MockFS{ 247 "external/avb/test/data/testkey_rsa4096.pem": nil, 248 "build/soong/fsgen/Android.bp": []byte(` 249 soong_filesystem_creator { 250 name: "foo", 251 } 252 `), 253 }), 254 android.FixtureModifyConfig(func(config android.Config) { 255 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"libfoo", "libbar"} 256 }), 257 ).RunTestWithBp(t, ` 258java_library { 259 name: "libfoo", 260} 261java_library { 262 name: "libbar", 263 required: ["libbaz"], 264} 265java_library { 266 name: "libbaz", 267 overrides: ["libfoo"], // overrides libfoo 268} 269 `) 270 resolvedSystemDeps := result.TestContext.Config().Get(fsGenStateOnceKey).(*FsGenState).fsDeps["system"] 271 _, libFooInDeps := (*resolvedSystemDeps)["libfoo"] 272 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) 273} 274 275func TestPrebuiltEtcModuleGen(t *testing.T) { 276 result := android.GroupFixturePreparers( 277 android.PrepareForIntegrationTestWithAndroid, 278 android.PrepareForTestWithAndroidBuildComponents, 279 android.PrepareForTestWithAllowMissingDependencies, 280 filesystem.PrepareForTestWithFilesystemBuildComponents, 281 prepareForTestWithFsgenBuildComponents, 282 android.FixtureModifyConfig(func(config android.Config) { 283 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductCopyFiles = []string{ 284 "frameworks/base/config/preloaded-classes:system/etc/preloaded-classes", 285 "frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl:system/usr/keylayout/subdir/Vendor_0079_Product_0011.kl", 286 "frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl:system/usr/keylayout/subdir/Vendor_0079_Product_18d4.kl", 287 "some/non/existing/file.txt:system/etc/file.txt", 288 "device/sample/etc/apns-full-conf.xml:product/etc/apns-conf.xml:google", 289 "device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml", 290 "device/sample/etc/apns-full-conf.xml:system/foo/file.txt", 291 "device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml", 292 "device/sample/firmware/firmware.bin:recovery/root/firmware.bin", 293 "device/sample/firmware/firmware.bin:recovery/root/firmware-2.bin", 294 "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware.bin", 295 "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware-2.bin", 296 } 297 config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = 298 map[string]android.PartitionQualifiedVariablesType{ 299 "system": { 300 BoardFileSystemType: "ext4", 301 }, 302 } 303 }), 304 prepareMockRamdiksNodeList, 305 android.FixtureMergeMockFs(android.MockFS{ 306 "external/avb/test/data/testkey_rsa4096.pem": nil, 307 "build/soong/fsgen/Android.bp": []byte(` 308 soong_filesystem_creator { 309 name: "foo", 310 } 311 `), 312 "frameworks/base/config/preloaded-classes": nil, 313 "frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl": nil, 314 "frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl": nil, 315 "device/sample/etc/apns-full-conf.xml": nil, 316 "device/sample/firmware/firmware.bin": nil, 317 }), 318 ).RunTest(t) 319 320 getModuleProp := func(m android.Module, matcher func(actual interface{}) string) string { 321 for _, prop := range m.GetProperties() { 322 323 if str := matcher(prop); str != "" { 324 return str 325 } 326 } 327 return "" 328 } 329 330 // check generated prebuilt_* module type install path and install partition 331 generatedModule := result.ModuleForTests(t, "system-frameworks_base_config-etc-0", "android_arm64_armv8-a").Module() 332 etcModule := generatedModule.(*etc.PrebuiltEtc) 333 android.AssertStringEquals( 334 t, 335 "module expected to have etc install path", 336 "etc", 337 etcModule.BaseDir(), 338 ) 339 android.AssertBoolEquals( 340 t, 341 "module expected to be installed in system partition", 342 true, 343 !generatedModule.InstallInProduct() && 344 !generatedModule.InstallInVendor() && 345 !generatedModule.InstallInSystemExt(), 346 ) 347 348 // check generated prebuilt_* module specifies correct relative_install_path property 349 generatedModule = result.ModuleForTests(t, "system-frameworks_base_data_keyboards-usr_keylayout_subdir-0", "android_arm64_armv8-a").Module() 350 etcModule = generatedModule.(*etc.PrebuiltEtc) 351 android.AssertStringEquals( 352 t, 353 "module expected to set correct relative_install_path properties", 354 "subdir", 355 etcModule.SubDir(), 356 ) 357 358 // check that generated prebuilt_* module sets correct srcs 359 eval := generatedModule.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 360 android.AssertStringEquals( 361 t, 362 "module expected to set correct srcs property", 363 "Vendor_0079_Product_0011.kl", 364 getModuleProp(generatedModule, func(actual interface{}) string { 365 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 366 srcs := p.Srcs.GetOrDefault(eval, nil) 367 if len(srcs) == 2 { 368 return srcs[0] 369 } 370 } 371 return "" 372 }), 373 ) 374 android.AssertStringEquals( 375 t, 376 "module expected to set correct srcs property", 377 "Vendor_0079_Product_18d4.kl", 378 getModuleProp(generatedModule, func(actual interface{}) string { 379 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 380 srcs := p.Srcs.GetOrDefault(eval, nil) 381 if len(srcs) == 2 { 382 return srcs[1] 383 } 384 } 385 return "" 386 }), 387 ) 388 389 // check that prebuilt_* module is not generated for non existing source file 390 android.AssertStringEquals( 391 t, 392 "prebuilt_* module not generated for non existing source file", 393 "", 394 strings.Join(result.ModuleVariantsForTests("system-some_non_existing-etc-0"), ","), 395 ) 396 397 // check that duplicate src file can exist in PRODUCT_COPY_FILES and generates separate modules 398 generatedModule0 := result.ModuleForTests(t, "product-device_sample_etc-etc-0", "android_arm64_armv8-a").Module() 399 generatedModule1 := result.ModuleForTests(t, "product-device_sample_etc-etc-1", "android_arm64_armv8-a").Module() 400 401 // check that generated prebuilt_* module sets correct srcs and dsts property 402 eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 403 android.AssertStringEquals( 404 t, 405 "module expected to set correct srcs property", 406 "apns-full-conf.xml", 407 getModuleProp(generatedModule0, func(actual interface{}) string { 408 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 409 srcs := p.Srcs.GetOrDefault(eval, nil) 410 if len(srcs) == 1 { 411 return srcs[0] 412 } 413 } 414 return "" 415 }), 416 ) 417 android.AssertStringEquals( 418 t, 419 "module expected to set correct dsts property", 420 "apns-conf.xml", 421 getModuleProp(generatedModule0, func(actual interface{}) string { 422 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 423 dsts := p.Dsts.GetOrDefault(eval, nil) 424 if len(dsts) == 1 { 425 return dsts[0] 426 } 427 } 428 return "" 429 }), 430 ) 431 432 // check that generated prebuilt_* module sets correct srcs and dsts property 433 eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 434 android.AssertStringEquals( 435 t, 436 "module expected to set correct srcs property", 437 "apns-full-conf.xml", 438 getModuleProp(generatedModule1, func(actual interface{}) string { 439 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 440 srcs := p.Srcs.GetOrDefault(eval, nil) 441 if len(srcs) == 1 { 442 return srcs[0] 443 } 444 } 445 return "" 446 }), 447 ) 448 android.AssertStringEquals( 449 t, 450 "module expected to set correct dsts property", 451 "apns-conf-2.xml", 452 getModuleProp(generatedModule1, func(actual interface{}) string { 453 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 454 dsts := p.Dsts.GetOrDefault(eval, nil) 455 if len(dsts) == 1 { 456 return dsts[0] 457 } 458 } 459 return "" 460 }), 461 ) 462 463 generatedModule0 = result.ModuleForTests(t, "system-device_sample_etc-foo-0", "android_common").Module() 464 generatedModule1 = result.ModuleForTests(t, "system-device_sample_etc-foo-1", "android_common").Module() 465 466 // check that generated prebuilt_* module sets correct srcs and dsts property 467 eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 468 android.AssertStringEquals( 469 t, 470 "module expected to set correct srcs property", 471 "apns-full-conf.xml", 472 getModuleProp(generatedModule0, func(actual interface{}) string { 473 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 474 srcs := p.Srcs.GetOrDefault(eval, nil) 475 if len(srcs) == 1 { 476 return srcs[0] 477 } 478 } 479 return "" 480 }), 481 ) 482 android.AssertStringEquals( 483 t, 484 "module expected to set correct dsts property", 485 "foo/file.txt", 486 getModuleProp(generatedModule0, func(actual interface{}) string { 487 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 488 dsts := p.Dsts.GetOrDefault(eval, nil) 489 if len(dsts) == 1 { 490 return dsts[0] 491 } 492 } 493 return "" 494 }), 495 ) 496 497 // check generated prebuilt_* module specifies correct install path and relative install path 498 etcModule = generatedModule1.(*etc.PrebuiltEtc) 499 android.AssertStringEquals( 500 t, 501 "module expected to have . install path", 502 ".", 503 etcModule.BaseDir(), 504 ) 505 android.AssertStringEquals( 506 t, 507 "module expected to set correct relative_install_path properties", 508 "foo", 509 etcModule.SubDir(), 510 ) 511 512 // check that generated prebuilt_* module sets correct srcs 513 eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 514 android.AssertStringEquals( 515 t, 516 "module expected to set correct srcs property", 517 "apns-full-conf.xml", 518 getModuleProp(generatedModule1, func(actual interface{}) string { 519 if p, ok := actual.(*etc.PrebuiltEtcProperties); ok { 520 srcs := p.Srcs.GetOrDefault(eval, nil) 521 if len(srcs) == 1 { 522 return srcs[0] 523 } 524 } 525 return "" 526 }), 527 ) 528 529 generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-0", "android_recovery_arm64_armv8-a").Module() 530 generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-1", "android_recovery_common").Module() 531 532 // check generated prebuilt_* module specifies correct install path and relative install path 533 etcModule = generatedModule0.(*etc.PrebuiltEtc) 534 android.AssertStringEquals( 535 t, 536 "module expected to have . install path", 537 ".", 538 etcModule.BaseDir(), 539 ) 540 android.AssertStringEquals( 541 t, 542 "module expected to set empty relative_install_path properties", 543 "", 544 etcModule.SubDir(), 545 ) 546 547 // check that generated prebuilt_* module don't set dsts 548 eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 549 android.AssertStringEquals( 550 t, 551 "module expected to not set dsts property", 552 "", 553 getModuleProp(generatedModule0, func(actual interface{}) string { 554 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 555 dsts := p.Dsts.GetOrDefault(eval, nil) 556 if len(dsts) != 0 { 557 return dsts[0] 558 } 559 } 560 return "" 561 }), 562 ) 563 564 // check generated prebuilt_* module specifies correct install path and relative install path 565 etcModule = generatedModule1.(*etc.PrebuiltEtc) 566 android.AssertStringEquals( 567 t, 568 "module expected to have . install path", 569 ".", 570 etcModule.BaseDir(), 571 ) 572 android.AssertStringEquals( 573 t, 574 "module expected to set empty relative_install_path properties", 575 "", 576 etcModule.SubDir(), 577 ) 578 579 // check that generated prebuilt_* module sets correct dsts 580 eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 581 android.AssertStringEquals( 582 t, 583 "module expected to set correct dsts property", 584 "firmware-2.bin", 585 getModuleProp(generatedModule1, func(actual interface{}) string { 586 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 587 dsts := p.Dsts.GetOrDefault(eval, nil) 588 if len(dsts) == 1 { 589 return dsts[0] 590 } 591 } 592 return "" 593 }), 594 ) 595 596 generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-0", "android_recovery_common").Module() 597 generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-1", "android_recovery_common").Module() 598 599 // check generated prebuilt_* module specifies correct install path and relative install path 600 etcModule = generatedModule0.(*etc.PrebuiltEtc) 601 android.AssertStringEquals( 602 t, 603 "module expected to have . install path", 604 ".", 605 etcModule.BaseDir(), 606 ) 607 android.AssertStringEquals( 608 t, 609 "module expected to set correct relative_install_path properties", 610 "lib/firmware", 611 etcModule.SubDir(), 612 ) 613 614 // check that generated prebuilt_* module sets correct srcs 615 eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 616 android.AssertStringEquals( 617 t, 618 "module expected to not set dsts property", 619 "", 620 getModuleProp(generatedModule0, func(actual interface{}) string { 621 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 622 dsts := p.Dsts.GetOrDefault(eval, nil) 623 if len(dsts) != 0 { 624 return dsts[0] 625 } 626 } 627 return "" 628 }), 629 ) 630 631 // check generated prebuilt_* module specifies correct install path and relative install path 632 etcModule = generatedModule1.(*etc.PrebuiltEtc) 633 android.AssertStringEquals( 634 t, 635 "module expected to have . install path", 636 ".", 637 etcModule.BaseDir(), 638 ) 639 android.AssertStringEquals( 640 t, 641 "module expected to set empty relative_install_path properties", 642 "", 643 etcModule.SubDir(), 644 ) 645 646 // check that generated prebuilt_* module sets correct srcs 647 eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) 648 android.AssertStringEquals( 649 t, 650 "module expected to set correct dsts property", 651 "lib/firmware/firmware-2.bin", 652 getModuleProp(generatedModule1, func(actual interface{}) string { 653 if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { 654 dsts := p.Dsts.GetOrDefault(eval, nil) 655 if len(dsts) == 1 { 656 return dsts[0] 657 } 658 } 659 return "" 660 }), 661 ) 662} 663