Loading apex/apex_test.go +41 −66 Original line number Diff line number Diff line Loading @@ -4479,14 +4479,11 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { if filepath.Base(output) == base { foundLibfooJar = true buildRule := s.Output(output) actual := android.NormalizePathForTesting(buildRule.Input) if actual != bootDexJarPath { t.Errorf("Incorrect boot dex jar path '%s', expected '%s'", actual, bootDexJarPath) } android.AssertStringEquals(t, "boot dex jar path", bootDexJarPath, buildRule.Input.String()) } } if !foundLibfooJar { t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs") t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().BuildDir(), s.AllOutputs())) } } Loading Loading @@ -4528,8 +4525,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4635,8 +4632,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4702,8 +4699,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4771,8 +4768,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -6423,13 +6420,9 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpre func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) *android.TestContext { t.Helper() bp += cc.GatherRequiredDepsForTest(android.Android) bp += java.GatherRequiredDepsForTest() fs := map[string][]byte{ fs := android.MockFS{ "a.java": nil, "a.jar": nil, "build/make/target/product/security": nil, "apex_manifest.json": nil, "AndroidManifest.xml": nil, "system/sepolicy/apex/myapex-file_contexts": nil, Loading @@ -6438,30 +6431,19 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt "system/sepolicy/apex/com.android.art.debug-file_contexts": nil, "framework/aidl/a.aidl": nil, } cc.GatherRequiredFilesForTest(fs) for k, v := range filesForSdkLibrary { fs[k] = v errorHandler := android.FixtureExpectsNoErrors if errmsg != "" { errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(errmsg) } config := android.TestArchConfig(t.TempDir(), nil, bp, fs) ctx := android.NewTestArchContext(config) ctx.RegisterModuleType("apex", BundleFactory) ctx.RegisterModuleType("apex_key", ApexKeyFactory) ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterComponentsMutator) android.RegisterPrebuiltMutators(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterHiddenApiSingletonComponents(ctx) ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators) ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators) ctx.Register() result := android.GroupFixturePreparers( cc.PrepareForTestWithCcDefaultModules, java.PrepareForTestWithHiddenApiBuildComponents, java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, PrepareForTestWithApexBuildComponents, android.FixtureModifyConfig(func(config android.Config) { pathCtx := android.PathContextForTesting(config) dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx) transformDexpreoptConfig(dexpreoptConfig) Loading @@ -6471,20 +6453,13 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt // product variables. config.TestProductVariables.BootJars = dexpreoptConfig.BootJars config.TestProductVariables.UpdatableBootJars = dexpreoptConfig.UpdatableBootJars }), fs.AddToFixture(), ). ExtendWithErrorHandler(errorHandler). RunTestWithBp(t, bp) _, errs := ctx.ParseBlueprintsFiles("Android.bp") android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) if errmsg == "" { android.FailIfErrored(t, errs) } else if len(errs) > 0 { android.FailIfNoMatchingErrors(t, errmsg, errs) } else { t.Fatalf("missing expected error %q (0 errors are returned)", errmsg) } return ctx return result.TestContext } func TestUpdatable_should_set_min_sdk_version(t *testing.T) { Loading Loading
apex/apex_test.go +41 −66 Original line number Diff line number Diff line Loading @@ -4479,14 +4479,11 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { if filepath.Base(output) == base { foundLibfooJar = true buildRule := s.Output(output) actual := android.NormalizePathForTesting(buildRule.Input) if actual != bootDexJarPath { t.Errorf("Incorrect boot dex jar path '%s', expected '%s'", actual, bootDexJarPath) } android.AssertStringEquals(t, "boot dex jar path", bootDexJarPath, buildRule.Input.String()) } } if !foundLibfooJar { t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs") t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().BuildDir(), s.AllOutputs())) } } Loading Loading @@ -4528,8 +4525,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4635,8 +4632,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4702,8 +4699,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -4771,8 +4768,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` Loading Loading @@ -6423,13 +6420,9 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpre func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) *android.TestContext { t.Helper() bp += cc.GatherRequiredDepsForTest(android.Android) bp += java.GatherRequiredDepsForTest() fs := map[string][]byte{ fs := android.MockFS{ "a.java": nil, "a.jar": nil, "build/make/target/product/security": nil, "apex_manifest.json": nil, "AndroidManifest.xml": nil, "system/sepolicy/apex/myapex-file_contexts": nil, Loading @@ -6438,30 +6431,19 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt "system/sepolicy/apex/com.android.art.debug-file_contexts": nil, "framework/aidl/a.aidl": nil, } cc.GatherRequiredFilesForTest(fs) for k, v := range filesForSdkLibrary { fs[k] = v errorHandler := android.FixtureExpectsNoErrors if errmsg != "" { errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(errmsg) } config := android.TestArchConfig(t.TempDir(), nil, bp, fs) ctx := android.NewTestArchContext(config) ctx.RegisterModuleType("apex", BundleFactory) ctx.RegisterModuleType("apex_key", ApexKeyFactory) ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterComponentsMutator) android.RegisterPrebuiltMutators(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterHiddenApiSingletonComponents(ctx) ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators) ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators) ctx.Register() result := android.GroupFixturePreparers( cc.PrepareForTestWithCcDefaultModules, java.PrepareForTestWithHiddenApiBuildComponents, java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, PrepareForTestWithApexBuildComponents, android.FixtureModifyConfig(func(config android.Config) { pathCtx := android.PathContextForTesting(config) dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx) transformDexpreoptConfig(dexpreoptConfig) Loading @@ -6471,20 +6453,13 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt // product variables. config.TestProductVariables.BootJars = dexpreoptConfig.BootJars config.TestProductVariables.UpdatableBootJars = dexpreoptConfig.UpdatableBootJars }), fs.AddToFixture(), ). ExtendWithErrorHandler(errorHandler). RunTestWithBp(t, bp) _, errs := ctx.ParseBlueprintsFiles("Android.bp") android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) if errmsg == "" { android.FailIfErrored(t, errs) } else if len(errs) > 0 { android.FailIfNoMatchingErrors(t, errmsg, errs) } else { t.Fatalf("missing expected error %q (0 errors are returned)", errmsg) } return ctx return result.TestContext } func TestUpdatable_should_set_min_sdk_version(t *testing.T) { Loading