add bp2build unit tests for aidl_interface
Bug: 229251008 Test: go test ./bp2build -run TestAidlInterface Change-Id: Ie7214d5578bc21e348410ca91ea42d7a3190eb3d
This commit is contained in:
@@ -18,6 +18,7 @@ bootstrap_go_package {
|
||||
"testing.go",
|
||||
],
|
||||
deps: [
|
||||
"aidl-soong-rules",
|
||||
"soong-android",
|
||||
"soong-android-allowlists",
|
||||
"soong-android-soongconfig",
|
||||
@@ -36,6 +37,7 @@ bootstrap_go_package {
|
||||
],
|
||||
testSrcs: [
|
||||
"aar_conversion_test.go",
|
||||
"aidl_interface_conversion_test.go",
|
||||
"android_app_certificate_conversion_test.go",
|
||||
"android_app_conversion_test.go",
|
||||
"apex_conversion_test.go",
|
||||
|
249
bp2build/aidl_interface_conversion_test.go
Normal file
249
bp2build/aidl_interface_conversion_test.go
Normal file
@@ -0,0 +1,249 @@
|
||||
package bp2build
|
||||
|
||||
import (
|
||||
"android/soong/aidl"
|
||||
"android/soong/android"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runAidlInterfaceTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
RunBp2BuildTestCase(
|
||||
t,
|
||||
func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("aidl_interface", aidl.AidlInterfaceFactory)
|
||||
ctx.RegisterModuleType("aidl_interface_headers", aidl.AidlInterfaceHeadersFactory)
|
||||
},
|
||||
tc,
|
||||
)
|
||||
}
|
||||
|
||||
func TestAidlInterfaceHeaders(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface_headers`,
|
||||
Blueprint: `
|
||||
aidl_interface_headers {
|
||||
name: "aidl-interface-headers",
|
||||
include_dir: "src",
|
||||
srcs: [
|
||||
"src/A.aidl",
|
||||
],
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_library", "aidl-interface-headers", AttrNameToString{
|
||||
"strip_import_prefix": `"src"`,
|
||||
"hdrs": `["src/A.aidl"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAidlInterface(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface with single "latest" aidl_interface import`,
|
||||
Blueprint: `
|
||||
aidl_interface_headers {
|
||||
name: "aidl-interface-headers",
|
||||
}
|
||||
aidl_interface {
|
||||
name: "aidl-interface-import",
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
],
|
||||
}
|
||||
aidl_interface {
|
||||
name: "aidl-interface1",
|
||||
flags: ["--flag1"],
|
||||
imports: [
|
||||
"aidl-interface-import-V1",
|
||||
],
|
||||
headers: [
|
||||
"aidl-interface-headers",
|
||||
],
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_library", "aidl-interface-headers", AttrNameToString{}),
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface-import", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
]`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface1", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"deps": `[
|
||||
":aidl-interface-import-V1",
|
||||
":aidl-interface-headers",
|
||||
]`,
|
||||
"flags": `["--flag1"]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAidlInterfaceWithNoProperties(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface no properties set`,
|
||||
Blueprint: `
|
||||
aidl_interface {
|
||||
name: "aidl-interface1",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface1", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAidlInterfaceWithDisabledBackends(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface with some backends disabled`,
|
||||
Blueprint: `
|
||||
aidl_interface {
|
||||
name: "aidl-interface1",
|
||||
backend: {
|
||||
ndk: {
|
||||
enabled: false,
|
||||
},
|
||||
cpp: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface1", AttrNameToString{
|
||||
"backends": `["java"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAidlInterfaceWithLatestImport(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface with single "latest" aidl_interface import`,
|
||||
Blueprint: `
|
||||
aidl_interface {
|
||||
name: "aidl-interface-import",
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
],
|
||||
}
|
||||
aidl_interface {
|
||||
name: "aidl-interface1",
|
||||
imports: [
|
||||
"aidl-interface-import",
|
||||
],
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface-import", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
]`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface1", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"deps": `[":aidl-interface-import-latest"]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAidlInterfaceWithVersionedImport(t *testing.T) {
|
||||
runAidlInterfaceTestCase(t, Bp2buildTestCase{
|
||||
Description: `aidl_interface with single versioned aidl_interface import`,
|
||||
Blueprint: `
|
||||
aidl_interface {
|
||||
name: "aidl-interface-import",
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
],
|
||||
}
|
||||
aidl_interface {
|
||||
name: "aidl-interface1",
|
||||
imports: [
|
||||
"aidl-interface-import-V2",
|
||||
],
|
||||
versions: [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface-import", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
]`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("aidl_interface", "aidl-interface1", AttrNameToString{
|
||||
"backends": `[
|
||||
"cpp",
|
||||
"java",
|
||||
"ndk",
|
||||
]`,
|
||||
"deps": `[":aidl-interface-import-V2"]`,
|
||||
"versions": `[
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
10
go.mod
10
go.mod
@@ -1,13 +1,17 @@
|
||||
module android/soong
|
||||
|
||||
require google.golang.org/protobuf v0.0.0
|
||||
|
||||
require github.com/google/blueprint v0.0.0
|
||||
require (
|
||||
google.golang.org/protobuf v0.0.0
|
||||
github.com/google/blueprint v0.0.0
|
||||
android/soong/aidl v0.0.0
|
||||
)
|
||||
|
||||
replace google.golang.org/protobuf v0.0.0 => ../../external/golang-protobuf
|
||||
|
||||
replace github.com/google/blueprint v0.0.0 => ../blueprint
|
||||
|
||||
replace android/soong/aidl v0.0.0 => ../../system/tools/aidl/build
|
||||
|
||||
// Indirect deps from golang-protobuf
|
||||
exclude github.com/golang/protobuf v1.5.0
|
||||
|
||||
|
@@ -93,6 +93,7 @@ function create_mock_soong {
|
||||
symlink_directory external/go-cmp
|
||||
symlink_directory external/golang-protobuf
|
||||
symlink_directory external/starlark-go
|
||||
symlink_directory system/tools/aidl
|
||||
|
||||
touch "$MOCK_TOP/Android.bp"
|
||||
}
|
||||
|
Reference in New Issue
Block a user