platform_build_soong/bp2build/cc_prebuilt_library_shared_test.go
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux c5184ec089 Rename prebuilt_library_* to cc_prebuilt_library_*
Follow the convention of everything else in `cc`

Test: CI
Change-Id: I133d0b7119d4e9b357aada3467bc079f20dc0f60
2022-10-20 14:51:55 +00:00

85 lines
2.2 KiB
Go

package bp2build
import (
"fmt"
"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,
Filesystem: map[string]string{
"libf.so": "",
},
Blueprint: `
cc_prebuilt_library_shared {
name: "libtest",
srcs: ["libf.so"],
bazel_module: { bp2build_available: true },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_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,
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("cc_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,
})`,
}),
},
})
}
func TestSharedPrebuiltLibrarySharedStanzaFails(t *testing.T) {
RunBp2BuildTestCaseSimple(t,
Bp2buildTestCase{
Description: "prebuilt library shared with shared stanza fails because multiple sources",
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
Filesystem: map[string]string{
"libf.so": "",
"libg.so": "",
},
Blueprint: `
cc_prebuilt_library_shared {
name: "libtest",
srcs: ["libf.so"],
shared: {
srcs: ["libg.so"],
},
bazel_module: { bp2build_available: true},
}`,
ExpectedErr: fmt.Errorf("Expected at most one source file"),
})
}