diff options
| -rw-r--r-- | android/config.go | 3 | ||||
| -rw-r--r-- | android/test_suites.go | 26 | ||||
| -rw-r--r-- | android/updatable_modules.go | 2 | ||||
| -rw-r--r-- | apex/apex_test.go | 372 | ||||
| -rw-r--r-- | java/Android.bp | 2 | ||||
| -rw-r--r-- | java/aapt2.go | 3 | ||||
| -rw-r--r-- | java/aar.go | 2 | ||||
| -rw-r--r-- | java/config/droidstubs.go | 4 | ||||
| -rw-r--r-- | java/lint.go | 22 | ||||
| -rw-r--r-- | java/lint_test.go | 100 | ||||
| -rw-r--r-- | java/ravenwood.go | 191 | ||||
| -rw-r--r-- | java/ravenwood_test.go | 122 | ||||
| -rw-r--r-- | mk2rbc/test/version_defaults.mk.test | 4 | ||||
| -rw-r--r-- | tradefed/config.go | 1 |
14 files changed, 600 insertions, 254 deletions
diff --git a/android/config.go b/android/config.go index eb1e647d4..c506c4bdf 100644 --- a/android/config.go +++ b/android/config.go @@ -612,9 +612,12 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) "framework-adservices": {}, "framework-appsearch": {}, "framework-bluetooth": {}, + "framework-configinfrastructure": {}, "framework-connectivity": {}, "framework-connectivity-t": {}, + "framework-devicelock": {}, "framework-graphics": {}, + "framework-healthfitness": {}, "framework-location": {}, "framework-media": {}, "framework-mediaprovider": {}, diff --git a/android/test_suites.go b/android/test_suites.go index 9ded99832..adcc15a6e 100644 --- a/android/test_suites.go +++ b/android/test_suites.go @@ -24,6 +24,7 @@ func testSuiteFilesFactory() Singleton { type testSuiteFiles struct { robolectric WritablePath + ravenwood WritablePath } type TestSuiteModule interface { @@ -47,12 +48,15 @@ func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) { }) t.robolectric = robolectricTestSuite(ctx, files["robolectric-tests"]) - ctx.Phony("robolectric-tests", t.robolectric) + + t.ravenwood = ravenwoodTestSuite(ctx, files["ravenwood-tests"]) + ctx.Phony("ravenwood-tests", t.ravenwood) } func (t *testSuiteFiles) MakeVars(ctx MakeVarsContext) { ctx.DistForGoal("robolectric-tests", t.robolectric) + ctx.DistForGoal("ravenwood-tests", t.ravenwood) } func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) WritablePath { @@ -74,3 +78,23 @@ func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) W return outputFile } + +func ravenwoodTestSuite(ctx SingletonContext, files map[string]InstallPaths) WritablePath { + var installedPaths InstallPaths + for _, module := range SortedKeys(files) { + installedPaths = append(installedPaths, files[module]...) + } + testCasesDir := pathForInstall(ctx, ctx.Config().BuildOS, X86, "testcases") + + outputFile := PathForOutput(ctx, "packaging", "ravenwood-tests.zip") + rule := NewRuleBuilder(pctx, ctx) + rule.Command().BuiltTool("soong_zip"). + FlagWithOutput("-o ", outputFile). + FlagWithArg("-P ", "host/testcases"). + FlagWithArg("-C ", testCasesDir.String()). + FlagWithRspFileInputList("-r ", outputFile.ReplaceExtension(ctx, "rsp"), installedPaths.Paths()). + Flag("-sha256") + rule.Build("ravenwood_tests_zip", "ravenwood-tests.zip") + + return outputFile +} diff --git a/android/updatable_modules.go b/android/updatable_modules.go index 6d0eeb716..1548170f9 100644 --- a/android/updatable_modules.go +++ b/android/updatable_modules.go @@ -33,4 +33,4 @@ package android // * AOSP - xx9990000 // * x-mainline-prod - xx9990000 // * master - 990090000 -const DefaultUpdatableModuleVersion = "340090000" +const DefaultUpdatableModuleVersion = "990090000" diff --git a/apex/apex_test.go b/apex/apex_test.go index 7e67c0f9d..229175fbd 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -10273,188 +10273,196 @@ func ensureDoesNotContainRequiredDeps(t *testing.T, ctx *android.TestContext, mo } } -// TODO(b/193460475): Re-enable this test -//func TestApexStrictUpdtabilityLint(t *testing.T) { -// bpTemplate := ` -// apex { -// name: "myapex", -// key: "myapex.key", -// java_libs: ["myjavalib"], -// updatable: %v, -// min_sdk_version: "29", -// } -// apex_key { -// name: "myapex.key", -// } -// java_library { -// name: "myjavalib", -// srcs: ["MyClass.java"], -// apex_available: [ "myapex" ], -// lint: { -// strict_updatability_linting: %v, -// }, -// sdk_version: "current", -// min_sdk_version: "29", -// } -// ` -// fs := android.MockFS{ -// "lint-baseline.xml": nil, -// } -// -// testCases := []struct { -// testCaseName string -// apexUpdatable bool -// javaStrictUpdtabilityLint bool -// lintFileExists bool -// disallowedFlagExpected bool -// }{ -// { -// testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd", -// apexUpdatable: true, -// javaStrictUpdtabilityLint: true, -// lintFileExists: false, -// disallowedFlagExpected: false, -// }, -// { -// testCaseName: "non-updatable apex respects strict_updatability of javalib", -// apexUpdatable: false, -// javaStrictUpdtabilityLint: false, -// lintFileExists: true, -// disallowedFlagExpected: false, -// }, -// { -// testCaseName: "non-updatable apex respects strict updatability of javalib", -// apexUpdatable: false, -// javaStrictUpdtabilityLint: true, -// lintFileExists: true, -// disallowedFlagExpected: true, -// }, -// { -// testCaseName: "updatable apex sets strict updatability of javalib to true", -// apexUpdatable: true, -// javaStrictUpdtabilityLint: false, // will be set to true by mutator -// lintFileExists: true, -// disallowedFlagExpected: true, -// }, -// } -// -// for _, testCase := range testCases { -// bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint) -// fixtures := []android.FixturePreparer{} -// if testCase.lintFileExists { -// fixtures = append(fixtures, fs.AddToFixture()) -// } -// -// result := testApex(t, bp, fixtures...) -// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") -// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) -// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") -// -// if disallowedFlagActual != testCase.disallowedFlagExpected { -// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command) -// } -// } -//} -// -//func TestUpdatabilityLintSkipLibcore(t *testing.T) { -// bp := ` -// apex { -// name: "myapex", -// key: "myapex.key", -// java_libs: ["myjavalib"], -// updatable: true, -// min_sdk_version: "29", -// } -// apex_key { -// name: "myapex.key", -// } -// java_library { -// name: "myjavalib", -// srcs: ["MyClass.java"], -// apex_available: [ "myapex" ], -// sdk_version: "current", -// min_sdk_version: "29", -// } -// ` -// -// testCases := []struct { -// testCaseName string -// moduleDirectory string -// disallowedFlagExpected bool -// }{ -// { -// testCaseName: "lintable module defined outside libcore", -// moduleDirectory: "", -// disallowedFlagExpected: true, -// }, -// { -// testCaseName: "lintable module defined in libcore root directory", -// moduleDirectory: "libcore/", -// disallowedFlagExpected: false, -// }, -// { -// testCaseName: "lintable module defined in libcore child directory", -// moduleDirectory: "libcore/childdir/", -// disallowedFlagExpected: true, -// }, -// } -// -// for _, testCase := range testCases { -// lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "") -// bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp) -// result := testApex(t, "", lintFileCreator, bpFileCreator) -// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") -// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) -// cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory) -// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags) -// -// if disallowedFlagActual != testCase.disallowedFlagExpected { -// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command) -// } -// } -//} -// -//// checks transtive deps of an apex coming from bootclasspath_fragment -//func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) { -// bp := ` -// apex { -// name: "myapex", -// key: "myapex.key", -// bootclasspath_fragments: ["mybootclasspathfragment"], -// updatable: true, -// min_sdk_version: "29", -// } -// apex_key { -// name: "myapex.key", -// } -// bootclasspath_fragment { -// name: "mybootclasspathfragment", -// contents: ["myjavalib"], -// apex_available: ["myapex"], -// hidden_api: { -// split_packages: ["*"], -// }, -// } -// java_library { -// name: "myjavalib", -// srcs: ["MyClass.java"], -// apex_available: [ "myapex" ], -// sdk_version: "current", -// min_sdk_version: "29", -// compile_dex: true, -// } -// ` -// fs := android.MockFS{ -// "lint-baseline.xml": nil, -// } -// -// result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture()) -// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") -// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto")) -// if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") { -// t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command) -// } -//} +func TestApexStrictUpdtabilityLint(t *testing.T) { + bpTemplate := ` + apex { + name: "myapex", + key: "myapex.key", + java_libs: ["myjavalib"], + updatable: %v, + min_sdk_version: "29", + } + apex_key { + name: "myapex.key", + } + java_library { + name: "myjavalib", + srcs: ["MyClass.java"], + apex_available: [ "myapex" ], + lint: { + strict_updatability_linting: %v, + %s + }, + sdk_version: "current", + min_sdk_version: "29", + } + ` + fs := android.MockFS{ + "lint-baseline.xml": nil, + } + + testCases := []struct { + testCaseName string + apexUpdatable bool + javaStrictUpdtabilityLint bool + lintFileExists bool + disallowedFlagExpected bool + }{ + { + testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd", + apexUpdatable: true, + javaStrictUpdtabilityLint: true, + lintFileExists: false, + disallowedFlagExpected: false, + }, + { + testCaseName: "non-updatable apex respects strict_updatability of javalib", + apexUpdatable: false, + javaStrictUpdtabilityLint: false, + lintFileExists: true, + disallowedFlagExpected: false, + }, + { + testCaseName: "non-updatable apex respects strict updatability of javalib", + apexUpdatable: false, + javaStrictUpdtabilityLint: true, + lintFileExists: true, + disallowedFlagExpected: true, + }, + { + testCaseName: "updatable apex sets strict updatability of javalib to true", + apexUpdatable: true, + javaStrictUpdtabilityLint: false, // will be set to true by mutator + lintFileExists: true, + disallowedFlagExpected: true, + }, + } + + for _, testCase := range testCases { + fixtures := []android.FixturePreparer{} + baselineProperty := "" + if testCase.lintFileExists { + fixtures = append(fixtures, fs.AddToFixture()) + baselineProperty = "baseline_filename: \"lint-baseline.xml\"" + } + bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint, baselineProperty) + + result := testApex(t, bp, fixtures...) + myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") + sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto")) + disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") + + if disallowedFlagActual != testCase.disallowedFlagExpected { + t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command) + } + } +} + +func TestUpdatabilityLintSkipLibcore(t *testing.T) { + bp := ` + apex { + name: "myapex", + key: "myapex.key", + java_libs: ["myjavalib"], + updatable: true, + min_sdk_version: "29", + } + apex_key { + name: "myapex.key", + } + java_library { + name: "myjavalib", + srcs: ["MyClass.java"], + apex_available: [ "myapex" ], + sdk_version: "current", + min_sdk_version: "29", + lint: { + baseline_filename: "lint-baseline.xml", + } + } + ` + + testCases := []struct { + testCaseName string + moduleDirectory string + disallowedFlagExpected bool + }{ + { + testCaseName: "lintable module defined outside libcore", + moduleDirectory: "", + disallowedFlagExpected: true, + }, + { + testCaseName: "lintable module defined in libcore root directory", + moduleDirectory: "libcore/", + disallowedFlagExpected: false, + }, + { + testCaseName: "lintable module defined in libcore child directory", + moduleDirectory: "libcore/childdir/", + disallowedFlagExpected: true, + }, + } + + for _, testCase := range testCases { + lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "") + bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp) + result := testApex(t, "", lintFileCreator, bpFileCreator) + myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") + sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto")) + cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory) + disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags) + + if disallowedFlagActual != testCase.disallowedFlagExpected { + t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command) + } + } +} + +// checks transtive deps of an apex coming from bootclasspath_fragment +func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) { + bp := ` + apex { + name: "myapex", + key: "myapex.key", + bootclasspath_fragments: ["mybootclasspathfragment"], + updatable: true, + min_sdk_version: "29", + } + apex_key { + name: "myapex.key", + } + bootclasspath_fragment { + name: "mybootclasspathfragment", + contents: ["myjavalib"], + apex_available: ["myapex"], + hidden_api: { + split_packages: ["*"], + }, + } + java_library { + name: "myjavalib", + srcs: ["MyClass.java"], + apex_available: [ "myapex" ], + sdk_version: "current", + min_sdk_version: "29", + compile_dex: true, + lint: { + baseline_filename: "lint-baseline.xml", + } + } + ` + fs := android.MockFS{ + "lint-baseline.xml": nil, + } + + result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture()) + myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29") + sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto")) + if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") { + t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command) + } +} // updatable apexes should propagate updatable=true to its apps func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) { diff --git a/java/Android.bp b/java/Android.bp index 2585cd23f..54b36ab60 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -67,6 +67,7 @@ bootstrap_go_package { "plugin.go", "prebuilt_apis.go", "proto.go", + "ravenwood.go", "robolectric.go", "rro.go", "sdk.go", @@ -107,6 +108,7 @@ bootstrap_go_package { "plugin_test.go", "prebuilt_apis_test.go", "proto_test.go", + "ravenwood_test.go", "rro_test.go", "sdk_library_test.go", "sdk_test.go", diff --git a/java/aapt2.go b/java/aapt2.go index 445e91298..f704fc6fc 100644 --- a/java/aapt2.go +++ b/java/aapt2.go @@ -309,7 +309,8 @@ func aapt2ExtractExtraPackages(ctx android.ModuleContext, out android.WritablePa var aapt2ConvertRule = pctx.AndroidStaticRule("aapt2Convert", blueprint.RuleParams{ - Command: `${config.Aapt2Cmd} convert --output-format $format $in -o $out`, + Command: `${config.Aapt2Cmd} convert --enable-compact-entries ` + + `--output-format $format $in -o $out`, CommandDeps: []string{"${config.Aapt2Cmd}"}, }, "format", ) diff --git a/java/aar.go b/java/aar.go index b162ef639..ad53e9db6 100644 --- a/java/aar.go +++ b/java/aar.go @@ -203,6 +203,8 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte // Flags specified in Android.bp linkFlags = append(linkFlags, a.aaptProperties.Aaptflags...) + linkFlags = append(linkFlags, "--enable-compact-entries") + // Find implicit or explicit asset and resource dirs assets := android.PathsRelativeToModuleSourceDir(android.SourceInput{ Context: ctx, diff --git a/java/config/droidstubs.go b/java/config/droidstubs.go index f46c893fd..39eec444c 100644 --- a/java/config/droidstubs.go +++ b/java/config/droidstubs.go @@ -23,7 +23,6 @@ var ( "--format=v2", "--repeat-errors-max 10", "--hide UnresolvedImport", - "--hide InvalidNullabilityOverride", // Force metalava to ignore classes on the classpath when an API file contains missing classes. // See b/285140653 for more information. @@ -49,9 +48,6 @@ var ( // TODO(tnorbye): find owners to fix these warnings when annotation was enabled. "--hide HiddenTypedefConstant", "--hide SuperfluousPrefix", - "--hide AnnotationExtraction", - // b/222738070 - "--hide BannedThrow", } MetalavaAnnotationsWarningsFlags = strings.Join(metalavaAnnotationsWarningsFlags, " ") diff --git a/java/lint.go b/java/lint.go index c3d723b40..bd6c1bae6 100644 --- a/java/lint.go +++ b/java/lint.go @@ -319,25 +319,19 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru cmd.FlagWithInput("@", android.PathForSource(ctx, "build/soong/java/lint_defaults.txt")) - if l.compileSdkKind == android.SdkPublic { - cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors) - } else { - // TODO(b/268261262): Remove this branch. We're demoting NewApi to a warning due to pre-existing issues that need to be fixed. - cmd.FlagForEachArg("--warning_check ", l.extraMainlineLintErrors) - } + cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors) cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks) cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks) cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) - // TODO(b/193460475): Re-enable strict updatability linting - //if l.GetStrictUpdatabilityLinting() { - // // Verify the module does not baseline issues that endanger safe updatability. - // if baselinePath := l.getBaselineFilepath(ctx); baselinePath.Valid() { - // cmd.FlagWithInput("--baseline ", baselinePath.Path()) - // cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks) - // } - //} + if l.GetStrictUpdatabilityLinting() { + // Verify the module does not baseline issues that endanger safe updatability. + if l.properties.Lint.Baseline_filename != nil { + cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename)) + cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks) + } + } return lintPaths{ projectXML: projectXMLPath, diff --git a/java/lint_test.go b/java/lint_test.go index b7e6aad8e..6aee5946b 100644 --- a/java/lint_test.go +++ b/java/lint_test.go @@ -91,9 +91,8 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) { t.Error("did not use the correct file for baseline") } - if !strings.Contains(*sboxProto.Commands[0].Command, "--warning_check NewApi") { - // TODO(b/268261262): Change this to check for --error_check - t.Error("should check NewApi warnings") + if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") { + t.Error("should check NewApi errors") } if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") { @@ -153,52 +152,55 @@ func TestJavaLintBypassUpdatableChecks(t *testing.T) { } } -// TODO(b/193460475): Re-enable this test -//func TestJavaLintStrictUpdatabilityLinting(t *testing.T) { -// bp := ` -// java_library { -// name: "foo", -// srcs: [ -// "a.java", -// ], -// static_libs: ["bar"], -// min_sdk_version: "29", -// sdk_version: "current", -// lint: { -// strict_updatability_linting: true, -// }, -// } -// -// java_library { -// name: "bar", -// srcs: [ -// "a.java", -// ], -// min_sdk_version: "29", -// sdk_version: "current", -// } -// ` -// fs := android.MockFS{ -// "lint-baseline.xml": nil, -// } -// -// result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()). -// RunTestWithBp(t, bp) -// -// foo := result.ModuleForTests("foo", "android_common") -// sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) -// if !strings.Contains(*sboxProto.Commands[0].Command, -// "--baseline lint-baseline.xml --disallowed_issues NewApi") { -// t.Error("did not restrict baselining NewApi") -// } -// -// bar := result.ModuleForTests("bar", "android_common") -// sboxProto = android.RuleBuilderSboxProtoForTests(t, bar.Output("lint.sbox.textproto")) -// if !strings.Contains(*sboxProto.Commands[0].Command, -// "--baseline lint-baseline.xml --disallowed_issues NewApi") { -// t.Error("did not restrict baselining NewApi") -// } -//} +func TestJavaLintStrictUpdatabilityLinting(t *testing.T) { + bp := ` + java_library { + name: "foo", + srcs: [ + "a.java", + ], + static_libs: ["bar"], + min_sdk_version: "29", + sdk_version: "current", + lint: { + strict_updatability_linting: true, + baseline_filename: "lint-baseline.xml", + }, + } + + java_library { + name: "bar", + srcs: [ + "a.java", + ], + min_sdk_version: "29", + sdk_version: "current", + lint: { + baseline_filename: "lint-baseline.xml", + } + } + ` + fs := android.MockFS{ + "lint-baseline.xml": nil, + } + + result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()). + RunTestWithBp(t, bp) + + foo := result.ModuleForTests("foo", "android_common") + sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto")) + if !strings.Contains(*sboxProto.Commands[0].Command, + "--baseline lint-baseline.xml --disallowed_issues NewApi") { + t.Error("did not restrict baselining NewApi") + } + + bar := result.ModuleForTests("bar", "android_common") + sboxProto = android.RuleBuilderSboxProtoForTests(t, result.TestContext, bar.Output("lint.sbox.textproto")) + if !strings.Contains(*sboxProto.Commands[0].Command, + "--baseline lint-baseline.xml --disallowed_issues NewApi") { + t.Error("did not restrict baselining NewApi") + } +} func TestJavaLintDatabaseSelectionFull(t *testing.T) { testCases := []struct { diff --git a/java/ravenwood.go b/java/ravenwood.go new file mode 100644 index 000000000..e36200307 --- /dev/null +++ b/java/ravenwood.go @@ -0,0 +1,191 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package java + +import ( + "android/soong/android" + "android/soong/tradefed" + + "github.com/google/blueprint/proptools" +) + +func init() { + RegisterRavenwoodBuildComponents(android.InitRegistrationContext) +} + +func RegisterRavenwoodBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("android_ravenwood_test", ravenwoodTestFactory) + ctx.RegisterModuleType("android_ravenwood_libgroup", ravenwoodLibgroupFactory) +} + +var ravenwoodTag = dependencyTag{name: "ravenwood"} + +const ravenwoodUtilsName = "ravenwood-utils" +const ravenwoodRuntimeName = "ravenwood-runtime" + +type ravenwoodTest struct { + Library + + testProperties testProperties + testConfig android.Path + + forceOSType android.OsType + forceArchType android.ArchType +} + +func ravenwoodTestFactory() android.Module { + module := &ravenwoodTest{} + + module.addHostAndDeviceProperties() + module.AddProperties(&module.testProperties) + + module.Module.dexpreopter.isTest = true + module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true) + + module.testProperties.Test_suites = []string{ + "general-tests", + "ravenwood-tests", + } + module.testProperties.Test_options.Unit_test = proptools.BoolPtr(false) + + InitJavaModule(module, android.DeviceSupported) + android.InitDefaultableModule(module) + + return module +} + +func (r *ravenwoodTest) InstallInTestcases() bool { return true } +func (r *ravenwoodTest) InstallForceOS() (*android.OsType, *android.ArchType) { + return &r.forceOSType, &r.forceArchType +} +func (r *ravenwoodTest) TestSuites() []string { + return r.testProperties.Test_suites +} + +func (r *ravenwoodTest) DepsMutator(ctx android.BottomUpMutatorContext) { + r.Library.DepsMutator(ctx) + + // Generically depend on the runtime so that it's installed together with us + ctx.AddVariationDependencies(nil, ravenwoodTag, ravenwoodRuntimeName) + + // Directly depend on any utils so that we link against them + utils := ctx.AddVariationDependencies(nil, ravenwoodTag, ravenwoodUtilsName)[0] + if utils != nil { + for _, lib := range utils.(*ravenwoodLibgroup).ravenwoodLibgroupProperties.Libs { + ctx.AddVariationDependencies(nil, libTag, lib) + } + } +} + +func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + + r.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{ + TestConfigProp: r.testProperties.Test_config, + TestConfigTemplateProp: r.testProperties.Test_config_template, + TestSuites: r.testProperties.Test_suites, + AutoGenConfig: r.testProperties.Auto_gen_config, + DeviceTemplate: "${RavenwoodTestConfigTemplate}", + HostTemplate: "${RavenwoodTestConfigTemplate}", + }) + + r.Library.GenerateAndroidBuildActions(ctx) + + // Start by depending on all files installed by dependancies + var installDeps android.InstallPaths + for _, dep := range ctx.GetDirectDepsWithTag(ravenwoodTag) { + for _, installFile := range dep.FilesToInstall() { + installDeps = append(installDeps, installFile) + } + } + + // Also depend on our config + installPath := android.PathForModuleInstall(ctx, r.BaseModuleName()) + installConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig) + installDeps = append(installDeps, installConfig) + + // Finally install our JAR with all dependencies + ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...) +} + +func (r *ravenwoodTest) AndroidMkEntries() []android.AndroidMkEntries { + entriesList := r.Library.AndroidMkEntries() + entries := &entriesList[0] + entries.ExtraEntries = append(entries.ExtraEntries, + func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { + entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", + "general-tests", "ravenwood-tests") + if r.testConfig != nil { + entries.SetPath("LOCAL_FULL_TEST_CONFIG", r.testConfig) + } + }) + return entriesList +} + +type ravenwoodLibgroupProperties struct { + Libs []string +} + +type ravenwoodLibgroup struct { + android.ModuleBase + + ravenwoodLibgroupProperties ravenwoodLibgroupProperties + + forceOSType android.OsType + forceArchType android.ArchType +} + +func ravenwoodLibgroupFactory() android.Module { + module := &ravenwoodLibgroup{} + module.AddProperties(&module.ravenwoodLibgroupProperties) + + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + return module +} + +func (r *ravenwoodLibgroup) InstallInTestcases() bool { return true } +func (r *ravenwoodLibgroup) InstallForceOS() (*android.OsType, *android.ArchType) { + return &r.forceOSType, &r.forceArchType +} +func (r *ravenwoodLibgroup) TestSuites() []string { + return []string{ + "general-tests", + "ravenwood-tests", + } +} + +func (r *ravenwoodLibgroup) DepsMutator(ctx android.BottomUpMutatorContext) { + // Always depends on our underlying libs + for _, lib := range r.ravenwoodLibgroupProperties.Libs { + ctx.AddVariationDependencies(nil, ravenwoodTag, lib) + } +} + +func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + + // Install our runtime into expected location for packaging + installPath := android.PathForModuleInstall(ctx, r.BaseModuleName()) + for _, lib := range r.ravenwoodLibgroupProperties.Libs { + libModule := ctx.GetDirectDepWithTag(lib, ravenwoodTag) + libJar := android.OutputFileForModule(ctx, libModule, "") + ctx.InstallFile(installPath, lib+".jar", libJar) + } + + // Normal build should perform install steps + ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install")) +} diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go new file mode 100644 index 000000000..2443ea8e7 --- /dev/null +++ b/java/ravenwood_test.go @@ -0,0 +1,122 @@ +// Copyright 2022 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package java + +import ( + "runtime" + "testing" + + "android/soong/android" +) + +var prepareRavenwoodRuntime = android.GroupFixturePreparers( + android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { + RegisterRavenwoodBuildComponents(ctx) + }), + android.FixtureAddTextFile("ravenwood/Android.bp", ` + java_library_static { + name: "framework-minus-apex.ravenwood", + srcs: ["Framework.java"], + } + java_library_static { + name: "framework-services.ravenwood", + srcs: ["Services.java"], + } + java_library_static { + name: "framework-rules.ravenwood", + srcs: ["Rules.java"], + } + android_ravenwood_libgroup { + name: "ravenwood-runtime", + libs: [ + "framework-minus-apex.ravenwood", + "framework-services.ravenwood", + ], + } + android_ravenwood_libgroup { + name: "ravenwood-utils", + libs: [ + "framework-rules.ravenwood", + ], + } + `), +) + +var installPathPrefix = "out/soong/host/linux-x86/testcases" + +func TestRavenwoodRuntime(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("requires linux") + } + + ctx := android.GroupFixturePreparers( + PrepareForIntegrationTestWithJava, + prepareRavenwoodRuntime, + ).RunTest(t) + + // Verify that our runtime depends on underlying libs + CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-runtime", "android_common", "framework-minus-apex.ravenwood") + CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-runtime", "android_common", "framework-services.ravenwood") + CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-utils", "android_common", "framework-rules.ravenwood") + + // Verify that we've emitted artifacts in expected location + runtime := ctx.ModuleForTests("ravenwood-runtime", "android_common") + runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-minus-apex.ravenwood.jar") + runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-services.ravenwood.jar") + utils := ctx.ModuleForTests("ravenwood-utils", "android_common") + utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar") +} + +func TestRavenwoodTest(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("requires linux") + } + + ctx := android.GroupFixturePreparers( + PrepareForIntegrationTestWithJava, + prepareRavenwoodRuntime, + ).RunTestWithBp(t, ` + android_ravenwood_test { + name: "ravenwood-test", + srcs: ["Test.java"], + sdk_version: "test_current", + } + `) + + // Verify that our test depends on underlying libs + CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-test", "android_common", "ravenwood-buildtime") + CheckModuleHasDependency(t, ctx.TestContext, "ravenwood-test", "android_common", "ravenwood-utils") + + module := ctx.ModuleForTests("ravenwood-test", "android_common") + classpath := module.Rule("javac").Args["classpath"] + + // Verify that we're linking against test_current + android.AssertStringDoesContain(t, "classpath", classpath, "android_test_stubs_current.jar") + // Verify that we're linking against utils + android.AssertStringDoesContain(t, "classpath", classpath, "framework-rules.ravenwood.jar") + // Verify that we're *NOT* linking against runtime + android.AssertStringDoesNotContain(t, "classpath", classpath, "framework-minus-apex.ravenwood.jar") + android.AssertStringDoesNotContain(t, "classpath", classpath, "framework-services.ravenwood.jar") + + // Verify that we've emitted test artifacts in expected location + outputJar := module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.jar") + module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.config") + + // Verify that we're going to install underlying libs + orderOnly := outputJar.OrderOnly.Strings() + android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-minus-apex.ravenwood.jar") + android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-services.ravenwood.jar") + android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar") +} diff --git a/mk2rbc/test/version_defaults.mk.test b/mk2rbc/test/version_defaults.mk.test index 166639278..3ce60bcdb 100644 --- a/mk2rbc/test/version_defaults.mk.test +++ b/mk2rbc/test/version_defaults.mk.test @@ -3,8 +3,8 @@ ifdef INTERNAL_BUILD_ID_MAKEFILE include $(INTERNAL_BUILD_ID_MAKEFILE) endif -DEFAULT_PLATFORM_VERSION := TP1A -.KATI_READONLY := DEFAULT_PLATFORM_VERSION +RELEASE_PLATFORM_VERSION := TP1A +.KATI_READONLY := RELEASE_PLATFORM_VERSION MIN_PLATFORM_VERSION := TP1A MAX_PLATFORM_VERSION := TP1A PLATFORM_VERSION_LAST_STABLE := 12 diff --git a/tradefed/config.go b/tradefed/config.go index 326a00666..b0150348b 100644 --- a/tradefed/config.go +++ b/tradefed/config.go @@ -33,6 +33,7 @@ func init() { pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml") pctx.SourcePathVariable("PythonBinaryHostMoblyTestConfigTemplate", "build/make/core/python_binary_host_mobly_test_config_template.xml") pctx.SourcePathVariable("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml") + pctx.SourcePathVariable("RavenwoodTestConfigTemplate", "build/make/core/ravenwood_test_config_template.xml") pctx.SourcePathVariable("RustDeviceTestConfigTemplate", "build/make/core/rust_device_test_config_template.xml") pctx.SourcePathVariable("RustHostTestConfigTemplate", "build/make/core/rust_host_test_config_template.xml") pctx.SourcePathVariable("RustDeviceBenchmarkConfigTemplate", "build/make/core/rust_device_benchmark_config_template.xml") |