Add support for SDK tests with LinuxBionic OS type.

Break apart test helpers a bit to make it possible to enable
LinuxBionic in a single test, and add LinuxBionic support to
cc.GatherRequiredDepsForTest.

Test: m nothing
Bug: 160349757
Change-Id: Iace1024c964cee2308c130c945daef9e46c18c66
This commit is contained in:
Martin Stjernholm
2020-07-11 04:33:29 +01:00
parent 6e97a7b4a1
commit 7feceb2354
3 changed files with 96 additions and 17 deletions

View File

@@ -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)