Merge "Add support for SDK tests with LinuxBionic OS type."
This commit is contained in:
commit
3044394329
3 changed files with 96 additions and 17 deletions
|
@ -30,6 +30,7 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
|||
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
||||
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
||||
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
||||
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
|
||||
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
||||
ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
|
||||
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
||||
|
@ -39,6 +40,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
ret := `
|
||||
toolchain_library {
|
||||
name: "libatomic",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
|
@ -92,6 +94,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
toolchain_library {
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
|
@ -121,6 +124,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
toolchain_library {
|
||||
name: "libclang_rt.fuzzer-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
src: "",
|
||||
|
@ -144,6 +148,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
toolchain_library {
|
||||
name: "libgcc",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
src: "",
|
||||
|
@ -151,6 +156,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
toolchain_library {
|
||||
name: "libgcc_stripped",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
recovery_available: true,
|
||||
sdk_version: "current",
|
||||
|
@ -159,6 +165,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
cc_library {
|
||||
name: "libc",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
stl: "none",
|
||||
|
@ -175,6 +182,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
}
|
||||
cc_library {
|
||||
name: "libm",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
stl: "none",
|
||||
|
@ -234,6 +242,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
cc_library {
|
||||
name: "libdl",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
stl: "none",
|
||||
|
@ -326,6 +335,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
|
||||
cc_defaults {
|
||||
name: "crt_defaults",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
recovery_available: true,
|
||||
vendor_available: true,
|
||||
native_bridge_supported: true,
|
||||
|
@ -437,6 +447,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
}
|
||||
`
|
||||
|
||||
supportLinuxBionic := false
|
||||
for _, os := range oses {
|
||||
if os == android.Fuchsia {
|
||||
ret += `
|
||||
|
@ -465,7 +476,59 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
|||
}
|
||||
`
|
||||
}
|
||||
if os == android.LinuxBionic {
|
||||
supportLinuxBionic = true
|
||||
ret += `
|
||||
cc_binary {
|
||||
name: "linker",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
recovery_available: true,
|
||||
stl: "none",
|
||||
nocrt: true,
|
||||
static_executable: true,
|
||||
native_coverage: false,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
|
||||
cc_genrule {
|
||||
name: "host_bionic_linker_flags",
|
||||
host_supported: true,
|
||||
device_supported: false,
|
||||
target: {
|
||||
host: {
|
||||
enabled: false,
|
||||
},
|
||||
linux_bionic: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
out: ["linker.flags"],
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "linux_bionic_supported",
|
||||
host_supported: true,
|
||||
target: {
|
||||
host: {
|
||||
enabled: false,
|
||||
},
|
||||
linux_bionic: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
if !supportLinuxBionic {
|
||||
ret += `
|
||||
cc_defaults {
|
||||
name: "linux_bionic_supported",
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,7 @@ import (
|
|||
"android/soong/cc"
|
||||
)
|
||||
|
||||
func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
|
||||
t.Helper()
|
||||
|
||||
fs := map[string][]byte{
|
||||
var ccTestFs = map[string][]byte{
|
||||
"Test.cpp": nil,
|
||||
"include/Test.h": nil,
|
||||
"include-android/AndroidTest.h": nil,
|
||||
|
@ -34,7 +31,10 @@ func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
|
|||
"aidl/foo/bar/Test.aidl": nil,
|
||||
"some/where/stubslib.map.txt": nil,
|
||||
}
|
||||
return testSdkWithFs(t, bp, fs)
|
||||
|
||||
func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
|
||||
t.Helper()
|
||||
return testSdkWithFs(t, bp, ccTestFs)
|
||||
}
|
||||
|
||||
// Contains tests for SDK members provided by the cc package.
|
||||
|
|
|
@ -29,7 +29,9 @@ import (
|
|||
"android/soong/java"
|
||||
)
|
||||
|
||||
func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, android.Config) {
|
||||
func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsType) (*android.TestContext, android.Config) {
|
||||
extraOsTypes = append(extraOsTypes, android.Android, android.Windows)
|
||||
|
||||
bp = bp + `
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
|
@ -41,7 +43,7 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||
name: "myapex.cert",
|
||||
certificate: "myapex",
|
||||
}
|
||||
` + cc.GatherRequiredDepsForTest(android.Android, android.Windows)
|
||||
` + cc.GatherRequiredDepsForTest(extraOsTypes...)
|
||||
|
||||
mockFS := map[string][]byte{
|
||||
"build/make/target/product/security": nil,
|
||||
|
@ -69,6 +71,15 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||
{android.Windows, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", ""},
|
||||
}
|
||||
|
||||
for _, extraOsType := range extraOsTypes {
|
||||
switch extraOsType {
|
||||
case android.LinuxBionic:
|
||||
config.Targets[android.LinuxBionic] = []android.Target{
|
||||
{android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", ""},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx := android.NewTestArchContext()
|
||||
|
||||
// Enable androidmk support.
|
||||
|
@ -117,9 +128,8 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||
return ctx, config
|
||||
}
|
||||
|
||||
func testSdkWithFs(t *testing.T, bp string, fs map[string][]byte) *testSdkResult {
|
||||
func runTests(t *testing.T, ctx *android.TestContext, config android.Config) *testSdkResult {
|
||||
t.Helper()
|
||||
ctx, config := testSdkContext(bp, fs)
|
||||
_, errs := ctx.ParseBlueprintsFiles(".")
|
||||
android.FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
|
@ -131,9 +141,15 @@ func testSdkWithFs(t *testing.T, bp string, fs map[string][]byte) *testSdkResult
|
|||
}
|
||||
}
|
||||
|
||||
func testSdkWithFs(t *testing.T, bp string, fs map[string][]byte) *testSdkResult {
|
||||
t.Helper()
|
||||
ctx, config := testSdkContext(bp, fs, nil)
|
||||
return runTests(t, ctx, config)
|
||||
}
|
||||
|
||||
func testSdkError(t *testing.T, pattern, bp string) {
|
||||
t.Helper()
|
||||
ctx, config := testSdkContext(bp, nil)
|
||||
ctx, config := testSdkContext(bp, nil, nil)
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
if len(errs) > 0 {
|
||||
android.FailIfNoMatchingErrors(t, pattern, errs)
|
||||
|
|
Loading…
Reference in a new issue