platform_build_soong/bp2build/cc_prebuilt_library_shared_test.go
Liz Kammer 78cfdaa597 Refactor bp2build tests
Moves to specifying attributes as a map, such at it is possible to add
additional attributes conditionally. This is in particular useful once
supporting the `enabled` property which will add
`target_compatible_with`

Test: go test soong tests
Change-Id: Iade8eed1ce3acb1d1712a9ee3119d9ae59675624
2021-11-15 11:09:05 -05:00

63 lines
1.8 KiB
Go

package bp2build
import (
"testing"
"android/soong/cc"
)
func TestSharedPrebuiltLibrary(t *testing.T) {
runBp2BuildTestCaseSimple(t,
bp2buildTestCase{
description: "prebuilt library shared simple",
moduleTypeUnderTest: "cc_prebuilt_library_shared",
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build,
filesystem: map[string]string{
"libf.so": "",
},
blueprint: `
cc_prebuilt_library_shared {
name: "libtest",
srcs: ["libf.so"],
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
"shared_library": `"libf.so"`,
}),
},
})
}
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
runBp2BuildTestCaseSimple(t,
bp2buildTestCase{
description: "prebuilt library shared with arch variance",
moduleTypeUnderTest: "cc_prebuilt_library_shared",
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build,
filesystem: map[string]string{
"libf.so": "",
"libg.so": "",
},
blueprint: `
cc_prebuilt_library_shared {
name: "libtest",
arch: {
arm64: { srcs: ["libf.so"], },
arm: { srcs: ["libg.so"], },
},
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
"shared_library": `select({
"//build/bazel/platforms/arch:arm": "libg.so",
"//build/bazel/platforms/arch:arm64": "libf.so",
"//conditions:default": None,
})`,
}),
},
})
}