3177a6e1e0
bp2buildTestCase attrNameToString runBp2BuildTestCase makeBazelTargetNoRestrictions The testing framework defined in the bp2build package can only be used from within the package because many common testing functions are private to the package. This prevents modules defined in Soong plugins (e.g. system/tools/aidl/build) from testing bp2build conversions. Test: go test ./bp2build Change-Id: Ia867081327c5181d04687b13c4550e68e6a11f86
85 lines
2.2 KiB
Go
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("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("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"),
|
|
})
|
|
}
|